[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

Bug #1198846 reported by Taihsiang Ho on 2013-07-08
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OEM Priority Project
grub2 (Ubuntu)

Bug 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:
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.

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/initramfs.debug

find_livefs() {
    # or do the scan of block devices
    for sysblock in $(echo /sys/block/* | tr ' ' '\n' | egrep -v "/(loop|ram|fd)"); do
        devname=$(sys2dev "${sysblock}")
        [ -e "$devname" ] || continue
        fstype=$(get_fstype "${devname}")

wait for 5 seconds seems to make the kernel probe the usb correctly

The efi/boot/BOOTx64.efi of 12.04.2 and 13.04 are the same

Taihsiang Ho (taihsiangho) wrote :

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
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
   set prefix=($root)/boot/grub
   if [ -e $prefix/x86_64-efi/grub.cfg ]; then
        source $prefix/x86_64-efi/grub.cfg
        source $prefix/grub.cfg

3. investigate the search behavior,
it seems that grub iterates hd before cd always.


static int
grub_efidisk_iterate (int (*hook) (const char *name))
  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

Taihsiang Ho (taihsiangho) wrote :

is there any way to parse the bios information about "where the grub efi application is loaded" to grub instead of using the search command??

Tammy Yang (wanchingy) wrote :

Private bug which affects Ubuntu-recovery : bug #1185375

Phillip Susi (psusi) wrote :

This isn't really a bug. Given two identical install images on different media, the system can't figure out which one you intended to use. Instead of giving it both, just give it the one you intend to use.

Changed in grub2 (Ubuntu):
status: New → Won't Fix
Tammy Yang (wanchingy) wrote :

This actually affects users when there is a partition on hard driver with install image (for recovery use for example). If deleting this partition is not an option, user can never boot into CDROM.
I think it will be great if efi grub application can be able to know which partition/media it is on (maybe from BIOS information) and find the grub.cfg on the same partition to avoid doing search.

Phillip Susi (psusi) wrote :

From your initial description it sounded like you were talking about having the exact same image in both places. If that is the case, then there is no telling them apart, and which is used doesn't really matter. If you are talking about say, an old release on the recovery partition and a new release in the dvd, that would be something different.

Tammy Yang (wanchingy) wrote :


Sorry, the original description might be a little bit misleading. Yes, we were taling about "an old release on the recovery partition and a new release in the dvd". What we found is, user can never boot into the new release in the dvd.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers