6. Bootloader Issues

6.1. Bootloader Reinstall

It may happen that you make a mistake and wipe your disk's MBR (Master Boot Record), or some misbehaving program erases it, or you dual boot with Windows® and catch a virus which suppresses 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 need a boot disk. Without a boot disk of some kind you might be completely lost, unless you made a backup of your MBR, see Section 6.2, “Backing Up and Restoring the MBR”.

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 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 command reinstalls LILO on your disk's boot sector and fixes the problem.

6.1.2. With GRUB

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

[Note]Note

In the following example we 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 installs 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 run a dual-boot system, be very careful to always have a GNU/Linux boot disk prepared. If you don't have a boot disk, and you (re)install Windows® (all versions) you won't be able to boot GNU/Linux after the Windows® upgrade because Windows® rewrites the MBR without any warning at all.

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.