6. Bootloader Issues

6.1. Bootloader Reinstall

Sometimes you will make a mistake and wipe your disk's MBR (Master Boot Record), or some misbehaving program does it, or you dual boot with Windows® and catch a virus that does it. So, you think you won't be able to boot your system anymore, right? Wrong! There are many ways to recover the boot record.

To recover your bootloader you will need a boot disk. Without a boot disk of some kind you might be completely lost[20].

Reboot your computer using the boot disk. What you do next varies according whether you use LILO or GRUB. No matter which bootloader you use, all the commands you must execute will need to be run as root.

6.1.1. With LILO

If you use LILO, you only need to issue the following at the command prompt: /sbin/lilo. This will re-install LILO on your disk's boot sector and will fix the problem.

6.1.2. With GRUB

If you use GRUB things are a little bit different to that of LILO.

[Note]Note

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 /boot/grub/ directory.

First, invoke GRUB's shell by issuing the grub command. 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.

6.1.3. Some Considerations for Dual-Booting Systems

Windows 9x, NT, 2000 and XP upgrades. If you are running a dual-boot system, be very careful to always have a GNU/Linux boot disk prepared. When (re)installing Windows® (all versions), as Windows® rewrites the MBR without any warning at all, and if you don't have a boot disk, you won't be able to boot GNU/Linux after you perform the Windows® upgrade.

6.2. Backing Up and Restoring the MBR

To make a backup copy of your hard disk's MBR, insert a blank floppy in your floppy disk drive and issue the following:

# dd if=/dev/hda of=/dev/fd0/mbr.bin bs=512 count=1

If you want to restore a backed up copy of your hard disk's MBR, insert the floppy containing it into your floppy disk drive and issue the following:

# dd if=/dev/fd0/mbr.bin of=/dev/hda bs=512
[Note]Note

The above examples assume that the MBR of your first IDE hard disk (/dev/hda) is backed up to a file named mbr.bin on your first floppy diskette drive (/dev/fd0) and should be run as the root user.



[20] Unless you made a backup of your MBR.