Maxim_Kazmin - Fotolia

Tip

Use GRUB to fix Linux boot problems

GRUB is a handy tool to help admins solve any Linux booting issues. Reinstalling or manually implementing GRUB are two main approaches to getting your system back up and running.

Editor's note: This article is part of a series on Linux boot problems. Read the following articles to recover Linux with Knoppix or troubleshoot Linux boot problems.

GRUB is a necessary component to start Linux, but you may run into an issue that prevents a proper bootup sequence. There are two main ways to fix Linux boot problems: reinstalling GRUB or manually reinstating the program on the command line.

Symptoms for GRUB issues include: You will see nothing but a blinking cursor when your server boots, GRUB generates a generic GRUB error message or GRUB indicates that it cannot find a file it needs.

GRUB reinstallation to fix Linux boot issues

If you have a serious problem with the master boot record (MBR) on your computer, it can happen that you only see a blinking cursor when your computer boots.

If there are issues with the MBR, you likely don't have GRUB and won't see a GRUB error message. In this situation it is impossible to boot your computer, so you need a rescue CD to start it. You can use Knoppix to boot your computer.

To fix Linux boot snags, make sure that everything on your hard disk is mounted, enter a chroot setup and next use the grub-install command to install GRUB again.

If you decide to install GRUB in the MBR and the hard disk is addressed by the device file /dev/sda, you would use the command grub-install /dev/sda.

This command reads the GRUB configuration file – /boot/grub/menu.lst on most distributions -- and writes the new GRUB bootloader to the MBR.

Here is what you see when you use grub-install to reinstall GRUB:

root@Knoppix:/# grub-install /dev/sda You shouldn't call/sbin/grub-install. Please call /usr/sbin/grub-install instead!
Searching for GRUB installation directory ... found: /boot/grub Installation finished. No error reported. This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect, fix it and re-run the script 'grub-install'. (hd0) /dev/sda

GRUB manual booting steps

You don't always need to reinstall GRUB to fix Linux boot issues. If the GRUB code still exists but is unable to boot anymore due to an issue in the GRUB configuration file, you can try to reboot manually.

If GRUB gives an error message and stops, manual booting is the best approach. Doing so lets you discover the root of the problem and what information you need to fix the issue.

To access the GRUB boot menu, watch what your computer does when it boots. In most cases, it shows you must press the Esc key the moment GRUB is processed. This brings you to the GRUB command line.

You can also boot from a rescue CD and enter the command grub to open the GRUB command-line interface.

Fix Linux boot issues with GRUB
From the GRUB command-line interface, it's easy to troubleshoot GRUB.

Fortunately, the GRUB shell offers you help, so that it's not strictly necessary to remember all the right commands. To get an overview of all available commands, just type the help command.

Running help command on GRUB
Type 'help' to get an overview of all available commands.

Loading GRUB manually requires entering all the commands from the /boot/grub/menu.lst file. The best approach to do this is to look at the current contents of the menu.lst. You can do that from the GRUB shell by entering the command cat /boot/grub/menu.lst. This file contains what your computer requires to fix the Linux boot.

Manually entering commands into GRUB CLI
Make sure that you enter the correct commands, display the contents of the menu.lst file to get a good example.

With the example on your computer's monitor, you can manually enter all the GRUB lines. That means that you must enter the root, kernel and initrd lines. One potential setup looks like this:

root (hd0,0) kernel /boot/vmlinuz-2.6.24-16-server root=/dev/sda2 ro
splash initrd /boot/initrd-2.6.24-16-server

After entering these commands, your computer awaits further instructions. Basically, that means you must enter the boot command now to start the booting process. Monitor it carefully to make sure that there are no booting errors.

There are chances that the server will give you an error if you manually enter the lines from the menu.lst to fix the Linux boot. If you receive an error message, reexamine your code to find any potential errors and run GRUB again.

Dig Deeper on Data center ops, monitoring and management

SearchWindows Server
Cloud Computing
Search Storage
Sustainability
and ESG
Close