5

One of our old scripts looks in two separate places for the grub.conf file: one "default" and one for UEFI

if [ -f /boot/grub/grub.conf ] ; then     
    GRUB_CONF_FILE=/boot/grub/grub.conf
elif [ -f /boot/efi/EFI/redhat/grub.conf ] ; then
    GRUB_CONF_FILE=/boot/efi/EFI/redhat/grub.conf

The script is now being updated to support using grub2, but I'm not sure if/where I need to be looking for the /etc/default/grub and /boot/grub2/grub.cfg, and /etc/grub.d

I'm sorry if some of the wording is poor. I've never had the GREAT pleasure of playing around with this fun boot stuff before and a lot of this is pretty new to me

Tesomas
  • 53

1 Answers1

2

It depends on how you are installing grub. And of course, if you are installing it on the EFI System Partition (ESP), then it depends on where you are mounting that. In the particular case of your script, it looks as though perhaps it is expecting the ESP to be mounted on /boot/efi, and the /EFI/redhat directory is set up to contain what would ordinarily be in /boot on a BIOS based system. If this is correct, just take the location of grub2.conf on a BIOS system and replace the /boot prefix with /boot/efi/EFI/redhat, and you have your answer, namely /boot/efi/EFI/redhat/grub2/grub2.conf. (Note that /etc/default/grub will not move, because that is only used to generate the grub configuration and not used at boot time.)

There are at least two other common ways of setting up your ESP. One is to mount the ESP directly on /boot. The advantage is that you can then install things like grub and the kernel without worrying about the BIOS/UEFI distinction. The disadvantage is that you are now polluting the root directory of your ESP (which in theory is OS-independent) with all kinds of linux-specific files, like the kernel, whereas it would be tidier to stick all of those in one place like under /EFI/redhat.

The approach I favor (and this is just my opinion), is to mount your ESP on its own directory (/esp), and then bind-mount a subdirectory of your ESP onto /boot. So then you get the advantage of a tidy ESP and the advantage of existing tools finding what they want in /boot. The disadvantages are a slightly more complicated fstab and the fact that you cannot have symbolic links in /boot (a FAT file system). Here is a snippet of an /etc/fstab file on a machine with this setup:

/dev/sda2               /esp            vfat            rw,nosuid,nodev,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro       0 2
/esp/EFI/redhat         /boot           none            rw,nosuid,nodev,bind    0 0
user3188445
  • 5,257
  • That's a pretty nice approach. I like it very well. But do you also use one of those grub efi partitions? – mikeserv Jul 22 '15 at 21:22
  • 1
    I actually use gummiboot rather than grub on my EFI machines. But I'd be shocked if grub cannot be run directly from the EFI partition, in which case you don't need a BIOS boot partition. Just use efibootmgr to specify the path to grub on your ESP. But I admit I have only tested this with gummiboot, syslinux.efi, and the raw linux kernel (with built-in EFISTUB), never with grub. – user3188445 Jul 22 '15 at 21:40
  • I just looked at your profile, some [89]0% of your total upvotes are mine - including your first. You're going places. – mikeserv Jul 22 '15 at 21:42
  • You might wanna work on a catchier nick though. For my part, I think 3188445serv has a nive ring to it, but that's merely a suggestion. – mikeserv Jul 22 '15 at 21:50