GRUB/Troubleshooting

This article documents issues that might arise when trying to use or install GRUB2.

Installing GRUB2 from within a chroot
When a separate partition exists, be sure to mount the target root partition before chrooting, but do not mount the  partition until after chrooting to the new environment. This is required because will not detect  as a separate partition and will assume the  directory and the root  directory are on the same partition.

Reinstalling the GRUB2 EFI boot manager entry
In case the boot manager entries need to be restored, they can be re-added without invoking. Load the  kernel module and install :

Next add a boot menu entry:

grub-install: error: cannot find EFI directory.
Properly setting the GRUB_PLATFORMS variable in (the first time!) as listed above should resolve this error. Set the GRUB_PLATFORMS variable then re-emerge GRUB2 using the following command:

In the case this error persists try forcing the install to the EFI directory by issuing the command with correct parameters for the   and   options:

grub-install: Attempting to install GRUB2 to a disk or partition
There could be many reasons for this error to come up.

No mounted /boot
A partition is not mounted.

No BIOS boot partition while using BIOS-GPT setup
This could mean there is not a  or   partition to embed the  file in.

Creating a little partition of a few hundreds kilobytes may be enough, although it is good practice to align this partition to 2048 sectors to avoid a performance penalty with the disk. A 1 MiB partition should work well.

Attempting to install GRUB2 in a partition
When attempting to install GRUB2 in a partition e.g. (for instance because the boot loader will be chainloaded by a different boot loader), simply add   option switch to force install.

Missing target detection
If does not print any errors message or if the error message is about scanning disk files and several platforms are enabled in  while nothing is installed on the disk, then edit the  script with a text editor of choice.

Change the platform variable to the appropriate platform for the current use case. The platform must be rightly set when emerging, else it will be incorrectly configured in the script.

For example, to set the platform for "PC", change  to.

grub-setup: no post-MBR gap
This error means that GRUB2 could not find the usual gap between the MBR and first partition of a disk. It is possible that the gap does not exist. Some tools (e.g. LiveUSB disk installer) format disks so that the first partition starts at sector 1 instead of 2048.

Repartitioning might be necessary to resolve the issue.

grub-install: embedding area is unusually small
There is not enough room at the beginning of the disk before the first partition.

In general this is a bit of trouble to fix. One or more partitions need to be resized in order to leave some free space at the beginning of the drive. The GParted LiveCD or (Gentoo-based) SystemRescueCD are excellent tools to make this job less difficult.

If the swap partition is the first partition on the disk (e.g. ) it is possible to simply remove the existing swap space partition and re-partition the space. This resolution would avoid the need for booting into a live medium in order to resize a root partition.