GRUB2 not detecting OS on raid partitions
Solution 1
Grub2 now has some understanding for md
devices. It should be provided via loadable modules as necessary.
Make sure that your system understands that it needs the md
devices to boot. Ensure all arrays are listed in /etc/mdadm/mdadm.conf
and run:
# dpkg-reconfigure mdadm
(nb: I recently has to something similar on my Debian system, but it ought to apply for Ubuntu as well)
Solution 2
At the grub menu, press 'e' to edit the menu entry and manually change the root= kernel argument to point to the raid array and boot from it manually. Then run update-grub, and it will see that you are currently booting from the raid array and configure itself to do so in the future.
Also, you don't need to have a separate /boot partition.
Related videos on Youtube
sleeves
Updated on September 18, 2022Comments
-
sleeves over 1 year
I have recently added a drive to a system and have successfully raid'ed (RAID-1) the paritions, with the exception of the boot partition. I have it ready and mirrored, but can't get GRUB2 (update-grub) to find it.
System: Ubuntu 11.04 Raid Metadata: 1.2
If I run update-grub, it finds the kernel images on the /dev/sda2 partition (present root) but not the images on /dev/md127.
/dev/md127 is composed of "missing" and "/dev/sdb2".
fdisk on /dev/sdb confirms that sdb2 is of type fd (raid autodetect) and is also flagged bootable.
I have two things I want to do.
- Make the boot.cfg on /dev/sdb2 have a menu option to have the root be /dev/md127
- Install grub onto /dev/md127 so the actual boot.cfg from there is being used.
Disk partitions:
$ sudo sfdisk -l /dev/sda Disk /dev/sda: 30394 cylinders, 255 heads, 63 sectors/track Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0 Device Boot Start End #cyls #blocks Id System /dev/sda1 0+ 13 14- 112423+ de Dell Utility /dev/sda2 * 14 7837 7824 62846280 83 Linux /dev/sda3 7838 8882 1045 8393962+ 82 Linux swap / Solaris /dev/sda4 8883 30393 21511 172787107+ 5 Extended /dev/sda5 8883+ 30393 21511- 172787076 83 Linux $ sudo sfdisk -l /dev/sdb Disk /dev/sdb: 30394 cylinders, 255 heads, 63 sectors/track Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0 Device Boot Start End #cyls #blocks Id System /dev/sdb1 0+ 13 14- 112423+ de Dell Utility /dev/sdb2 * 14 7837 7824 62846280 fd Linux raid autodetect /dev/sdb3 7838 8882 1045 8393962+ 82 Linux swap / Solaris /dev/sdb4 8883 30393 21511 172787107+ 5 Extended /dev/sdb5 8883+ 30393 21511- 172787076 fd Linux raid autodetect
The thing to note here is that /dev/sdb2 is part of a raid, while /dev/sda2 is not. /dev/sda2 is the present non-raid boot that works fine. I would like to switch to a raid boot and when that is good, convert sda2 to raid and add it to the "missing" raid drive.
$ cat /proc/mdstat Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] md5 : active raid1 sda5[2] sdb5[1] 172785980 blocks super 1.2 [2/2] [UU] md127 : active raid1 sdb2[1] 62846208 blocks [2/1] [_U]
The tail end of mdadm.conf. This was auto-generated by /usr/share/mdadm/mkconf
# This file was auto-generated on Thu, 30 Jun 2011 14:38:15 -0500 # by mkconf $Id$ ARRAY /dev/md127 UUID=352d87d1:23d5c92d:04cfec0a:0340cbb1 ARRAY /dev/md/5 metadata=1.2 UUID=7ea17a90:6cbf0816:feef74da:5fa4f88a name=ramuh:5
The grub.cfg file that boots fine from /dev/sda2
menuentry 'Ubuntu, with Linux 2.6.38-11-generic-pae' --class ubuntu --class gnu-linux --class gnu --class os { recordfail set gfxpayload=$linux_gfx_mode insmod part_msdos insmod ext2 set root='(/dev/sda,msdos2)' search --no-floppy --fs-uuid --set=root 7bbe19ee-c62c-4674-b0ca-281d1cedac00 linux /boot/vmlinuz-2.6.38-11-generic-pae root=UUID=7bbe19ee-c62c-4674-b0ca-281d1cedac00 ro quiet splash vt.handoff=7 initrd /boot/initrd.img-2.6.38-11-generic-pae
Thanks!
-
sleeves almost 13 yearsBTW, I have already searched and found a metadata issue like this where grub 2 used to require metadata 0.9. However, that is old news and all that I see now recommends metadata 1.2.
-
Nils almost 13 yearsCan you post your full grub config used for booting?
-
sleeves over 12 yearsSorry, but I haven't gotten around to posting it. I could be wrong, but do you think the problem could be in there? That file is not used for scanning, right? It is an output that is auto-generated. I'll still post it if you think it will help.
-
Nils over 12 yearsPropably not. But I think there is a error in your thoughts. How can grub find a soft-mirror-device to load the initrd while the initrd contains the code for the soft-mirror? IMO the raid can only be active AFTER the initrd has been loaded. Thus you can`t install grub on md127 (because it is not a physical disk known by grub).
-
Nils over 12 yearsNext question that arises is - why is your raid1 not started after booting? Does your mdadm.conf contain the right content and is sda2 also set up as raid auto-detect?
-
sleeves over 12 years@Nils, thanks for the help. I think I would be OK if initrd was not loaded via raid. I also think that I could easily add the right root= in order to make it boot raid. My main concern is in getting grub to scan and add that entry automatically. Do you think if I manually edited the config and booted that way, then the scan might work?
-
sleeves over 12 years@Nils, the raid is setup properly as far as each drive and the "auto-detect". In fact, it works fine as a raid device if I manually mount it to some folder.
-
sleeves over 12 yearsThanks. Here is what I am in the process of doing. 1) dpkg-reconfigure mdadm (make sure no errors) 2) mount /dev/md/127 /newroot 3) rsync -avx / /newroot/ 4) grub-mkconfig (I don't expect this to find the raid) 5) reboot and manually change root= to point to /dev/md/127 6) grub-mkconfig (I expect this to find the raid and update grub.cfg to load the proper modules)
-
Steve Townsend over 12 yearsDon't use /dev/md/127, use /dev/md127. Why is it showing up as /dev/md127 and not, say, /dev/md0? Probably not a big deal.
-
sleeves over 12 yearsThanks Mikey. Not going well. I did many things and none of them boot right. /dev/md127 was something weird that I wondered about. The other partition is /dev/md5 and md127 was once /dev/md2 but on some reboot it decided to change. NOTE: grub-rescue cannot see the raid drives. I type: insmod raid and insmod mdraid09 and ls and see nothing but hd0 drives. Again, the only way to get it to boot is to change the BIOS boot to the second drive which has the original non-raid boot setup. I then can change root=/dev/md127 and it boots fine.
-
Steve Townsend over 12 yearsCan you post your complete partitioning? And /proc/mdstat, /etc/mdadm/mdadm.conf? Something's not quite right.
-
sleeves over 12 yearsIt is resolved. The steps are very similar to above and makes sense. 1) Do all of the stuff you said, 2) grub-install /dev/sda, 3) grub-mkconfig > /newroot/boot/grub/menu.cfg, where newroot is /dev/md127 mounted, 4) grub-mkconfig > /boot/grub/menu.cfg, 5) Reboot and manually edit the first grub entry so that it has root=/dev/md127, 6) Let it boot, then re-run these steps all over again (some redundancy). Re-installing grub makes sure it now is going to look at /dev/md127 for grub info, 7) Reboot and when it works, add the other disk to the raid array and install grub to the other disk.