Backing Up your SD Card with Linux

From LearnLinux.tv Wiki
Jump to navigationJump to search

Overview

In this video, the viewer is shown several varations of the dd command for backing up an SD card.

Relevant Links
Original Video

View attached storage volumes

 lsblk

dd command samples

Note: Replace "<DEVICE ID>" with the actual device ID, and "<IMAGE NAME>" with the name you want to call your image.

Note 2: Target the entire SD card, not individual partitions. Basically, leave out the partition numbers:

 * "/dev/mmcblk0" instead of "/dev/mmcblk0p1"
 * "/dev/sdb" instead of "/dev/sdb1"
Normal image (image roughly the same size as the sd card itself)
 sudo dd if=/dev/<DEVICE ID> of=<IMAGE NAME>.img bs=4M; sync

Example:

 sudo dd if=/dev/mmcblk0 of=mysdcard.img bs=4M; sync
Restore the image created in the previous example (reverse 'if' and 'of')
 sudo dd if=<IMAGE NAME>.img of=/dev/<DEVICE ID> bs=4M; sync

Example:

 sudo dd if=mysdcard.img of=/dev/mmcblk0 bs=4M; sync
Create an image (and also compress it at the same time, which saves LOTS of space
 sudo dd if=/dev/<DEVICE NAME> | gzip > <IMAGE NAME>.img.gz

Example:

 sudo dd if=/dev/mmcblk0 | gzip > mysdcard.img.gz
Restore a compressed SD Card image
 sudo gzip -dc <IMAGE NAME>.img.gz | sudo dd of=/dev/<DEVICE ID>

Example:

 sudo gzip -dc mysdcard.img.gz | sudo dd of=/dev/mmcblk0