Instal Grub2 on mirrored (spare) raid drive

Hi everyone:
I have a server with 2 disk on mirror RAID. In older times on grub1 and suse 11.0 i get working the server to boot on any disk. I remember that i install the grub on mbr of sda and mbr of sdb.

In this mode in case of primary disk failure, the system is able to boot on secondary disk. I must recognize that was ussefull when one of disk fail.

Now the server has growup, and have 2 disk of 3Tb (on raid of course) and opensuse 13.2 with grub 2

The question is HOW i can install the spare grub on secondary disk?. The idea is that if i invert sata cables, or change boot priority or one disk fail the system can boot normally.

My disk configuration is:

gdisk /dev/sda
GPT fdisk (gdisk) version 0.8.10

Partition table scan:
  MBR: hybrid
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with hybrid MBR; using GPT.

Command (? for help): p
Disk /dev/sda: 5860533168 sectors, 2.7 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 3864627C-A5F7-4C31-A173-1EC7F7AFDD5F
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 5860533134
Partitions will be aligned on 2048-sector boundaries
Total free space is 4859 sectors (2.4 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          821361   400.1 MiB   EF00  primary
   2          823296         5011455   2.0 GiB     0700  primary
   3         5011456      1053591551   500.0 GiB   FD00  primary
   4      1053591552      5860532223   2.2 TiB     FD00  primary


gdisk /dev/sdb -l
GPT fdisk (gdisk) version 0.8.10

Partition table scan:
  MBR: hybrid
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with hybrid MBR; using GPT.
Disk /dev/sdb: 5860533168 sectors, 2.7 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 589E7CEC-A758-4F11-A570-30164686B311
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 5860533134
Partitions will be aligned on 2048-sector boundaries
Total free space is 2925 sectors (1.4 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          819199   399.0 MiB   0700  primary
   2          819200         5011455   2.0 GiB     0700  primary
   3         5011456      1053591551   500.0 GiB   FD00  primary
   4      1053591552      5860532223   2.2 TiB     FD00  primary


Running “grub2-install /dev/sdb” should be OK. You can add second bootloader device to /etc/defaut/grub_installdevice, so that any grub2 update will automatically refresh both drives. Actually, YaST bootloader should offer to do it when it detects mirrored disks.

Thanks arvidjaar for your help,

First i see that /boot partition is not mirrored (raid), so i do the following steps:

My /boot is on /dev/sda1 and i my /dev/sdb1 was empty. This is bad, because if sda fail sdb never will able to boot.

Create mount point:

mkdir /boot.spare/

Edit fstab:
-Here i comment the mount with exact disk data to the generic /dev/sda:
-Create mount rule NOAUTO to /dev/sdb1


#/dev/disk/by-id/ata-WDC_WD30EZRX-00D8PB0_WD-WMC4N1660824-part1 /boot                ext4       acl,user_xattr        1 2
/dev/sda1              /boot                ext4       acl,user_xattr               1 2
/dev/sdb1               /boot.spare          ext4       acl,user_xattr,noauto        1 2

Copy /boot to /boot.spare

find ./ -mount -xdev -print | cpio -pdumVa /boot.spare/

And finally install the grub2 on sdb:

grub2-install /dev/sdb
/usr/sbin/grub2-bios-setup: warning: This partition label have not any starting BIOS partition; The embebbed is not possible.
/usr/sbin/grub2-bios-setup: error: The embebbed is not possible, but is necesary for a multiple partitions.

OUCH, how i can solve this with a running system?

The only way to solve that i think is:
1)mark failed to /dev/sdb (md0 and md1).
2)Taking the advantage that sda & sdb have the same capacity i can do
DD if=/dev/sda of=/dev/sdb
3)Reinsert /dev/sdb to md0 and md1.

I think that i will try that.

If this work, i will get a real good copy of partitions and the synced data.

Please, run bootinfoscript (https://github.com/arvidjaar/bootinfoscript) and upload result to http://susepaste.org

Here is the report
http://susepaste.org/94936592

:shame::shame:

Some comments in random order

  1. You say you updated to openSUSE 13.2 but bootloader is grub2 1.99, which is far too old for 13.2. It is quite possible that bootloader installation failed during update for the same reason installation on /dev/sdb fails now. You probably want to fix it.
  2. You are using hybrid partition table for no real reason. As long as you do not really need it, I’d consider converting it to pure GPT. I think hybrid was popular with openSUSE in the past. Unfortunately you cannot convert to MBR due to disk size.
  3. Because GPT partition table does not reserve space before the very first partition as MBR did, grub2 - at least, version used in openSUSE 13.2 and above - expects you to create separate partition to reserve space for bootloader. This becomes even more important if you are using /boot on Linux MD. You do not have this partition which explains installation failure.
  4. YaST2 supports only installation of grub2 on mirrored disk in “MBR” (or on full disk). If you intend to mirror /boot (instead of maintaining a second copy), it is also your only choice.

So what I’d do in this case

  1. Carve out some space from second partition. It is swap, so you can easily shrink it. Actually, sda already has ~950K between sda1 and sda2. It is enough; you just need to change sdb to mirror it.
  2. Create BIOS boot partition on both drives (GPT GUID 21686148-6449-6E6F-744E-656564454649) [FONT=verdana]in free space.[/FONT]
  3. [FONT=verdana]Mirror /boot (instead of copy it).[/FONT]
  4. [FONT=verdana]Install grub2 on /dev/sda and /dev/sdb. It should work now.[/FONT]

[FONT=verdana]
If you for some reasons insist on maintaining separate /boot copy on second drive, install it using

grub2-install --boot-directory=/boot.spare --force /dev/sdb

It should install grub2 in blocklist mode, leaving second stage on filesystem. Just like you apparently have it now on /boot.

Oh, and I would be interested in getting copy of your core.img (/boot/grub2/i386-pc/core.img); bootinfoscript fails to parse it. Could you make this file as well as MBR (first 512 bytes of /dev/sda) somehow available? Thank you!
[/FONT]

  1. Is my fault, the running system is 13.1 “bottle” i miss the keyboard when type. Sorry, real sorry for mistake.
    2)this is working now in master, i don’t know about the convenience of modify the system. It can be done after get a bootable copy

4)No problem i prefer edit files at hand, in this way i will learn where is needed touch.

About the steps to do: Please do not get hungry but i prefer ask like a children to avoid crash a running server.
1)I must do:


gdisk /dev/sdb
d 2 (delete partition 2, swap)
c p 2 start=823296     end=5011455 (create partition 2 as primary with same start and end point that sda2)
t 0700 (assign same partition type like sda2)
d 1(delete partition 1, /boot.spare)
c p 1 start=2048     end=821361  (create boot partition 1 as primary with same start and end that sda1)
t EF00 (asign efi type to /dev/sda1

2)free space to asign gpt GUID 21686148-6449-6E6F-744E-656564454649, is inside red marks or the newest /dev/sdb1


   1            2048          821361   400.1 MiB   EF00  primary
   2          823296         5011455   2.0 GiB     0700  primary

3)Use this metod to clone, right?

 dd if=/dev/sda1 of=/dev/sdb1
  1. core img have binary data. You can download a copy from my server.
    http://www.schweb.com.ar/share/core.img

Real thanks, you help is really great.

Does not matter, grub2 1.99 is still too old even for this. But see below.

I must do:

gdisk /dev/sdb
d 2 (delete partition 2, swap)
c p 2 start=823296 end=5011455 (create partition 2 as primary with same start and end point that sda2)
t 0700 (assign same partition type like sda2)
d 1(delete partition 1, /boot.spare)
c p 1 start=2048 end=821361 (create boot partition 1 as primary with same start and end that sda1)
t EF00 (asign efi type to /dev/sda1

No, type EF00 is wrong for both sda1 and sdb1. They are not EFI System Partitions, but just plain Linux ones. So the correct types (without using Linux MD) would be 8300 for sda1 and sdb1 and 8200 for sda2 and sdb2. But note that older parted may not know these partition types, so using 0700 would be appropriate as well. Not that it really matters - Linux does not care about those types - but it would avoid confusion when you ask people for help :slight_smile: Of course if you decide to mirror them you may consider changing type to FD00.

2)free space to asign gpt GUID 21686148-6449-6E6F-744E-656564454649, is inside red marks or the newest /dev/sdb1

1 2048 821361 400.1 MiB EF00 primary
2 823296 5011455 2.0 GiB 0700 primary

You actually have two free areas - before the very first partition and this one. It is up to you which one to chose. If you create additional partition in the beginning you can skip previous step entirely.

3)Use this metod to clone, right?

 dd if=/dev/sda1 of=/dev/sdb1

No. You should never use dd to duplicate file system. New filesystem will have same UUID and label and this will result in rather bad confusion everywhere including GRUB. Create new filesystem on /dev/sdb1 and copy content of /boot to it. But note that you would need to replicate grub.cfg and all kernels every time they change (like when new kernel is installed). And you will need to manually run grub2-install every time grub2 is updated as well.

  1. core img have binary data. You can download a copy from my server.
    http://www.schweb.com.ar/share/core.img

Well, this core.img is from grub 2.00, so something went wrong with detection. As this is out of scope here - care to open issue on github so we can track it? It will probably need some extended debug output.

well, before that i do your suggerences, the disaster ocurrs. An energy fail on the city occur, and when the power come back the server cant boot.

The motherboard is a old 2003 gygabte with a athlon 2000+. Is based on BIOS/MBR start system, and for some reason the bios is corrupted.

When try to boot of disk, say “grub loading”, and hangup. But when try to boot of installation dvd appear “ISOLINUX…” (previous to green screen) hangup, even disk plugged or not.
At this point with an non booting motherboard, i was stuck.

So, here is my thanks you so much, and apologize for continuity fault in this thread. I have buyed all things for a fresh install. I am sure that i will ask how install grub2 on mirrored disk, but i a new installation.

Best Regards
Christian