Repair GRUB2-efi boot
This is an advanced tutorial which means it is expected that you already have some familiarity with Linux and the command line.
I ran into a weird problem with Ubuntu 18.04 on one of my computers recently. I was performing a regular software update via the Software Updater GUI when the install got stuck at “Installing for x86_64-efi partition”. I left the computer for a couple of hours but the install never moved beyond this point, so I had to find the updater process and kill it.
I had a feeling that things weren’t going to behave nicely after a reboot since I had interrupted an update in the middle of a GRUB install.
Sure enough, after I restarted the computer I was met with a GRUB Rescue prompt and the message “No device found.”
Time to manualy fix GRUB.
The first step is to get yourself a UEFI Ubuntu 18.04 boot USB. You can follow the instructions on how to create one here. Since your computer is dead in the water you’re going to need to find yourself another computer to use to make the USB. Boot to it when finished.
Now for the fun part.
Open a terminal and mount the root partition (/) of the device containing your OS. If you only have one hard drive in your computer it is likely to be /dev/sda.
$ sudo mount /dev/sda2 /mnt
You can verify that this device contains your root partition (/) by doing an “ls” on the directory you mounted
$ ls /mnt bin boot dev etc home initrd.img lib lib64 lost+found media mnt opt proc root run sbin snap srv sys tmp usr var vmlinuz
Mount the /dev/sda1 partition as that is likely your efi partition and do an “ls” to check
$ sudo mount /dev/sda1 /mnt/boot/efi $ ls /mnt/boot/efi EFI
Mount the rest of the directories that GRUB needs to use to check for other operating systems, etc.
We can do this one at a time with multiple commands like this:Or we can do this much easier in one command with the help of a for loop:
$ sudo mount -B /dev /mnt/dev $ sudo mount -B /dev/pts /mnt/dev/pts $ sudo mount -B /proc /mnt/proc $ sudo mount -B /sys /mnt/sys
$ for i in /dev /dev/pts /proc /sys; do sudo mount -B $i /mnt$i; done
Chroot into your environment
$ sudo chroot /mnt
$ grub-install /dev/sda $ grub-install --recheck /dev/sda $ update-grub
Now you can exit the chroot environment
Turn off the computer and remove the USB stick. Then turn your computer back on. If all went according to plan your computer should boot normally into Ubuntu 18.04.
After the computer starts, open a terminal and update all packages:
$ sudo apt update && sudo apt upgrade -y
If you receive an error about dpkg being interrupted you will need to run an automatic configure to fix it.
$ sudo dpkg --configure -a
If dpkg finishes without errors your system should be back to a fully functional state : )
Until Later ^‿^