Restoring the Stage 1 Boot Loader

Sometimes things go wrong when working with Linux, whether a side effect related to a process during patching or a mis-issued command can render your system unusable.

In this brief post, I will describe a process that can be used in the event you have blown away Grub from the MBR (Master Boot Record).  This recovery takes a few minutes and in the event occurs to you, can save hours if your planned solution was rebuild and restore.

How do I know if this is possibly the issue that is affecting me?  The Linux boot process involves a few stages, the focus here will be based on the Stage 1 loader which occurs when the MBR is pulled to determine what boot loader should be used to facilitate the Stage 2 process.  A very common sympton that will occur when the Stage 1 loader is having issues is seeing only “GRUB ” when your system boots.  This is a common indicator that the system is having problems locating the device map and allowing it to proceed to Stage 2 and continue with the boot process.

If this is the case that your system is experiencing, the process to restore is booting into rescue mode, mounting the file systems, and restoring the grub loader.  The below steps assume your boot partition is the first primary partition on your system, your root file system is contained inside LVM, called rootvg, and your / is called rootlv, and your primary disk’s name is sda.

First is to boot into rescue mode, this is defined based on the Linux distribution but is usually a trivial task and utilizes the rescue prompts provided from the media.  The next step is to mount your current disk in the rescue mode so it can be used for the repair.

mount /dev/rootvg/rootlv /mnt

mount /dev/sda1 /mnt/boot

grub-install –root-directory=/mnt /dev/sda1

umount /mnt/boot

umount /mnt



The above commands will restore the grub loader and allow your system to move on after the Stage 1 loader, the above file systems and device names need to be adjusted given your setup