[efi boot to unexpected media] plug in live usb and DVD at the same time, try to boot from DVD but it comes to usb
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OEM Priority Project |
New
|
Undecided
|
Unassigned | ||
Precise |
New
|
Undecided
|
Unassigned | ||
grub2 (Ubuntu) |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
Description:
efi boot application of live media (e.g. usb and DVD) will boot to unexpected media or partitions with (device)/.disk/info
Here shows one of the way to reproduce this bug by live usb and live DVD plug in the same laptop together
System configuration:
OS: ubuntu 12.04.2
Kernel: 3.8.0-19-generic #29
Bios and Hardware info:
I tested this bug on different machine and make sure it is directly related to grub2
Prepare a machine with uefi bootable is enough
Steps to reproduce this bug:
1. prepare live usb and live DVD with image ubuntu 12.04.2 64bit [1]
2. make show there is no more something like live media or recovery partitions of hard disks on your laptop. More precisely, make sure there is no such file and directory (some devices)/.disk/info except those media prepared in step 1.
3. make sure the bios of the laptop we are going to use has set the uefi enable
4. plug in the live usb and DVD together on the same laptop
5. power on the laptop
6. open the uefi boot menu entry - it may be hot key F9 (for HP) or something like DEL, depending on your laptop bios support
7. select the boot efi application of efi/bootx64.efi under DVD manually
8. wait at least 5 seconds, and select "Try Ubuntu without installing" at the grub prompt menu [2]
9. when booting to desktop, open the terminal (for example by "ctrl + alt + t") and use the command "df"
Expected result:
/dev/sr0 (or any of your DVD rom device number with the live DVD) mounted on /cdrom
Actual result:
/dev/sdb1 (or any of your USB device number with the live usb) mounted on /cdrom
Additional information:
[1]
in fact, both of ubuntu 12.04.2 64bit and 13.04 64bit could reproduce this bug as well.
You can make a live usb or dvd with one of the images.
That is, there are 4 kinds of usb-dvd combinations could reproduce this bug.
[2]
If this bug could not be reproduced, it may be blocked by another issue:
Casper missing to access usb at the scanning the /sys/block
Please make sure you were not blocked by this issue by
1. at the grub prompt menu entry, press "e" on the entry "Try Ubuntu without installing"
2. append "debug" at the end of this statement "linux /casper/vmlinuz.efi ...... splash --"
3. press F10 to boot from this modified grub boot entry
4. after booting to desktop, open the terminal (for example by "ctrl + alt + t")
5. check whether /dev/sdb1(or any of your live usb device number) was raised by the following casper script in /dev/.initramfs
script/casper:
find_livefs() {
......
# or do the scan of block devices
for sysblock in $(echo /sys/block/* | tr ' ' '\n' | egrep -v "/(loop|ram|fd)"); do
[ -e "$devname" ] || continue
......
}
wait for 5 seconds seems to make the kernel probe the usb correctly
[3]
The efi/boot/
I think this behavior is raised by the grub search command in memdisk:
1. in the reproducing step 8, press e and then press F2 to make ourselves to be dropped into the grub shell ($root) /boot/grub x86_64- efi/grub. cfg ]; then x86_64- efi/grub. cfg
2. cat (memdisk)/grub.cfg, shows
grub shell> cat (memdisk)/grub.cfg
if ! search --file --set=root /.disk/info: then
search --file --set=root /.disk/minu-info
fi
set prefix=
if [ -e $prefix/
source $prefix/
else
source $prefix/grub.cfg
fi
3. investigate the search behavior,
it seems that grub iterates hd before cd always.
grub-core/ disk/efi/ efidisk. c
static int iterate (int (*hook) (const char *name))
grub_efidisk_
{
struct grub_efidisk_data *d;
char buf[16];
int count;
for (d = fd_devices, count = 0; d; d = d->next, count++)
{
grub_snprintf (buf, sizeof (buf), "fd%d", count);
grub_dprintf ("efidisk", "iterating %s\n", buf);
if (hook (buf))
>.......return 1;
}
for (d = hd_devices, count = 0; d; d = d->next, count++)
{
grub_snprintf (buf, sizeof (buf), "hd%d", count);
grub_dprintf ("efidisk", "iterating %s\n", buf);
if (hook (buf))
>.......return 1;
}
for (d = cd_devices, count = 0; d; d = d->next, count++)
{
grub_snprintf (buf, sizeof (buf), "cd%d", count);
grub_dprintf ("efidisk", "iterating %s\n", buf);
if (hook (buf))
>.......return 1;
}
return 0;
}
4. usb will be regarded as hd device, so the search command always set the variable root as usb (more precisely, any other hard disk devices with .disk/info) instead of our selection, DVD