update-grub sets root= non-deterministic device

Bug #738297 reported by David Balažic
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
grub2 (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Using wubi rev 197 I installed Ubuntu 10.10 from Windows XP.

Hard drives and partitions:
2 hard drives (one PATA 160GB, one SATA 500GB)
disk 0 (PATA): Primary partition C: , NTFS, over the entire disk
disk 1 (SATA): Primary partition E: , NTFS , 450 GB, the rest is unpartitioned

Windows XP installed on C:

Steps:
 - downloaded wubi 197
 - installed Ubuntu 10.10 on disk E:
 - reboot into Ubuntu
 - the installation is finished
 - another reboot into ubuntu
...

Then I did an update ( apt-get upgrade) and after that I got the "/host/ubuntu/disks/root.disk missing" message on each boot and dropping to shell.

It turns out the grub configuration changed from
set root='(hd1,msdos1)'
to
set root='(hd0,msdos1)'

and
linux /boot/vmlinuz-2.6.35-22-generic root=/dev/sdb1 ...
to
linux /boot/vmlinuz-2.6.35-22-generic root=/dev/sda1 ...

As the same error is printed for unclean NTFS (see bug 226622) and that Ubuntu leaves the NTFS partionion in unclean state after each shutdown (bug 733816), I first thought this is an issue with unclean FS...

Revision history for this message
David Balažic (xerces8) wrote :

After the mentioned update there were nmoreupdates detected by Update Manager.
I installed them and now the grub.cfg again has the correct hd1 entry and sdb1.

But it still does not boot each time.

The problem is, that there are 3 "scsi" devices: sda, sdb and sdc.
And the naming is not deterministic. I guess it depends on detection time.

Sometimes hd0 (as seen by BIOS, which is always stable) is named sda, sometimes sdb and even sdc.
Same with hd1 and the other (not hard drive) device.

This just brings back the old, known problem of "relying on a particular detection order of devices is ... not reliable".
There were many solutions proposed: UUID, devlabel, etc...

Please advise (if you check the amount of issues I reported just today, you'll guess I am on the edge of deleting Ubuntu from my PC. For good.)

affects: ubuntu → grub2 (Ubuntu)
Revision history for this message
David Balažic (xerces8) wrote : Re: hard disk device name ordering non-deterministic

I attach the dmesg output in a case where it did not boot.

As can be seen , the Maxtor 160GB drive got the name sdb and sda was assigned to the 500 GB WDC, which is the opposite of the working configuration.

The D:\ubuntu folder is on the WDC.

To remind, the grub settings are:
 set root='(hd1,msdos1)'
...
 linux /boot/vmlinuz-2.6.35-22-generic root=/dev/sdb1 ...

summary: - wubi: boot disk changed after update
+ hard disk device name ordering non-deterministic
Revision history for this message
Colin Watson (cjwatson) wrote : Re: [Bug 738297] Re: hard disk device name ordering non-deterministic

Regarding your change of bug title: hard disk device name ordering is
indeed non-deterministic, and that isn't a bug. The bug is in anything
that fails to cope with that.

Revision history for this message
David Balažic (xerces8) wrote : Re: hard disk device name ordering non-deterministic

Yes, of course. Feel free to change it to some better wording.

Revision history for this message
gweg (gweg) wrote :

I can see this problem, or something similar is present in natty grub 1.99~rc1-4ubuntu1
update-grub put:

     linux /vmlinuz-2.6.38-7-generic-pae root=/dev/md123 ro ...

as the entry in grub.cfg

It should never do this, because /dev/md123 is correct only at that time, and may very well be incorrect on the next boot. My fstab has:

LABEL=natty3_md / ext3 noatime,errors=remount-ro 0 1
LABEL=boot1t /boot auto noatime 0 0

fyi, if I change fstab LABEL=natty3_md to UUID=...., and re-run update-grub, the problem is still there.

In my example, my boot partition was non-raid, regular ext3 partition and the other partitions, except swap, are mdraid (raid1). In my mdadm.conf if have:

ARRAY /dev/md/amy:natty3 metadata=1.2 UUID=b1211dcb-67a1-4032-364a-12057c183e9a name=amy:natty3

To work-around this problem, I added the following line to /etc/default/grub:

GRUB_DEVICE="LABEL=natty3_md"

which created the correct root=LABEL=natty3_md in the grub.cfg

This worked for me, but I don't think it is a good solution for the average user. Really, update-grub should use root=LABEL= or root=UUID= in grub.cfg whenever possible, rather than /dev/md... or /dev/sd...

summary: - hard disk device name ordering non-deterministic
+ update-grub sets root= non-deterministic device
Revision history for this message
David Balažic (xerces8) wrote :

I changed the grub boot command line from
linux /boot/vmlinuz-2.6.35-22-generic root=/dev/sdb1 ...
to
linux /boot/vmlinuz-2.6.35-22-generic root=UUID=3343342

(got the UUID from the blkid command)

and now it works.
I did 3 tries and got a different /dev/sdX name for the ubuntu host partition, so I guess it works.

So the question is, why was it not set to UUID in the first place?

description: updated
Revision history for this message
David Balažic (xerces8) wrote :

I upgrade to ubuntu 11.04 and the grub.cfg (re)created in the process has root=UUID=...
so I guess this one is fixed.

Revision history for this message
gweg (gweg) wrote :

not seeing this problem any more. I suspect it is fixed by:
grub2 (1.99~rc1-6ubuntu1) natty; urgency=low

  * Resynchronise with Debian. Remaining changes:
...
    - Apply Ubuntu GRUB Legacy changes to legacy update-grub script: title,
      recovery mode, quiet option, tweak how memtest86+ is displayed, and
      use UUIDs where appropriate.
...
 -- Colin Watson <email address hidden> Fri, 25 Mar 2011 23:44:33 +0000

Changed in grub2 (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.