This is an advanced tutorial.

It is expected that you already have quite a bit of experience with Linux, the command line, scripting, etc.

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.

  1. 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
  2. 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
  3. 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:

    $ 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
    Or we can do this much easier in one command with the help of a for loop:

    $ for i in /dev /dev/pts /proc /sys; do sudo mount -B $i /mnt$i; done
  4. Chroot into your environment

    $  sudo chroot /mnt
  5. Fix grub

    $ grub-install /dev/sda
    $ grub-install --recheck /dev/sda
    $ update-grub
  6. Now you can exit the chroot environment

    $ exit
  7. 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 : )

If you have any questions/comments please leave them below.

Thanks so much for reading ^‿^


If this tutorial helped you out please consider buying me a pizza slice!