Hard-Disk Partition Table management with “dd”.

Linux command dd seems unfriendly, but it is a very powerful command able to do many different things, like backup partitions, CD or USB stick or ca be used for zeroingMBR or the entire Partiton-Table.
The man page says: dd is an application that will “convert and copy a file”.

The GNU clone of dd is part of fileutils package and unlike most Unix commands, dd uses a keyword=value format for its parameters.

The dd utility copies the specified input file to the specified output with possible conversions.
The standard input and output are used by default. The input and output block sizes may be specified to take advantage of raw physical I/O.
Sizes are specified in bytes and the number may end with k, b, or w to specify multiplication by 1024, 512, or 2, respectively. Numbers may also be separated by x to indicate multiplication.

Basic options are:
if= file Specifies the input path. Standard input is the default.
of= file Specifies the output path. Standard output is the default.

Backup MBR with dd command:
The following command is used to back-up MBR stored on /dev/sdX on a file:

dd if=/dev/sdX of=/tmp/sda-mbr.bin bs=512 count=1

The following command will restore partition table to disk:

dd if= sda-mbr.bin of=/dev/sdX bs=1 count=64 skip=446 seek=446

The following command will zero everything (both MBR and partition table record):

dd if=/dev/zero of=/dev/hda bs=512 count=1

The following command will zero the boot code (MBR) but the partition table remains intact:

dd if=/dev/zero of=/dev/hda bs=446 count=1

Comments are closed.