| 0 comments ]

While in Linux, it may be prudent to backup the system's boot sector before installing another Operating System or before any major filesystem changes or BIOS upgrades. (OR to just simply have it as a backup.)

Backup

Issue the following command from the terminal to backup the boot sector to a file called backup.boot. Note: the drive name could be different depending on your setup (i.e. sda instead of hda). Type df -h for more information.

dd if=/dev/hda of=backup.boot bs=512 count=1

Restore

Issue the following command to write the boot sector to the hda drive. Note: the drive name could be different depending on your setup (i.e. sda instead of hda). Type df -h for more information.

dd if=backup.boot of=/dev/hda bs=1
  • In short, replace hda with your device, use df -h to figure out root partition (i.e. /dev/sda)



Check and Compare Backup Files

CMP: comparing binary files

"If you want to compare two files byte by byte, you can use the cmp program with the `-l' option to show the values of each differing byte in the two files. With GNU cmp, you can also use the `-c' option to show the ASCII representation of those bytes. See section Invoking cmp, for more information." -

cmp -l file1.boot file2.boot

Diff: comparing binary files:

diff --binary backup.boot backup.boot2

0 comments

Post a Comment