Backup Your MBR on Linux
Use this command to backup your MBR:
dd if=/dev/hda of=/home/hda.boot.mbr bs=512 count=1
To restore the MBR (from a Live CD), use this command:
dd if=/mnt/hda1/home/hda.boot.mbr of=/dev/hda bs=512 count=1
About the dd command:
dd if=<source> of=<target> bs=<byte size>("USUALLY" some power of 2, not less than 512 bytes(ie, 512, 1024, 2048, 4096, 8192, 16384[/b], but can be ANY reasonable number.) skip= seek= conv=<conversion>.
Source is the data being read. Target is where the data gets written.
Warning!! If you reverse the source and target, you can wipe out a lot of data. This feature has inspired the nickname "dd" Data Destroyer.
Warning!! Caution should be observed when using dd to duplicate encrypted partitions.
In response to one of the comments posted, it was asked how dd would treat encrypted partitions. The answer is dd should copy a partition, any partition, just fine. All it sees is raw data - a sequence of numbers. It neither knows nor cares about file systems or drive types. You'll just have to remember it was encrypted and loop crypt mount to mount it.
Thanks to the fine folks at Edmonton Linux Users Group and especially Mike Ward for that answer.


Reader Comments (2)
What sort of problems might arise from using dd on a encrypted partition? Thanks.
Hi there, sorry about not getting back to you right away. I was on vacation for the past number of weeks. I am unsure what problems may arise if dd is used on an encrypted partition. From what I know of dd, it creates an exact replica of what you point it to. The only problem I'd foresee is if the system somehow "registers" the encrypted partition and that it would "know" if the partition was "tampered" with should you "reload" the partition.
I found one resource that suggests dd works fine with encrypted partitions. It just states to unmount the partition before running dd.
If I found out more, I'll add a followup to my post.