Sunday, May 01, 2005

Recover Linux boot loader

Recover Linux Boot loader
This is to be done when you need to recover the Linux boot loader after another OS has erased the previous boot loader

most of the Linux distros have rescue mode
lookout for that option when you boot from the 1st Cd of that distro.
you will end up at some shell prompt with some directions about your current system image
you can follow those instructions to recover the Linux loader

this document will help you to recover the Linux loader for any distro and any version

boot from a Linux rescue CD or any Live CD
when you are at the shell prompt

run this

#fdisk -l

you will get some entry like this

Device Boot Start End Blocks Id System
/dev/hda1 * 1 510 4096543+ b W95 FAT32
/dev/hda2 511 1096 4707045 83 Linux
/dev/hda3 1097 1797 5630782+ 83 Linux
/dev/hda4 1798 4865 24643710 f W95 Ext'd (LBA)
/dev/hda5 1798 2243 3582463+ 7 HPFS/NTFS
/dev/hda6 2244 2753 4096543+ b W95 FAT32
/dev/hda7 2754 4347 12803773+ b W95 FAT32
/dev/hda8 4348 4865 4160803+ 83 Linux

since i have multiple Linux FS partitions so i have more than one entry here,
this may not be the case for you ,or if it is then you need to identify your root (/) partition

Bow i know that my root(/) for my Linux installation is /dev/hda3

so i will make a dir in anywhere ,say in the /tmp directory

# mkdir /tmp/mnt

then mount your Linux installation there

# mount /dev/hda3 /tmp/mnt/

then chroot to that partition

if everything is right then you will end up here

# chroot /tmp/mnt/
root@gaurav/ #

most Linux rescue modes will leave you to this stage ,so the below directions are common for all distros.

then if you had grub installed earlier the go for re-installing grub as

# grub-install /dev/hda

or if you have lilo installed
you can check lilo installation by

# lilo -v

this will only check if the lilo boot loader will be installed without any errors and will not install lilo.

and to install lilo
run

#lilo

after this u can exit from the Linux rescue mode and go for a reboot .

No comments: