How to reactivate Linux loaders GRUB, GRUB 2 and LILO
Solution
Reactivating GRUB
Boot from Linux installation CD and enter rescue mode;
Mount all partitions and change root from the temporary root to the root partition of the installed system:
#mkdir /mnt/tmp
#mount /dev/sdXY /mnt/tmp (/dev/sdXY is the root partition)
#chroot /mnt/tmp
Generate /etc/mtab:
#grep -v rootfs /proc/mounts > /etc/mtab
Check if the GRUB configuration file is correct:
GRUB stores its configuration in either /boot/grub/grub.conf or /boot/grub/menu.lst depending on the distribution you are using.
Reactivate GRUB automatically:
Run the following command:
#grub-install /dev/[device name]
where /dev/[device name] is the name of disk/partition where you are going to install GRUB.
For example, the following command will install GRUB to the MBR of disk /dev/sda:
Reactivate GRUB manually in case Step 5 fails:
You will receive a prompt:
Please issue the commands (4 is the root partition in this example):
grub>root (hd0,4)
grub> setup (hd0)
You will see the output:
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/reiserfs_stage1_5" exists... yes
Running "embed /boot/grub/reiserfs_stage1_5 (hd0)"... 18 sectors are embedded
.
succeeded
Running "install /boot/grub/stage1 (hd0) (hd0)1+18 p (hd0,4)/boot/grub/stage2
/boot/grub/grub.conf"... succeeded
Done.
grub>
Reboot.
Reactivating GRUB 2
If recovering a Linux partition using Acronis software, its UUID changes, which will cause GRUB 2 to fail to boot the OS with an error, for example:
Error: invalid arch independent ELF magic
In such cases, one needs to reinstall GRUB 2:
Boot the Live CD, for example, Ubuntu Live CD;
From the Desktop, open a terminal: Applications -> Accessories -> Terminal ;
Determine your normal system partition:
sudo fdisk -l (That is a lowercase L)
If you aren't sure, run the following command and look for the correct disk size and ext3 or ext4 format:
Mount your normal system partition:
sudo mount /dev/sdXY /mnt
If you aren't sure if you mounted the correct partition, once it's mounted run the following command to inspect the partition:
ls /mnt
If it is the correct partition, you should see the normal Linux folders such as /bin, /boot, /etc, /home, etc
Example:
sudo mount /dev/sda1 /mnt
Note: the partition to mount is normally the partition on which Linux was installed: sda1, sdb5, etc. If you have a separate /boot partition, use the device on which the /boot partition is located. Grub 2 works best when installed in the MBR of the drive to which BIOS boots. Also remember that you mount the partition (including the number) in this step, but you do not include the partition number when you run the "sudo grub-install" command later. GRUB 2 counts the first drive (X) as "0", but the first partition (Y) as "1".
Only if you have a separate boot partition:
sudo mount /dev/sdXY /mnt/boot
with sdXY being your /boot partition designation.
Reinstall GRUB 2:
sudo grub-install --root-directory=/mnt /dev/sdX
Do NOT include the partition number.
Example:
sudo grub-install --root-directory=/mnt /dev/sda
Note: Substitute the device on which Ubuntu was installed - sda, sdb, etc. Do not specify a partition number.
Unmount the partition:
If you mounted a separate /boot partition, unmount it first:
Reboot.
Reactivating LILO
Boot from Linux installation CD and enter rescue mode;
Mount all partitions and change root from the temporary root to the root partition of the installed system:
#mkdir /mnt/tmp
#mount /dev/sdXY /mnt/tmp (/dev/sdXY is the root partition)
#chroot /mnt/tmp
Run the following command to reactivate LILO:
Reboot.
More information
See also: