Cloning a large SD card to smaller card PDF

This is just some quick documentation of how to clone the image from a larger SD card onto a smaller SD card.  Now obviously this won't work if the card is actually full of data, but in my case I had an 8 gig card I wanted to reclaim use of since the application I'm using didn't need near that much space.  I wanted to put it on a 4 gig card....

 

So first step is use gparted or something similar to shrink the partition down to a little less than 4 gig.  Once it's on the other card, you can always expand it so lean towards the small side.  

 

Then, use dd to copy the large card's image to your local hard disk.  

dd if=/dev/mmcblk0 of=sd.img

 

That image should wind up being about the size of your large card - in my case 8 GB.  You could also use the 'bs' and 'count' switches to have dd only copy the first 4 GB since that's all we'll actually make use of.  

 

Now put the smaller card in your card reader and use dd to write the image onto it.  

 

dd if=sd.img of=/dev/mmcblk0
[sudo] password for elijah: 
dd: writing to `/dev/mmcblk0': No space left on device
7761921+0 records in
7761920+0 records out
3974103040 bytes (4.0 GB) copied, 1962.22 s, 2.0 MB/s
 

But as long as your partition(s) were shrunk so the total is less than 4 gigs, the fact that the entire image wasn't copied shouldn't be a problem.  Or at least, it wasn't for me :-)