How To
Summary
This document shows information and usage of grub2 on x86_64 (Intel) UEFI firmware-based systems.
Environment
Steps
mount: unknown filesystem type 'vfat'
# grub2-mkconfig -o /boot/grub2/grub.cfg
/usr/bin/grub2-editenv: error: cannot rename the file /boot/grub2/grubenv.new to /boot/grub2/grubenv: No such file or directory.
Generating grub configuration file ...
/usr/bin/grub2-editenv: error: cannot rename the file /boot/grub2/grubenv.new to /boot/grub2/grubenv: No such file or directory.
# [ -d /sys/firmware/efi ] && echo UEFI || echo BIOS
UEFI
RPM packages necessary to help grub on UEFI
grub2-efi-x64-2.02-156.el8.x86_64
efibootmgr-16-1.el8.x86_64
shim-x64-15.8-2.el8_10.x86_64
Shim is also installed on BIOS systems.
Notice that the default grubenv actually redirects to the EFI one:
# ls -l /boot/grub2/grubenv
lrwxrwxrwx. 1 root root 25 Feb 21 2024 /boot/grub2/grubenv -> ../efi/EFI/redhat/grubenv
At this point I should mention the /boot/efi/EFI directory. You won't see this on a BIOS system, but it is essential for grub2 in the UEFI environment.
This is actually stored on a separate filesystem, in a partition on the boot drive. (In my example I'm on a KVM guest)
Model: Virtio Block Device (virtblk)
Disk /dev/vda: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
1 1049kB 630MB 629MB fat32 EFI System Partition boot, esp
2 630MB 1704MB 1074MB xfs
3 1704MB 21.5GB 19.8GB lvm
So here /dev/vda1 is the EFI partition. Note that it is formatted as fat32. We'll see later that this is important to remember.
Both the boot and EFI partitions are mounted in normal operation:
# grep efi /etc/fstab
UUID=031B-53EF /boot/efi vfat umask=0077,shortname=winnt 0 2
df output:
/dev/vda2 1038336 273724 764612 27% /boot
/dev/vda1 613184 5940 607244 1% /boot/efi
mount output:
/dev/vda2 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota)
/dev/vda1 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=winnt,errors=remount-ro)
In order to insure they are mounted, make sure the fat, vfat and msdos modules exist and are not blacklisted:
First, check if they exist for your current kernel:
# cd /lib/modules/$(uname -r)/kernel/fs/fat
# ls -l
total 56
-rw-r--r--. 1 root root 36260 Dec 6 12:15 fat.ko.xz
-rw-r--r--. 1 root root 6536 Dec 6 12:15 msdos.ko.xz
-rw-r--r--. 1 root root 8880 Dec 6 12:15 vfat.ko.xz
Now, make sure they are not blocked:
# cd /etc/modprobe.d
# grep -E "fat|msdos" *
#
OK, so no config file has them blocked out.
We can also check that they are loaded into memory:
# lsmod | grep fat
vfat 20480 1
fat 86016 1 vfat
If you need to recreate the grub menu, there is no special EFI option necessary. The links created in the system, along with the shim, will allow y ou to use regular grub commands, such as:
# grub2-mkconfig -o /boot/grub2/grub.cfg
Also, if you need to recreate the initrd and recreate the grub menu, this is a good all-in-one line to use:
# dracut --regenerate-all -f && grub2-mkconfig -o /boot/grub2/grub.cfg
Document Location
Worldwide
Was this topic helpful?
Document Information
Modified date:
07 January 2025
UID
ibm17180423