While GRUB usually works just fine, there can be cases where everything doesn’t work as expected and you might just find yourself in a situation where you can’t get GRUB to load, especially if you have more than one OS installed. These instructions have helped me fix most that problem in most cases.
Capital letters in commands in the following instructions are variables which you should replace with appropriate values for your setup.
Boot into a live environment
Mount your root partition into
/mnt
:sudo mount /dev/sdXY /mnt
where X is the number of the disk and Y is the lowercase letter of the partition.You can use
lsblk
,sudo fdisk -l
or GParted to view what partitions are available. Your root partition is generally the largest partition (probably over 10GB) and inext4
format.If your disk is encrypted, you can use the
cryptsetup
command to decrypt it:sudo cryptsetup luksOpen /dev/sdXY sdXY--crypt
. After decrypting, the decrypted data is available at/dev/mapper/sdXY--crypt
.If the encrypted partition is using LVM, the LVM partitions will be available under
/dev/mapper
with the partition names provided during setup. On Ubuntu, the main partition should be something likeubuntu-FLAVOR--vg_root
Check if there are any files in
/mnt/boot
. If you can find files with names containinginitrd
orvmlinuz
, you can skip the next step since you most likely don’t have a separate boot partition.Mount your boot partition into
/mnt/boot
:sudo mount /dev/sdXY /mnt
. X (the disk number) is probably the same as in step 2, but Y (the partition letter) will not be the same. The boot partition is usually inext2
format.If you have an EFI partition, mount it into
/mnt/boot/efi
:sudo mount /dev/sdXY /mnt/boot/efi
.To determine if you have an EFI partition, simply use
sudo fdisk -l | grep -i efi
. If you have an EFI partition, the first column in the output will be the full path to the EFI partition (i.e. what you replace/dev/sdXY
in the command with)Mount the special Linux directories to
mnt
:for i in proc sys dev dev/pts run do sudo mount -o bind /$i /mnt/$i done
You may replace newlines with semicolons (
;
) to write the script in one line:for i in proc sys dev dev/pts run; do sudo mount -o bind /$i /mnt/$i; done
chroot
into/mnt
:sudo chroot /mnt
Finally fix the GRUB installation:
sudo grub-install /dev/sdX
whereX
is the same asX
in step 4 or step 2.