Comment 1 for bug 496435

Revision history for this message
bwallum (rbw2) wrote :

I can confirm this bug. The problem appears to be that Grub2 will include the line
set root=(hdX,Y)
when installing grub on the external hard drive. In my case I had 3 internal drives on the machine that I used to configure the external drive. So the line root=(hd3,1) was included which works fine if the machine plugged into identifies the external drive as (hd3,1) but not if the machine has, say, two internal drives so identifies the external drive as (hd2,1).

This is a major regression from Grub 0.97 where it was possible to specify by UUID to avoid such problems. Using the command set root=UUID=uuid_string_of_numbers dosn't appear to work in Grub2. This is my original menuentry in /boot/grub/grub.cfg:-

menuentry "Ubuntu, Linux 2.6.31-17-generic" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
 set quiet=1
 insmod ext2
 set root=(hd3,1)
 search --no-floppy --fs-uuid --set fd0c6442-dc3d-49ba-8e46-91657460fe52
 linux /boot/vmlinuz-2.6.31-17-generic root=UUID=fd0c6442-dc3d-49ba-8e46-91657460fe52 ro
 initrd /boot/initrd.img-2.6.31-17-generic

I have tried a custom entry by creating a file (07_UbuntuUSB) in etc/grub.d and running as follows:

menuentry "UbuntuUSB, Linux 2.6.31-17-generic" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
 set quiet=1
 insmod ext4
 set root=UUID=fd0c6442-dc3d-49ba-8e46-91657460fe52
 search --no-floppy --fs-uuid --set fd0c6442-dc3d-49ba-8e46-91657460fe52
 linux /boot/vmlinuz-2.6.31-17-generic root=UUID=fd0c6442-dc3d-49ba-8e46-91657460fe52 ro
 initrd /boot/initrd.img-2.6.31-17-generic
}

It shows in the grub boot menu ok then fails because it it cannot find a file (but doesn't report which file it cannot find - another enhancement request please). The UUID refers to the boot partition on the external drive which contains the grub files and the os.