[Bug 1188364] [NEW] grub-install will install a misconfigured EFI image on removable media when /boot is also on the removable media

Craig G cgallek at gmail.com
Thu Jun 6 19:44:11 UTC 2013


Public bug reported:

With vanilla grub, grub-install with the --removable flag will install
in the grubx64.efi file in the EFI/BOOT directory of an efi partition.
If the --boot-directory flag is used, grub-install will also generate a
configuration file in EFI/BOOT which will try to source the grub.cfg
file from the supplied boot directory.  For example, in my case, the
following grub.cfg file is generated:

search.fs_uuid e83c44ec-cedd-11e2-874f-4c72b927200b root hd1,msdos1  
set prefix=($root)/grub
configfile $prefix/grub.cfg

Here, the UUID is the boot partition of my system and that the prefix
used is relative to the supplied boot directory and does not contain the
string 'boot'.

The standard grubx64.efi generated by grub-mkimage (specifically, not
using the -c option to include a configuration file) uses a heuristic to
try to find a configuration file.  The first step of this heuristic is
to look in the local directory.  Using a vanilla grubx64.efi built with
grub-mkimage, grub-install correctly installs the efi boot loader, the
above configuration file, and the system boots by sourcing the real
grub.cfg file on the referenced boot partition.

In this change:
http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/raring/grub2/raring/revision/154
A script was added to the ubuntu packaging of grub which builds custom versions of the grub efi boot loader image.  Specifically, the 'gcd' version of the loader built with grub-mkimage on line 62 is built with a default configuration in it labeled "Skeleton configuration file which finds the real boot disk."  This configuration unconditionally sets the prefix to ($root)/boot/grub and makes the assumption that the grub directory will be in a directory called boot on the root partition rather than on a dedicated partition.  Further, it assumes that the root partition will contain an info or a mini-info file.  This breaks the chain loading described above by removing the part of the configuration search heuristic that looks in the local directory.

I don't completely understand why the grub-install script uses the gcd
loader in the removable case (http://bazaar.launchpad.net/~ubuntu-
branches/ubuntu/raring/grub2/raring/view/head:/util/grub-
install.in#L837).  I also don't completely understand why the ubuntu
customization of the gcd loader needs to include a default configuration
(the same configuration could have been used by placing the file in the
install directory, just like grub-install does for its customizations).
The assumption of directory structure is certainly wrong in the ubuntu
customization at least for the general case, but I'm not sure if the fix
for my situation is to fix the gcd file that gets generated, or to
change grub-install to use the non-customized version of the efi loader.

** Affects: grub2 (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to grub2 in Ubuntu.
https://bugs.launchpad.net/bugs/1188364

Title:
  grub-install will install a misconfigured EFI image on removable media
  when /boot is also on the removable media

Status in “grub2” package in Ubuntu:
  New

Bug description:
  With vanilla grub, grub-install with the --removable flag will install
  in the grubx64.efi file in the EFI/BOOT directory of an efi partition.
  If the --boot-directory flag is used, grub-install will also generate
  a configuration file in EFI/BOOT which will try to source the grub.cfg
  file from the supplied boot directory.  For example, in my case, the
  following grub.cfg file is generated:

  search.fs_uuid e83c44ec-cedd-11e2-874f-4c72b927200b root hd1,msdos1  
  set prefix=($root)/grub
  configfile $prefix/grub.cfg

  Here, the UUID is the boot partition of my system and that the prefix
  used is relative to the supplied boot directory and does not contain
  the string 'boot'.

  The standard grubx64.efi generated by grub-mkimage (specifically, not
  using the -c option to include a configuration file) uses a heuristic
  to try to find a configuration file.  The first step of this heuristic
  is to look in the local directory.  Using a vanilla grubx64.efi built
  with grub-mkimage, grub-install correctly installs the efi boot
  loader, the above configuration file, and the system boots by sourcing
  the real grub.cfg file on the referenced boot partition.

  In this change:
  http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/raring/grub2/raring/revision/154
  A script was added to the ubuntu packaging of grub which builds custom versions of the grub efi boot loader image.  Specifically, the 'gcd' version of the loader built with grub-mkimage on line 62 is built with a default configuration in it labeled "Skeleton configuration file which finds the real boot disk."  This configuration unconditionally sets the prefix to ($root)/boot/grub and makes the assumption that the grub directory will be in a directory called boot on the root partition rather than on a dedicated partition.  Further, it assumes that the root partition will contain an info or a mini-info file.  This breaks the chain loading described above by removing the part of the configuration search heuristic that looks in the local directory.

  I don't completely understand why the grub-install script uses the gcd
  loader in the removable case (http://bazaar.launchpad.net/~ubuntu-
  branches/ubuntu/raring/grub2/raring/view/head:/util/grub-
  install.in#L837).  I also don't completely understand why the ubuntu
  customization of the gcd loader needs to include a default
  configuration (the same configuration could have been used by placing
  the file in the install directory, just like grub-install does for its
  customizations).  The assumption of directory structure is certainly
  wrong in the ubuntu customization at least for the general case, but
  I'm not sure if the fix for my situation is to fix the gcd file that
  gets generated, or to change grub-install to use the non-customized
  version of the efi loader.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1188364/+subscriptions




More information about the foundations-bugs mailing list