Common GRUB issues
In this post I am going to compile several GRUB-related issues and how to solve them.
Table of Contents
GRUB command line
When installing or removing an operating system on a dual-boot system, you may see this window on boot (instead of the boot menu):
- GRUB has some issues to find the right EFI file, so you need to tell GRUB where is it. Type
ls
to see the partition list. You will see something like this:(proc) (hd0) (hd0,gpt3) (hd0,gpt2) (hd0,gpt1)
- EFI partition is usually the first disk partition (
/dev/sda1
) so we are going to runls
to list the contents of(hd0, gpt1)
.ls (hd0,gpt1)/
- If you see a
grub
orefi
folder, great! you are on the right partition. If not, try repeatingls
command with the other partitions. - Now we are going to change the
root
to our EFI partition.set root=(hd0,gpt1)
- Then, if you type
ls /
, GRUB will display the root folder of the EFI partition. Let’s find GRUB EFI file usingls
command.grub> ls / efi/ grub> ls /efi debian/ grub> ls/efi/debian shinmx64.efi grubx64.efi mmx64.efi ... grub.cfg
- You may see different output, look for the
grubx64.efi
file. that’s GRUB boot menu. Runchainloader
with the full path ofgrubx64.efi
.chainloader /efi/debian/grubx64.efi
- Finally, run
boot
. That’s it.
Note: you can access GRUB command line from the boot menu by pressing C. Then, press Esc to go back to boot menu.
Growing EFI partition
-
If you need to increase your EFI partition, first you need to use a Live system (mounted on a USB) to be able to resize disk partitions. You can use almost any Linux operating system that alows you to use it without install it on the hard drive. I am going to use Arch Linux as the Live system.
-
Once you have booted your Live system, copy EFI partition files to another disk partition. To do that, mount the EFI partition and the disk partition where you want to copy the files. To simplify the process, I recommend you to use your operating system main partition to place copied files. By doing this, you can mount your system partition on
/mnt
and EFI partition where is usually mounted on your system (e.g.:/boot
). -
Then, to mount the partition, use
lsblk -o name,parttypename
to locate EFI partition and the partition where you want to place copied files:
NAME PARTTYPENAME
sda
├─sda1 EFI System
├─sda2 Linux filesystem
├─sda3 Linux filesystem
- In this case,
/dev/sda3
is the main system partition. Now, mount the partitions (ensure you have root permissions, or usesudo
):
mount /dev/sda3 /mnt
mount /dev/sda1 /mnt/boot
- Run
rsync -a
to copy boot files to the other partition. Create a folder if needed. (remember to usesudo
if you are not theroot
user).
mkdir /mnt/home/user/efifiles
rsync -a /mnt/boot /mnt/home/user/efifiles
- Check files have been copied. Unmount the partitions (first unmount the EFI one).
umount /dev/sda1
umount /mnt/sda3
-
Grow EFI partition using
fdisk
, GParted or similar tool. If you have unused partitions between EFI and system partitions, you can simply delete those unused partitions (and EFI partition), and create a new partition that takes all unused space. If there is no unused partitions, you may need to shrink a system partition to create a new boot partition. Remember to set partition type toEFI System
(or something like that, check your partition tool) and format the partition asFAT32
. -
Once you have your new boot partition, mount the two partitions again (check their name with
lsblk
), runrsync -a
to copy EFI files to the new partition.
mount /dev/sda3 /mnt
mount /dev/sda1 /mnt/boot
rsync -a /mnt/home/user/efifiles/ /mnt/boot/
- Finally, we are going to reinstall GRUB on the new boot partition. Run
arch-chroot
(if you are using Arch Linux as the Live system) to set the root to your system main partition mount point.
arch-chroot /mnt
- Then, reinstall GRUB (check
--efi-directory
is right).
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
- And re-make
grub.cfg
file (check the file path on your system before running the command).
grub-mkconfig -o /boot/grub/grub.cfg
Edit your system’s /etc/fstab
file to ensure it has the right configuration (with the new EFI partition).
If you have any suggestion, feel free to contact me via social media or email.
Latest tutorials and articles:
Featured content: