Bug 841452 - Grub picks bad root device when using mdadm raid1
Grub picks bad root device when using mdadm raid1
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: grub (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Václav Pavlín
Release Test Team
: 1260540 (view as bug list)
Depends On:
  Show dependency treegraph
Reported: 2012-07-19 00:02 EDT by Phil Anderson
Modified: 2015-10-23 09:59 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2013-04-03 04:53:02 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Phil Anderson 2012-07-19 00:02:12 EDT
When installing grub on a raid1 boot device, grub-install doesn't make a sensible choice about which device to use as the root device.  This can lead to booting being unnecessarily dependent on both drives in a mirrored configuration.

In my example, I have /dev/md0 made up of a raid1 array of /dev/sda1 & /dev/sdb1 which is mounted as /boot.

When I run grub-install /dev/md0 or /dev/sda, it uses (hd1,0) as the root drive, due to mdadm arbitrarily returning /dev/sdb1 as the first device in the array.  This due to the following code in grub-install:
# There's not a real root device, so just pick the first
if is_raid1_device $root_device ; then
    root_device=`find_real_devs $root_device | awk '{print $1}'`

As grub (installed on the first disk) is looking for the second disk, I am unable to boot should the second disk fail.

grub-install could be smartened up to prefer a root_device on the same disk which we are installing grub on, or possibly the lower numbered disk (assuming that if disk 0 fails, disk 1 becomes disk 0).  This would make booting after single a disk failure much more likely to succeed for simple mirrored configurations.
Comment 2 Vladimir Serbinenko 2012-08-01 13:54:14 EDT
This issue can't be solved reliably without UUIDs. Adding UUIDs to GRUB Legacy is possible (see e.g. Ubuntu patchs) it feels like an overkill for this old code and creates other problems which need hints to be solved.
Comment 3 Václav Pavlín 2012-12-06 08:40:13 EST
Hi, would this solve your issue, Phil:

As Vladimir writes it would be probably overkill to implement this to Grub Legacy. If How-To from link works for you, I will close this bug.
Comment 4 Phil Anderson 2012-12-06 20:01:13 EST
Unfortunately I don't have time at the moment to test that, but it sounds like it would work.  I simply tweaked grub-installer and hard coded root_device.  Not a proper solution, but it was quick and easy.
Comment 6 Václav Pavlín 2013-04-02 08:00:19 EDT
Phil, any news about the How-To? Can I close this bz?
Comment 7 Phil Anderson 2013-04-02 19:07:36 EDT
Feel free to close it if you want.  I manually changed grub_installer to effectively do what the How-To does and it worked fine.  I
Comment 8 Samantha N. Bueno 2015-10-23 09:59:01 EDT
*** Bug 1260540 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.