Sometimes you make a mistake and wipe your disk's MBR (Master Boot Record), or some misbehaving program does it, or if you dual boot with Windows and catch a virus that does it. So, you say, I won't be able to boot my system anymore, right? Wrong! There are many ways to recover the boot loader.
This one is not a surprise for anybody: To recover your boot loader you will need a boot disk. Without a boot disk of some kind you might be completely lost[1]. You have made a boot disk, haven't you?
Well, just put the diskette in the floppy drive and reboot your computer. What you do next varies according whether you use LILO or grub. No matter which boot loader you use, all the commands you have to execute will need to be run as root.
If you use LILO, you just need to issue the following at the command prompt: /sbin/lilo. This will reinstall LILO in your disk's boot sector and that will fix the problem.
If you use grub things are a little bit different than when using LILO... but don't be afraid, we are here to help.
![]() | The following example will assume that you are trying to install grub in the MBR of your first IDE drive, and that the file stage1 is in the directory /boot/grub/. |
First, invoke grub's shell by issuing the command: grub. Once there, issue the following command: root (hd0,0); this will tell grub that the files it needs are in the first partition (0) of your first hard disk (hd0). Then issue the following command: setup (hd0); this will install grub in the MBR of your first hard disk. That's it!
You can also try to use grub-install /dev/hda to install grub on your first hard drive's MBR, but the method described above is the preferred one.
Well, that is all there is to know about reinstalling your boot loader.
![]() | The information below only applies to ext2 and ext3 file systems. If you have another file system, please check the documentation on it for information about this. |
The super-block is the first block of each ext2fs partition. It contains important data about the file system, like size, free space, etc. (It is similar to the method used by FAT partitions). A partition with a damaged super-block cannot be mounted. Fortunately, ext2fs keeps several super-block backup copies scattered over the partition.
Boot your system with the boot disk you created earlier (You have created one, right?). The backup copies are usually located at the beginning of each 8 KB (8192 bytes) block. So, the next backup copy is in byte number 8193. To restore the super-block from this copy, execute e2fsck -b 8193 /dev/hda4; change hda4 accordingly to reflect the name of your damaged partition. If that block also happens to be damaged, try the next one at byte number 16385, and so on until you find a suitable one. Reboot your system to activate the changes.
[1] | Unless you make a backup of your MBR, more on that later... |