clone devices with dd

Thursday, 8. November 2012

1. Open Konsole
2. Make sure NO partitions are mounted from the source hard drive.
3. Backup the whole drive.

# dd if=/dev/sda conv=sync,noerror bs=64K | gzip -c > sda.img.gz

  4, Backup MasterBootRecord

#  dd if=/dev/sda of=mbr-backup count=1 bs=512

“dd” is the command to make a bit-by-bit copy of “if=/dev/sda” as the “Input File” to “of=sda.img.gz” as the “Output File”. Everything from the partition will go into an “Output File” named “sda.img.gz”. “conv=sync,noerror” tells dd that if it can’t read a block due to a read error, then it should at least write something to its output of the correct length. Even if your hard disk exhibits no errors, remember that dd will read every single block, including any blocks which the OS avoids using because it has marked them as bad. “bs=64K” is the block size of 64×1024 Bytes. Using this large of block size speeds up the copying process. The output of dd is then piped through gzip to compress it.


  •  To restore your system:
 #  gunzip -c sda.img.gz | dd of=/dev/sda conv=sync,noerror bs=64K    
  • To restore Masterbootrecord
# dd if=mbr-backup of=/dev/sda

other useful things:


  • Store extra information about the drive geometry necessary in order to interpret the partition table stored within the image. The most important of which is the cylinder size.
# fdisk -l /dev/hda >
  •  backup just one partition
#  dd if=/dev/sda2 of=sda2.img



One of the disadvantages of the dd method over software specifically designed for the job such as clonezilla is that dd will store the entire partition, including blocks not currently used to store files, whereas the likes of clonezilla understand the filesystem and don’t store these unallocated blocks. The overhead isn’t too bad as long as you compress the image and the unallocated blocks have low entropy. In general this will not be the case because the emtpy blocks contain random junk from deleted files. To rectify this, it’s best to blank all unused blocks before making the image. After doing that, the unallocated blocks will contain mostly zeros and will therefore compress down to almost nothing.

Mount the partition, then create a file of zeros which fills the entire disk, then delete it again.

# dd if=/dev/zero of=/tmp/ bs=8M; rm

also read (dd with progressbar)

very special thx to


Comments are closed.