Difference between revisions of "Create SD Card Images"

From odroid US
Jump to: navigation, search
Line 9: Line 9:
 
</pre>
 
</pre>
  
Now you need to clip the image to end at the end of the second partition.  This allows Windows users to use the image.  Use file to get information about you image:
+
Now you need to clip the image to end at the end of the second partition.  This allows Windows users to use the image.  Use file to get information about your image:
  
 
<pre>
 
<pre>

Revision as of 12:18, 17 May 2013

This tip is for Linux users

Once you have an SD Card you are happy with, you can create an image of it. Connect the SD Card to the host and make sure you know which device the SD Card came up as. (Use dmesg or similar technique) Use your device letter instead of X below.

Create a complete copy of everything on the SD Card:

sudo dd if=/dev/sdX of=myimage.img bs=4M

Now you need to clip the image to end at the end of the second partition. This allows Windows users to use the image. Use file to get information about your image:

file myimage.img

Output is formatted for clarity.

Ubuntu_12.11_20130420_Fully_Loaded_U2-HDMI.img: x86 boot sector; 
partition 1: ID=0xb, starthead 66, startsector 4096, 262144 sectors; 
partition 2: ID=0x83, starthead 61, startsector 266240, 11266048 sectors, code offset 0xb8

Do some calculation. End of partition 2: 266240+11266048=11532288 sectors. There are 512 bytes/sector for ext4 partitions, so convert to megabytes: (11532288*512)/(1024*1024) = 5631. For this specific image, the smallest amount of data we need to copy is 5631M.

Use dd to copy just the minimum length:

dd if=myimage.img of=clipped.img bs=1M count=5631

Now the clipped.img file holds the SD Card image. We can loop mount it as a check, but we need the starting offset in bytes: 266240*512=136314880

mkdir mnt
sudo mount -t ext4 -o ro,loop,offset=136314880 clipped.img mnt
# Now you can look around in the mnt directory
# and umount when done
sudo umount mnt

Compress the image to save internet bandwith:

xz -z clipped.img

And get the md5sum:

md5sum clipped.img.xz > clipped.img.xz.md5sum