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.

630px-Hard_disk_platters_and_head

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
http://ubuntuforums.org/showthread.php?t=1540873

You might also like

Make Raspbian run from an external USB hard drive or USB memory stick
Raspberry Pi can ONLY boot from the SD Card. If you want to use your Raspberry Pi from an external USB...

Make Raspbian run from an external USB hard drive or USB memory stick
Raspberry Pi can ONLY boot from the SD Card. If you want to use your Raspberry Pi from an external USB...

Make Raspbian run from an external USB hard drive or USB memory stick
Raspberry Pi can ONLY boot from the SD Card. If you want to use your Raspberry Pi from an external USB...

Stop Spotlight from indexing external hard drive
If you don't want Spotlight to index an external driver or a USB flash drive you only have to add an...

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.