It is a good idea to backup the important system files like /etc/fstab, /etc/lilo.conf after you login using Tomsrtbt floppy or RedHat Linux CDROM (Rescue option) in following sections. This can be very handy during crash situation or something happens to system files.
bash# cp /etc/fstab /etc/fstab.orig bash# cp /etc/lilo.conf /etc/lilo.conf.orig bash# cp /etc/hosts /etc/hosts.orig bash# cp /etc/hosts.allow /etc/hosts.allow.orig bash# cp /etc/hosts.deny /etc/hosts.deny.orig bash# cp /etc/inetd.conf /etc/inetd.conf.orig bash# cp /etc/inittab /etc/inittab.orig bash# cp /etc/networks /etc/networks.orig
Most of the distributions like RedHat, SUSE, Debian provide CDROM which have "Rescue" option. For this, you have should set the BIOS of your computer to boot first from IDE CDROM drive. Usually you set the BIOS (using F8 key during boot) to boot first from CDROM drive, second from Floppy drive and third from hard disk. Load the Linux cdrom into the CD drive and reboot the system. The Linux distribution will load and at the prompt select "Rescue Operation". In the resuce operation mount the hard disks and try to repair.
# chroot /mnt/SYSIMAGE # df
Follow these steps to recover from LILO or system failures.
Get the tomsrtbt floppy http://www.toms.net/rb or MuLinux floppy (see also Tiny Linux). Boot with tomsrtbt floppy Use fdisk to find the partitions. Try to recognise the root and boot partition. Watch out, you may be having the /boot files on the root partition itself.
The Linux's root partition has the following directories bin, boot, etc, usr.
And the Linux's boot partition has these directories: vmlinuz, boot.b, chain.b, map.
To find out root partition do this :
bash# fdisk /dev/hda Command (m for help): m (Gives you help on commands) Command (m for help): p (Gives you list of partitons) Command (m for help): q 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
Next, you should find the /boot, /usr and /var partitions. The disk locations of these partitions are needed to create the new lilo configuration.
In my case the root partition is /dev/hda4 which is used in the examples below:
bash# mkdir /rootpart bash# mount /dev/hda4 /rootpart bash# cat /rootpart/etc/fstab Read the output of fstab and mount partitions as per fstab file, see below - bash# mount /dev/hda5 /rootpart/boot bash# mount /dev/hda6 /rootpart/usr bash# mount /dev/hda7 /rootpart/var bash# mount /dev/hda8 /rootpart/opt bash# mount /dev/hda9 /rootpart/root bash# mount /dev/hda10 /rootpart/home
Edit /etc/fstab (not /rootpart/etc/fstab) and put (sample code given here) -
/dev/hda4 /rootpart ext2 defaults 1 1 /dev/hda5 /rootpart/boot ext2 defaults 1 1 /dev/hda6 /rootpart/usr ext2 defaults 1 1 /dev/hda7 /rootpart/var ext2 defaults 1 1 /dev/hda8 /rootpart/opt ext2 defaults 1 1 /dev/hda9 /rootpart/root ext2 defaults 1 1 /dev/hda10 /rootpart/home ext2 defaults 1 1 /dev/hda11 /rootpart/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 /rootpart/win95part bash# mount /rootpart/win95part And repair the problem partitions using fsck or e2fsck commands. bash# man fsck bash# man e2fsck
Follow scene 1 above, if that fails then follow these steps. After executing steps in scene 1 above, you should have already mounted /rootpart and have created /etc/fstab file.
Note: It is very important to note how chroot command works below. The /sbin/lilo file which chroot uses is actually located in /rootpart/sbin/lilo and NOT in /sbin!! Hence, do not get confused.
bash# mount -a bash# chroot /rootpart /sbin/lilo -q bash# man chroot bash# chroot /rootpart /sbin/lilo
Note: New users of chroot will be confused. If chroot command complains that it cannot find /boot/map file then it actually means it that it cannot find /rootpart/boot/map. Because you gave /rootpart as the first argument to chroot and all references are with respect to /rootpart.
Alternatively, you can directly use /sbin/lilo instead of chroot. The -r option of lilo actually does chroot. It is very strongly recommended that you use chroot, instead of lilo -r, as it is more convenient and can catch errors more easily.
bash# man lilo bash# /sbin/lilo -r /rootpart
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. Or get boot disks for Linux/NT/Windows/DOS/Mac are at http://www.bootdisk.com Other option is - get a hold of installation Linux-CDROM. Just about every Linux distribution provides a image of a rescue disk on their CD. Under Linux use "dd if=/cdrom/disks/rescue of=/dev/fd0" to create a rescue floppy disk. Under DOS use rawrite.exe (included on Linux CD) and then do "rawrite image-name a:".
If you have another computer running linux, then login as root and do -
Note: If you compile your own kernel as a bzImage (for instance, bzImage-2.4.4), then you should create a hard link to vmlinuz-2.4.4 as follows (note the the z in name vmlinuz and it is not vmlinux). If you do not do this then mkbootdisk command may fail.
bash# cd /boot bash# ls -l vmlinuz* bash# ln /boot/bzImage-2.4.4 /boot/vmlinuz-2.4.4
bash$ man mkbootdisk bash# cp /etc/lilo.conf /etc/lilo-original.conf
bash$ mkbootdisk --device /dev/fd0 2.2.12-20
Step 1: Boot tomsrtbt (see Tiny Linux) 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 /rootpart ext2 defaults 1 1 /dev/hda11 /b1 vfat defaults 1 1 bash$ mkdir /rootpart; mount /rootpart 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 /rootpart
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 --device /dev/fd0 2.2.12-20 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$ su - root bash# man fdisk bash# fdisk -l /dev/sda > partition_table_backup.txt
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
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |