Skip to main content

How to repair Ubuntu if it won't boot

Fix startup issues

How to boot repair Ubuntu

Start-up problems. That moment when – having expected yourself to be getting on with your day's work or entertainment – you find yourself staring at a cryptic error message, or even worse, a blank screen.

No matter how many times you press reset or restart, the same impenetrable barrier blocks your path. So, what can you do? Start-up problems come in all shapes and sizes, and they can be difficult to track down.

There are, however, some sound principles to use that will resolve many errors, and in this tutorial, we're going to look at the tools and techniques required to troubleshoot most start-up problems. You should start by examining how the boot process works.

This reveals that the boot process can be split into three broad stages centred around the Grub 2 boot loader: pre-Grub, Grub and post-Grub. Knowing this allows you to focus your troubleshooting efforts based on where in the process the error or freeze occurs.

How to boot repair Ubuntu

If you're struggling to get the Boot-Repair tool disc to boot, experiment with the various fail-safe boot options.

Let's start at the beginning. You switch on your PC. If power comes on, but nothing else happens, chances are you've a hardware issue to sort – if you recently poked around the innards of your PC, then check everything is connected correctly.

If not, unplug all external devices except your keyboard and try again. If this doesn't work, open the case carefully and disconnect your internal drives too. If the computer now boots to the splash screen, you can try reconnecting the internal drives and trying again; if you're now able to boot to the login screen, shut down your PC and start reconnecting your external peripherals to see if the problem has cleared itself or can be targeted to a single device, in which case try a different cable, or go online and Google for known boot problems involving that device.

If you're lucky, your motherboard will emit a series of beeps or flashing lights you can use – again by enlisting the help of the internet – to identify the likely problem. This may involve replacing a component or something more drastic.

If you're able to get as far as your PC's splash screen, but then your computer hangs or a 'missing operating system' error message appears, then first think back to any recent changes.

If you've overclocked your PC, eg, you should now enter the system EFI or BIOS and look for the option to load fail-safe defaults. Try rebooting again.

If this fails, then the problem is likely to be with your hard drive, and so the first places to look are the MBR and Grub. If Grub isn't set to automatically appear when your PC starts, try rebooting while holding the Shift key or tapping Esc to bring up the Grub boot menu to confirm it's not able to even load itself.

Jump to the Boot-Repair tool section once you've verified it's nowhere to be found.

If Grub is able to load, but can't find any bootable OS you'll find yourself with a number of scenarios: you may be presented with a basic command prompt such as grub> or grub rescue>, which indicates one or more files required by Grub are missing or corrupt.

You may get a specific error message or frozen splash screen, or you may just see Grub and nothing else, indicating it can't even find the most basic information required to proceed.

If you press C you may be able to enter the Grub Terminal mode to perform basic checks and repairs – you can attempt to manually initiate the boot by pressing Ctrl+X or F10, eg, or use the set command to review current settings and change basic settings such as the graphics mode.

If the Grub menu appears, then the issue may lie with its configuration file if things immediately grind to a halt after you select a menu option, but if Linux does start loading before grinding to a halt, the problem will lie with your operating system, in which case skip to the Post-Grub troubleshooting section.

How to boot repair Ubuntu

Give your hard drive the once-over when booting from your rescue disc to check it's working as it should

Boot-Repair tool

If you're struggling to fix Grub issues by hand, or there's no sign of Grub on your system at all, then you'll need to enlist the services of your rescue media and the Boot-Repair tool, which works with all Debian-based distros, including Ubuntu.

The Boot-Repair tool itself will launch automatically when you boot from a Boot-Repair tool disc, but if you're unable to create it, but have access to a Linux installation disc, use that in a live environment instead, then grab the Boot-Repair tool using the following commands:

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

$ sudo apt-get update

$ sudo apt-get install boot-repair

$ boot-repair

The Boot-Repair tool is focussed on those early boot problems caused by the hard drive's boot sector, MBR and Grub. It basically provides a convenient and user-friendly graphical front-end to the tools required to fix many problems.

The tool offers a 'Recommended repair' option that promises to fix most frequent problems, or you can click 'Advanced options' to see what it can do and manually select specific fixes without getting your hands dirty in the Terminal.

The step-by-step guide (see Tweak Boot-Repair tool Settings later in this guide) reveals what repairs and tweaks are possible, but note the tool is context-sensitive, and some options may be greyed out or missing depending on your setup.

The tool automatically generates a log of your system and that it attempts to do, which you can then share on the Ubuntu user forums if necessary. Before attempting any advanced tweaks on your own, it pays to try the recommended option first, then ask for help on the forums using the output logs generated – this will ensure you choose the right option and don't cause more damage.

The Boot process

When you press your system's power button, control is initially given to your PC's EFI or BIOS, which starts its various components, performs basic diagnostics tests and attempts to find a bootable device, which is typically the first hard drive.

Once located, the BIOS or EFI looks for the Master Boot Record (MBR) at the very beginning of the drive, which has a tiny program inside that loads the next stage of the boot loader, reading a file (eg e2fs_stage_1_5), which in turn is able to load the Grub boot loader.

A 'missing operating system' error at this point means you need your rescue disc for diagnostics as something is missing – either in Grub, the MBR or the drive itself. Once Grub loads successfully it reads a file called menu.lst, which contains the list of choices you see in the boot menu. Each entry basically identifies the drive, partition and file that contains the Linux kernel, plus RAM disk file used by the kernel as it boots.

The entry will also contain any additional parameters passed to the kernel. Control is now passed to the kernel, which attempts to mount the root file system. This is a key moment, and if it fails you may get a kernel panic, or things might grind to a halt. If successful, it'll create a single process to run the /sbin/upstart file (other distros use init) – if this goes wrong, you'll get a panic, it may halt again or drop you into a root shell.

At this point, upstart starts running scripts and upstart events to start other services and eventually bring you to the logon screen.