Posts: 37
Joined: Sat May 19, 2012 5:33 pm
Location: IO93ml

Backup theory question

Sat Oct 27, 2012 6:42 pm


I use a mac and used dd to back up my 4GB SD card using this command:

Code: Select all

sudo dd bs=1m if=/dev/rdisk1 of=~/Desktop/ssbackup01.img
My install is the main Wheezy os with apt-get update and upgrade ran, git-hub installed and the rpi-update ran. So not much new data added to make my SD bigger than I started with.

The backup I created is 4.03gb (4,025,483,264 bytes), unlike the official download which is 1.94gb (1,939,865,600 bytes).
Did i do something wrong to create a larger image than the one I start with?
If my file is reporting 4.03gb how can I expect this to fit onto a 4gb SD card, it seems to me that the file is greater than the capacity of a blank SD.

Can anyone help me understand the science? I want a foolproof way to back up my install and flash to any other SD card 4gb or greater.

Thanks ;)

Posts: 37
Joined: Wed Aug 15, 2012 8:44 pm

Re: Backup theory question

Sat Oct 27, 2012 8:10 pm

When you use dd, it copies the whole card (including empty space), so your image will be the size of the entire sd card regardless of what space is actually in use.

It may fit on another 4gb card (I've had times when it doesn't). I'm not 100% certain but I think that if you want to fit your image onto a 2gb card for example, you should use fdisk or gparted to shrink the active partition first. I can't really explain how because I've never done it, and it's very easy to kill your install!

Posts: 37
Joined: Wed Aug 15, 2012 8:44 pm

Re: Backup theory question

Sat Oct 27, 2012 8:12 pm

Also, it will definitely fit back on the same card or a larger one (you can then use raspi-config to expand the image to fill the bigger card)

User avatar
Posts: 606
Joined: Fri Aug 17, 2012 3:35 am
Location: Mesa, AZ
Contact: Website

Re: Backup theory question

Sat Oct 27, 2012 8:21 pm

The key I have found is to not expand to the "full" size of the SDcard but rather just a tad bit less. This needs to be done when you first expand the filesystem to fit the card.

I wrote a script that does this called rpi-wiggle. Again, this doesn't work if you have already expanded using raspi-config or other methods.

This then allows you to make backups of the image and write them to like sized SDCards without the size being too large.

Note that if you have already expanded, getting it smaller requires a lot of steps typically using a Linux box.
Dweeber A.K.A. Kevin...
My RPI Info Pages including Current Setup -

Forum Moderator
Forum Moderator
Posts: 3755
Joined: Wed Dec 28, 2011 11:45 pm

Re: Backup theory question

Sun Oct 28, 2012 12:30 am

dd is a dumb tool, it just copies whatever it finds. So if you use it to make an image and don't explicitly tell it where to stop it will copy everything including unpartitioned space.

As long as the parts of the image that actually contain partitions fit when you restore your image then the image should work fine.

Return to “Raspberry Pi OS”