1

Grub has similar concept of modules like the Linux kernel. They are a bunch of precompiled files which usually live at boot/grub/x86_64-efi/<module_name>.mod on the rootfs.

The module needs to be loaded before it can be used. "used" means that you can you can run a particular new command in grub.cfg. A way you install a module is having a insmod <module_name>.

Is it possible to embed a grub module withing the grub binary instead of having the modules living on the rootfs?

1 Answer 1

0

When you install grub, you can indicate grub-install --modules=… and get some modules preloaded.

You can also use grub-probe … which gives you the modules needed to access a given directory.

5
  • Thanks, but I'm hoping to understand what does that turn into exactly. Will it just copy the .mod files to the EFI partition? Oct 8, 2021 at 15:16
  • This depends : on an old MBR system, there are is space after the boot sector and before the first partition (30ko). On an EFI boot, a grubx64.efi file is created. Oct 8, 2021 at 15:25
  • That's the boot-loader binarygrubx64.efi. I'm trying to understand if modules can also live within the bootloader binary or they always exist as a separate .mod file. Oct 8, 2021 at 15:34
  • The grubx64.efi is typically made by a low level command : grub-mkimage -p /boot/grub -O x86_64-efi -c grub-pre.cfg -o /tmp/grubx64.efi luks2 part_gpt cryptodisk gcry_rijndael pbkdf2 gcry_sha256 ext2 Then it embeds the partition table handling, filesystem and other things needed to load your favorite kernel. Oct 8, 2021 at 16:13
  • The modules are literally included within the grubx64.efi binary file. In case of Secure Boot, this is essential, as anything that loads program code without performing Secure Boot signature checks would be classifiable as a "Secure Boot circumvention device". The modules are ELF binaries, but when included, a single signature on the resulting .efi binary covers them all.
    – telcoM
    Oct 8, 2021 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.