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