Comment 1 for bug 1198846

Revision history for this message
Taihsiang Ho (tai271828) 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
   fi
   set prefix=($root)/boot/grub
   if [ -e $prefix/x86_64-efi/grub.cfg ]; then
        source $prefix/x86_64-efi/grub.cfg
   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
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