Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

How To Create an Image of the SD Card

Luke Hsiao edited this page Apr 10, 2015 · 2 revisions

Using Linux

First, know your partitions:

sudo fdisk -l

Full backup of the image:

sudo dd if=/dev/sdx of=/path/to/image

or for compression (recommended):

sudo dd if=/dev/sdx | sudo gzip > /path/to/image.gz

To restore the backup you reverse the commands:

sudo dd if=/path/to/image of=/dev/sdx

or when compressed:

sudo gzip -dc /path/to/image.gz | sudo dd of=/dev/sdx 

Important Note:

SD cards are not exactly the same size!. This means that even though you want to restore our 16GB SD card image to another 16GB SD card, it may not work because the other SD card is slightly smaller/larger. There are two ways to deal with this:

Resize the Root Partition

This means that the original Linux paritions created on the SD card should actually be a bit smaller than the full card so that there is unused space. For example, if you're using a 16GB SD card, rather than installing Linux and letting it fill the card, force it to install in a smaller, say, 14GB partition. This way, your image is guaranteed to fit on another 16GB card. We did NOT do this.

Truncate the Image and Fix the File System

Unforunately, with our disk images, you may just have to copy what you can, which will truncate off the end of the image. Then, you can use another tool to fix the filesystem and it should work just fine.

There are lots of different ways to do this in Linux. Some involve using resize2fs, others involve using dd directly, then rsync. Just make sure you have a backup of the original image in case something goes wrong!