Skip to content

Instantly share code, notes, and snippets.

@pbatard
Last active April 6, 2023 00:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbatard/0deddbd71eefc35a3ed0b08e12a9e7e3 to your computer and use it in GitHub Desktop.
Save pbatard/0deddbd71eefc35a3ed0b08e12a9e7e3 to your computer and use it in GitHub Desktop.

How to test EFI File System Transposition for GRUB

  1. Apply the EFI File System Transposition patches to your git repository.
  2. Download supergrub2-2.06s1-beta2-multiarch-CD.iso from here (Courtesy of https://sourceforge.net/projects/supergrub2/). We use Super GRUB2 Disk so that we don't have to create our own GRUB config and also because its ISO was created using grub-mkrescue from 2.06 and exhibits the issues we are trying to address.
  3. We'll need to issue make install so that grub-mkrescue can collect the necessary files from the "system" for the ISOHybrid creation, so make sure to create a custom target install directory (e.g. ~/grub-install) so that your build will use this rather than the system defaults.
  4. Create a iso/boot/grub/ directory tree somewhere in your workspace (e.g. ~/iso/boot/grub/) .
  5. From the ISO, under boot/grub/, extract grub.cfg, loopback.cfg, unifont.pf2 and the sgd/ directory into your iso/boot/grub/ directory.
  6. Configure GRUB while making sure to set the prefix to your custom target install directory (e.g. ./configure --disable-nls --with-platform=efi --target=amd64-pe --prefix ~/grub-install).
  7. Run make install.
  8. Build the ISO with something like: ~/grub-install/bin/grub-mkrescue --verbose -o ~/grub.iso ~/iso.
    You should obtain an ISO that contains among other things a .disk/<....>.uuid, a System/ directory, a efi/boot/ directory, the content of your source iso directory and a efi.img.
  9. Now partition a USB flash drive (preferably to GPT) and create a single FAT32 partition there (Bonus: If your UEFI system supports NTFS, as should be the case for most recent ASUS, Gigabyte or Intel x86_64 based systems, you should also be able to try with NTFS). Use any label you want for the partition or leave it blank/default since file system transposition should not be tied to a volume having a specific label or GUID/UUID.
  10. Extract the whole content of the ISO as is onto the newly created partition. Make sur to also copy the .disk/ subdirectory during that process.
  11. Boot the USB media on a UEFI system. You should get to the Super GRUB2 Disk GRUB menu.

Additional Notes

Without the patches (and this is something you can validate by carrying steps 8-10 with the original supergrub2-2.06s1-beta2-multiarch-CD.iso which uses current GRUB-2.06 grub-mkrescue to generate the ISO) you would get the 3 following failure points, which is what each individual patch addresses:

  1. Because xorriso requires shoving the GRUB EFI bootloaders into a efi.img, if you extract the content 'as is' onto a FAT32 partition, you will be missing the /efi/boot/boot....efi bootloaders and therefore a UEFI system will declare your media as unbootable.
  2. Even if you were to extract the GRUB EFI bootloaders from efi.img and place them at their expected location, because the GRUB fat module is not included by default, GRUB would be unable to access any content on the FAT32 partition altogether, including its configuration files.
  3. Even if you were to add fat support to the GRUB EFI bootloader, GRUB would still be unable to locate the boot media, as it is currently set to search it by disk UUID (search --fs-uuid ...) and a disk UUID will of course never be preserved during File System Transposition (hence our change to search --file ...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment