1

I'm trying to use Grub2 as the boot manager on an EFI system in standalone mode. (The only persistent harddisk has OS X on it; Linux and Windows drives may or may not be present at times, hence the standalone mode.)

I'm using SuperGrub2Disk, which is one EFI executable, and as I understand it Grub2's executable in this mode has an embedded disk image that it mounts for its root partition, with a copy of its own config file inside.

I'd like to override or amend this config file with an external grub.cfg. I've tried placing it next to the grub EFI executable or in the root of the ESP partition, but it's not being recognized. I've also tried to load it from a grub command line by the following command:

configfile (hd3,gpt1)/grub.cfg

This seems to have no effect other than clearing the screen - even though the config file is there as confirmed by ls.

Could anyone tell me if there's a way to use an external config file with an EFI standalone blob?

3

GRUB 2 binaries include hard-coded references to their configuration files. I haven't really been keeping track of all the gory details, but as I understand it, there are two EFI GRUB 2 binaries for Ubuntu on AMD64/x86-64 systems:

  • grub2-efi-amd64 -- This is the version of GRUB 2 that's used on computers that do not use Secure Boot. As I understand it, the binary itself is linked on your computer from pre-compiled components included in the package. The resulting binary refers to a grub.cfg file on your Linux installation's /boot/grub directory. Thus, you can't use the grubx64.efi binary installed from this package on one computer on another one, because the binary is customized for the computer on which it was created.
  • grub2-efi-amd64-signed -- This version of GRUB 2 is compiled and linked on a Canonical system so that it can be signed with a Secure Boot key. One side effect of the requirement that the binary be signed is that it cannot be customized for your system, and as a result, this version of grubx64.efi looks in the same directory as the binary for grub.cfg. On an Ubuntu system, this grub.cfg file searches for /boot/grub/grub.cfg, but in principle it could be customized to do something else.

Thus, in your case you can't use the unsigned GRUB 2 binary; if you want to use a stock Ubuntu GRUB 2 binary, you must use the signed one. Alternatively, you could build your own binary, as described here, among other places.

In your case, though, I don't think GRUB 2 is really optimal. Both rEFIt (which is now abandoned) and my fork of it, rEFInd, feature dynamic scanning for available boot loaders. Thus, if you install rEFIt or rEFInd to your internal disk's EFI System Partition (ESP) and put the boot loaders for your OSes on their respective removable media, rEFIt/rEFInd will provide you with options to boot those OSes if and only if the appropriate disk is plugged in. This behavior, however, will depend on proper management of your boot loaders, placing each one on the ESP of its respective disk; if your boot loaders are all stored on your internal disk's ESP, rEFIt/rEFInd will show non-functional OS options at all times, just like GRUB 2 would. In either case, using rEFIt or rEFInd will obviate the need to delve into the morass of manual GRUB 2 configuration.

  • Hey Rod,I am familiar with Refind - I use it to boot Grub2 while I'm still looking to get the latter to work properly. I need Grub's internal command line functionality to execute setpci before booting the OS; this is required to get my thunderbolt GPU working. Without a grub.cfg I need to enter the commands by hand, and as far as I know no other EFI boot managers have this. (Technically I could use an EFI shell mm command instead of setpci, but on the Mac I'm limited to a 1.x version of the shell and mm on that platform doesn't seem to support addressing PCI registers like it does in 2.x) – martona Jul 4 '15 at 10:16
  • Is GRUB required only for Linux? If so, you could boot rEFIt/rEFInd to GRUB to Linux. If you omit rEFInd's EFI filesystem drivers, you won't see the direct-kernel boot options in rEFInd's menu and it should all work pretty smoothly, giving you the best of both worlds, as it were. – Rod Smith Jul 4 '15 at 15:22
  • The short answer to the original question is that I can put a grub.cfg into /boot/grub, /grub, /boot/grub2 or /grub2 on any partition and SuperGrub2Disk will find them there - but only in these locations. Building (or at least grub-mkimage-ing) my own grub.efi with the -p "" option will produce a binary that will load a config file from next to the image itself. – martona Jul 7 '15 at 9:56
1

I would expect that a grub.cfg placed in the same directory is read and executed by a GRUB UEFI image with both of them usually being stored on the ESP, but I don't know that much about Mac setups. (On another note the embedded configuration has very limited functionality.)

May be creating the GRUB image yourself without an embedded configuration brings you one step further to a solution, these posts might help:

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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