Tips for Grub Repair on a Linux Server

In most cases, a Linux server will not stop working unless someone does something to it. In other words, if you do not attempt to tweak it or optimize it, you do not have to worry about waking up one morning to find out none of your websites are active.

Having said that, we all make mistakes, and I can testify to occasions when I did something I thought would be a simple customization, only to find out it caused my system to no longer boot.

When your server will not longer boot, it is often because of an issue with Grub, the Linux bootloader. The good news is that grub problems are usually easy to fix. The bad news is that fixing them will almost always require physical access to the server. If you lease a remote dedicated server, you better hope you made good backups.

You need physical access because the easiest way to fix grub is to boot to a live CD or rescue CD, preferably a CD containing the Linux distribution you have installed. For a CentOS server, follow these instructions.

  1. Start the server with the live CD inserted.
  2. At the boot prompt, type “linux rescue”
  3. Mount all file systems in read-write mode.
  4. Change to “real root” on the disk:
    chroot /mnt/sysimage
  5. Re-install grub. For installation on the MBR of your drive labeled /dev/sda, type:
    grub-install /dev/sda

There are plenty of other issues you can have with grub, and the exact cause and solution may vary depending on your distribution. Consult your distribution’s documentation before trying anything.











Comments: