BACK UP YOUR BOOT SECTOR

While there are many ways to back up your file system, such as rsync for remote backups and tar or dd for local backups, there aren't as many options for backing up your boot sector. However, having a backup of your boot sector is equally important in the event of a system crash. For this procedure, the dd tool is your best bet.

LILO, or any other boot loader, is generally installed on the boot sector of the boot drive. After you've installed or modified your boot sector and verified that it works, back it up by writing it to a file on your hard drive or a floppy disk. For example:

# dd if=/dev/hda of=bootsector.img bs=512 count=1

or:

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

The first command writes the boot sector of your boot drive (in this case, /dev/hda) to a file called bootsector.img in the current directory. Replace /dev/hda with your boot drive, such as /dev/sda if you have a SCSI drive, or /dev/hde if you boot off the first device on the third controller, such as an ATA100 controller in a system with onboard ATA66 controllers.

If you ever need to restore from these images, reverse the "infile" (if) and "outfile" (of) destinations. For example:

# dd if=bootsector.img of=/dev/had

If it's stored on a floppy, use this:

# dd if=/dev/fd0 of=/dev/had

Make sure that you use the right source and destination. If you mistakenly write the floppy to the hard drive when you make a backup, you'll damage your boot sector and won't be able to boot.