01 July 2020

Repairing grub in a dual boot system without using Boot Repair

After installing Windows, installing Ubuntu detects Windows and installs fine, giving you a dual boot system. But if you re-install Windows or install another OS on another partition, chances are you'll get a MokManager error that looks like this:


Before attempting to repair Grub2, go to your BIOS (as shown in this page) and select the grubx64.efi file or whichever efi file is relevant to your installation, and reboot. Chances are that the non-booting is just being caused because the computer does not know which efi file is safe. I think this happens due to secure boot being enabled, but please don't disable secure boot. Just specifying the correct efi file may help.

If it still isn't booting and you want to repair Grub2, follow the steps in this or this website. I had tried using Boot Repair, which worked nicely, but only once. So I now prefer doing it manually.

Steps:
1. Boot from a live CD or live USB which has the same Ubuntu version as your latest installed Ubuntu.
2. Use sudo fdisk -l and sudo blkid or GParted to determine which sda Ubuntu is installed on. Let's assume it's on sda4.
3. sudo mount /dev/sda4 /mnt
4. for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; done
5. If Ubuntu is on an efi partition (check using sudo fdisk -l | grep -i efi), mount it with sudo mount /dev/sda4 /mnt/boot/efi.
6. This command won't work if you are using a 32 bit live boot disk on a 64 bit computer, so make sure you use a 64 bit live boot disk: sudo chroot /mnt
7. update-grub (if this doesn't work, goto step 8. Else, step 10).
8. grub-install /dev/sda
9. update-grub. To locate and add Windows to grub menu.
10. If Ubuntu was installed in efi mode, run this: blkid | grep -i efi; grep -i efi /etc/fstab
11. Reboot the computer.

Even now, the "Failed to start MokManager" error may show up. Just go to BIOS and select the right efi file and reboot. Everything should work fine now.
 
Update: If the bootloaders are on separate disks, I've mentioned how to fix it here.



Say thank you or donate

No comments: