How to backup and restore bootsector

Trying to install new O/S with dual-boot is a scary job, it can leave you with a messed up bootsector.

To backup first 512 bytes:

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

First 512 bytes on the hdd is known as bootsector.You should change the device to reflect your boot drive (it may be sda for SCSI).

To restore use:

dd if=bootsector.img of=/dev/hda