penn

链接

Backup and recover your boot sector

2008年11月14日 21:36 | Comments(0) | Category:Linux | Tags:

You can can use rsync for remote backups and tar or dd for local backups to backup your file system, however, there aren't as many options for backuping the boot sector.  But,  having a backup of your boot sector is equally important in the events of system crash.  Fortunately, dd tool does this work perfectly.

Grub and Lilo, or any other boot loader, generally installed ot the boot sector of your boot disc. After you have installed or modified your boot sector and verified that whether it works, back it up by writting it to a file on your hard driver:

for IDE driver:

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

for SCSI driver:

# dd if=/dev/sda of=bootsector.bin bs=512 count=1

or you can write it to a floppy disk directly:

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

Make sure that you use the right source and destination, if you mistakely write the a file or the floppy to your boot driver when you make a backup, you'll damage your boot sector and won't enable to boot.

Now, if there has any error on your boot sector, you can restore rapidly from these images backuped previously by reversing the "if" and "of" destination:

# dd if=bootsector.bin of=/dev/hda

if it stored on a floppy disk, use following command:

# dd if=/dev/fd1 of=/dev/hda

relatively, if the driver is a SCSI disk, substitute sda for hda.