You cannot avoid accidents and if it happens to linux systems then it may damage the master boot record (MBR) or LILO (Linux boot Loader). There may be cases where linux will not boot due to hard disk failures. The LILO may also fail if you accidentally re-partition the hard disk or you install another additional operating system like Windows 98/NT on the linux computer.
This document gives you some ideas, tips and quick guide to recover fast without wading through hundreds of pages of documentation on LILO or Linux.
Follow these steps to recover from LILO or system failures.
Get the tomsrtbt floppy http://www.toms.net/rb Boot with tomsrtbt floppy Use fdisk to find the partitions. Try to recognise the root partition by doing this -
bash# fdisk /dev/hda bash# mkdir /test bash# mount /dev/hda1 /test bash# ls /test You should see root-partition list like this - bin fd lib mnt proc sbin usr boot dev etc home lost+found opt root tmp var
In my case the root partition is /dev/hda4 which is used in the examples below:
bash# mkdir /hda4 bash# mount /dev/hda4 /hda4 bash# cat /hda4/etc/fstab Read the output of fstab and mount partitions as per fstab file, see below - bash# mount /dev/hda5 /hda4/boot bash# mount /dev/hda6 /hda4/usr bash# mount /dev/hda7 /hda4/var bash# mount /dev/hda8 /hda4/opt bash# mount /dev/hda9 /hda4/root bash# mount /dev/hda10 /hda4/home
Edit /etc/fstab (not /hda4/etc/fstab) and put (sample code given here) -
/dev/hda4 /hda4 ext2 defaults 1 1 /dev/hda5 /hda4/boot ext2 defaults 1 1 /dev/hda6 /hda4/usr ext2 defaults 1 1 /dev/hda7 /hda4/var ext2 defaults 1 1 /dev/hda8 /hda4/opt ext2 defaults 1 1 /dev/hda9 /hda4/root ext2 defaults 1 1 /dev/hda10 /hda4/home ext2 defaults 1 1 /dev/hda11 /hda4/win95part vfat defaults 1 1 On my computer hda4 contains the linux root partition, hda5 had boot partition and hda11 has windows 95 vfat system. bash# mkdir /hda4/win95part bash# mount /hda4/win95part And repair the system using fsck or e2fsck commands. bash# man fsck bash# man e2fsck
Follow scene 1 above, if that fails then follow these steps. Now you should have already mounted /hda4 and have created /etc/fstab file.
bash# mount -a bash# chroot /hda4 /sbin/lilo -q bash# man chroot bash# chroot /hda4 /sbin/lilo
bash# man lilo bash# /sbin/lilo -r /hda4
If scene 1 and 2 failes, then if you made the boot disk with 'mkbootdisk' (during install or by using 'man mkbootdisk'), boot with it and repair your partitions. The mkbootdisk is in mkbootdisk*.rpm package, you must install this.
If you have another computer running linux, then login as root and do -
bash$ man mkbootdisk bash# cp /etc/lilo.conf /etc/lilo-original.conf
bash# mkbootdisk /dev/fd0
Step 1: Boot tomsrtbt and mount the partitions and backup the root partition to another partition having disk space with comamnds -
Edit /etc/fstab and put (sample code given here, you may have to change as per your disk layout) - /dev/hda4 /hda4 ext2 defaults 1 1 /dev/hda11 /b1 vfat defaults 1 1 bash$ mkdir /hda4; mount /hda4 bash$ mkdir /b1; mount /b1 bash$ cd / bash$ df And see that there is enough disk space in /b1 to tar up the root partition bash$ tar cvf /b1/root-hda4.tar /hda4
Step 2: Insert Linux cdrom, reboot and install the redhat linux on /dev/hda4 (but DO NOT install any extra packages, you just need to install only the root, boot systems and LILO manager that is, a very bare minimum). This will also install the LILO on hard disk. Boot linux now and login as root and do -
bash$ man mkbootdisk bash# cp /etc/lilo.conf /etc/lilo-original.conf
bash# mkbootdisk /dev/fd0 bash# cp /etc/lilo-original.conf /etc/lilo.conf
You should take the following pre-cautionary measures to tackle the problems in future.
bash$ man mkbootdisk The mkbootdisk is in mkbootdisk*.rpm package, you must install this. bash$ mkbootdisk --help bash$ mkbootdisk --device /dev/fd0 2.2.12-20
bash# vi /etc/fstab And put these lines - /dev/hda1 /a1 vfat defaults 1 1 /dev/hdb1 /b1 vfat defaults 1 1 In my case hda1 had the linux root partition '/' bash# cd / bash# tar cvf /b1/linux-root-partition-hda1.tar a1 bash# tar cvf /b1/linux-boot-partition-hda1.tar a1/boot
You can replace the boot sector with the DOS boot loader by issuing the DOS command at MS DOS prompt:
FDISK /MBR
See also LILO documentation on linux at /usr/doc/lilo* for other methods of uninstalling the LILO. And see also 'man lilo'.
After making changes to /etc/lilo.conf you MUST run lilo to make changes to go in effect. It is a very common mistake committed by newusers. Type -
bash# lilo -v -v -v