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.


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...
Install Raspbian RAW image into an SD Card in Mac OS X
First download a Raspbian RAW image from here: Plug-in your SD...
Avoid Android File Transfer starting automatically in Mac OS X after Android device plugin to USB port
"Android File Transfer" application starts automatically in Mac OS X when you plug your Android device...
Install OpenCV 2.3.1a in Ubuntu 11.10
If you want to install OpenCV 2.1 you can just use apt-get to do the work: sudo apt-get install libcv-dev...
Leave a comment ?


Leave a Comment