Tag Archives: backup

Backup and restore hard drive with “dd”

Look for the hard drives device with mount or sudo fdisk -l and unmount it. In my case it’s going to be sda.


Backup uncompressed image:

sudo dd if=/dev/sda of=/home/sda.bin bs=1024

Backup compressed image:

sudo dd if=/dev/sda bs=1024 | gzip > /home/user/sda.bin.gz

If the target file system where the image is going to be created can’t have files larger than 4GB for example (as for FAT32) you’ll have to split the output:

sudo dd if=/dev/sda conv=sync,noerror bs=64K | gzip -c | split -b 2000m - /media/usbdrive/sda.bin.gz

Restore uncompressed image:

sudo dd if=/home/user/sda.bin of=/dev/sda bs=1024

Restore compressed image:

sudo gzip -dc /home/user/sda.bin.gz | dd of=/dev/sda bs=1024

Restore compressed and splited image:

sudo cat /media/usbdrive/sda.bin.gz.* | gzip -dc | dd of=/dev/sda conv=sync,noerror bs=64K

You can do the same with only one partition of the hard drive if you replace sda with sdaX being X the partition number.

Ref: https://help.ubuntu.com/community/DriveImaging#Creating_Disc_Images_Using_dd