If you find that Grub appears to be working fine, but your problems begin when you attempt to load Linux itself. Try switching to verbose mode during boot by pressing the Esc key to see if any clues appear in the messages that scroll past (or if it hangs at a certain point).
Make a note of these and do a search online for them for more advice. If this doesn't happen, hold Shift at boot to bring up the Grub menu if necessary, then select 'Advanced options' followed by '(recovery mode)', which will launch Ubuntu in a minimal state, plus mount the file system in read-only mode.
If this is successful, after a succession of scrolling messages you should find yourself presented with the Recovery Menu, offering nine options. The options are all pretty much self-explanatory – the clean option may be of use if your hard drive is full, which can cause boot problems.
If your problems started because a package failed to install properly, then dpkg will repair it and hopefully get things working again. The failsafeX option is a useful if you find yourself booting to a black screen or the graphical desktop doesn't appear to be working correctly – it basically bypasses problems with your graphics drivers or X server to give you a failsafe graphics mode to troubleshoot your problem from.
We've touched on fsck already – this will check the drive for corrupt files, which can clear many errors, particularly if your PC crashed and has failed to boot since. The grub option isn't relevant unless you've used Grub's own recovery tools in place of the Boot-Repair tool to get this far in the boot process – selecting this will make your changes permanent.
Use the network option to re-enable networking, and the root option to drop to the shell prompt, allowing you to troubleshoot directly from there. If doing so, be sure to mount the file system in read/write mode using the following command:
mount -o remount,rw /
You can also pass temporary kernel parameters to Ubuntu during the boot process, which may help in some scenarios.
With your chosen operating system selected in Grub, press the e key to edit the kernel file. Scroll down to the line beginning linux – parameters are added to the end of this line after quiet splash . You'll need to make sure that you leave a space between each parameter. Once done, press Ctrl+X to boot with those parameters. Note that any parameters you add here are temporary –
in other words, they're removed the next time you boot, so you can experiment until you find a solution that works, then – if necessary – make it permanent by editing the Grub configuration file (sudo nano /etc/default/grub).
You can also pass parameters from the live CD environment using the Boot-Repair tool using the 'Add a kernel option', which includes 15 common parameters that can help with troubleshooting. Examples of these include acpi=off, which disables the ACPI system that's known to cause random reboots or system freezes on certain PCs, and nomodeset, which instructs Ubuntu to only load graphics drivers after the X environment has been loaded, and not before.
These temporary parameters can be passed to your rescue disc too, in case you're having problems getting that working. Press F6 at the initial boot screen to choose from the options on show. For more information on specific parameters, do an online search for the parameter.
There's one last thing you can try from the Grub boot menu – if your kernel has been upgraded, it's possible to boot using an older version of the kernel from the Advanced options screen under Grub. You'll see each version of the kernel listed – try the previous version if you believe your boot problem is linked to the latest kernel.
If this works, you can make the version you've used permanent by editing the Grub configuration file – the simplest way to do this is by using the Boot-Repair tool.
If things look particularly bleak, then you may have luck reinstalling Ubuntu over the top of itself. Boot from the Ubuntu Live CD and choose the option to 'Install Ubuntu' when prompted. When you get to the 'Installation type' screen you'll be presented with a new option, pre-selected by default: 'Reinstall Ubuntu…'
This option basically reinstalls Ubuntu without touching your home folder or partition, which means not only should your documents and other files be preserved, but key settings and many programs may be left alone too. It'll also leave entries in your boot menu alone, ensuring you won't lose access to other operating systems.
What will be replaced are system-wide files, which will hopefully root out any corrupt ones and get your PC up and running again. Although it doesn't affect your files, it's still good practice to back up the drive – or at least your home folder or partition – before you begin.
To ensure you don't lose anything from your system, make sure you recreate all user accounts with the same login and password, including – of course – your own during the install process.
Tweak Boot-Repair tool settings
1. Main options
The first tab offers a convenient button for backing up your current partition table, boot sector and log – click this to copy this key information. It's also where you can reinstall Grub, restore the MBR and choose whether to hide the Grub menu.
If you think your filesystem is corrupt, tick 'Repair file systems' to have it checked and fixed.
2. Grub location
This tab allows you to specify which OS to boot by default in a multiboot setup. You can also choose to place Grub in its own separate /boot partition if you wish – typically this is only needed on encrypted disks, drives with LVM set up or some older PCs.
The final option specifies which drive Grub itself will be placed (sda by default).
3. Grub options
This section opens with options for making sure Grub is updated to its latest version. There's also three specific error fixes offered. You can also add new kernel options to the Grub menu here, or purge all previous kernels before reinstalling the last one.
You may even see an option allowing you to edit the Grub configuration file directly.
4. Other tweaks
If the MBR options tab isn't greyed out, use it to restore your MBR from a backup and choose which partition gets booted from it. The final Other options tab offers an opportunity for repairing Windows files (irrelevant in most cases) and provides options for pasting a summary of your settings online for reference.
- Enjoyed this article? Expand your knowledge of Linux, get more from your code, and discover the latest open source developments inside Linux Format. Read our sampler today and take advantage of the offer inside.