Ubuntu Boot Repair

Objective

Fix an Ubuntu system that won’t boot properly.

Distributions

Ubuntu 18.04

Requirements

An Ubuntu install with root privileges, and preferably a second computer to create a live CD.

Difficulty

Easy

Conventions

  • # – requires given linux command to be executed with root privileges either directly as a root user or by use of sudo command
  • $ – given linux command to be executed as a regular non-privileged user

Introduction

No one wants a system that doesn’t boot. It’s about as bad and frustrating as any technical problem gets, and more often than not, it feels like the system is totally shot. Fear not, though, Ubuntu has a couple of convenient ways to help repair your computer and get things back to normal.

The Easy Way

Believe it or not, there is and easy way. There’s a utility that you can run from an Ubuntu live CD/USB that automatically repairs your system. You don’t have to worry about the specifics or even diagnose the problem. It automatically runs through with the click of a button. So, that’s probably a good first option.

Create Your Live CD/USB

If you don’t already have one, create a live medium to work off of. Head over to Ubuntu’s download page, and grab the latest desktop image. From there, you can either use a utility like Brasero to write it to a disk, or you can image it to a USB with dd. If you go with dd, find the location of your drive, and your command should look something like this:

$ sudo dd if="ubuntu-18.04-desktop-amd64.iso" of=/dev/sdX bs=8M

When you have your live medium, insert it in your non-booting computer and start it up. Select the medium through your motherboard’s boot options. When Ubuntu comes up, select the “Try Ubuntu” option.



Add The PPA

It might seem counter-intuitive, but you can enable a PPA and install software on a live CD. The utility that you need is available through a PPA, so this is the procedure that you’ll need to follow in order to use it. Start by enabling the PPA and updating Apt.

$ sudo add-apt-repository ppa:yannubuntu/boot-repair
$ sudo apt update

Confirm that you want to install the PPA when asked.

Install Boot-Repair

Now, you can install Boot-Repair like you normally would with Apt.

$ sudo apt install boot-repair

Run The Utility

Ubuntu Boot-Repair

Ubuntu Boot-Repair

Finally, you can run the utility. You can use the same terminal window that you’re working in to launch it directly.

$ boot-repair
Ubuntu Boot-Repair Report

Ubuntu Boot-Repair Report

A small window will open up with two buttons. The first one is an automatic repair that will go through your system and attempt to repair it. When you’re ready, click the button to run the repair. It’ll kick off on its own and do what it needs to. When it finishes, you’ll see a message telling you that the repair was (hopefully)successful. It will also generate a report detailing what it did.

You can now shut down Ubuntu and remove the live medium when you’re prompted to do so. Boot back up into your normal Ubuntu system to see if everything worked.

More Options

If you think you know what the problem is, you can always try the default Ubuntu way of fixing boot problems. Included with every Ubuntu install is a series of fail-safe options that allow you to more easily recover a non-booting system.

They let you take the reigns a bit more than the Boot-Repair utility, but they also allow you more options to mess up your system. If you’re going to go down this road, make sure you have a pretty good idea what you’re doing.



Booting Into Boot Recovery

Ubuntu Boot To Recovery

Ubuntu Boot To Recovery

When you start up your Ubuntu PC, hold down the Shift key. The GRUB menu will pop open. Select the “Advanced Options” entry. It’ll probably be the second one from the top. From there, you’ll see several different kernel options. Under each one will be an identical entry with (recovery mode) at the end. Select the recovery entry for the latest kernel.

Ubuntu Recovery Menu

Ubuntu Recovery Menu

The menu will change to display several recovery options, starting with resume, which will just boot the computer normally. The other options afford you a series of tools that let you manually repair the more common boot issues.

You can repair or reinstall GRUB to remedy and bootloader related issues. These would be any issues where the computer starts up fine, but as soon as it tries to start Ubuntu itself, it hangs or crashes. It might even present as a message saying that a kernel can’t be found.

The dpkg option allows you to try to reconfigure or remove broken packages that are preventing the system from booting properly. It automatically searches for upgrades, and tries to detect any possible ways to clean up your system.

Speaking of cleaning, the clean option is a great choice if you need free space or hard drive space is causing boot issues. This one can be kind of tricky, but can save you in a pinch.

fsck is the utility that you’re probably already familiar with. It’ll help you repair any hard drive issues or corruption that might be impacting your system.

Finally, when all else fails, you can drop into a root terminal and try to fix things yourself. Like any other time you log in as root, be careful. It’s very easy to make matters worse.

After you thin you have your system sorted out, you can try to boot normally with resume.

Closing Thoughts

With any luck, these tips helped you save your Ubuntu PC. Remember to be careful when running any kind of repair. There’s always the chance of things going wrong or unintended consequences.

Nothing is perfect, and sometimes an install is just broken. If you’re looking for a last resort measure to rescue your system, you can always try using a live CD and chrooting into your broken install. As always, there are no guarantees, but it will get you access to make backups and try some other methods for debugging and eventually fixing Ubuntu.