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

Bug #1188364 reported by Craig G
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
grub2 (Ubuntu)
Confirmed
Undecided
Unassigned

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.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in grub2 (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.