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
.
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.
If you use GRUB things are a little bit different to that of LILO.
![]() | 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
|
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.
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.
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