Backup image to smaller SD card

9 posts
by Jermcb » Tue Feb 05, 2013 1:59 pm
Hi everyone,

Just started using raspberry pi. It is great! I managed to set it up on an 8Gb SD card. It has all the functionality I need. So Now I want to make an image of the setup I currently have for team members. However, they all have 4Gb SD card.

Rather than going out to buy a bunch of 8Gb SD cards, is there a way to take the image from my 8Gb SD card an create an image for a 4Gb SD card.

I am only using about 3Gb maximum on the 8Gb card. We use windows operating systems on our computers.

Thank you!
Posts: 1
Joined: Tue Feb 05, 2013 1:53 pm
by JollyRoger » Tue Feb 05, 2013 3:25 pm
Hi Jermcb

This is how I do what you want to achieve:

First, shrink the size of the filesystem on your 8Gb card to under 4Gb, so that it fit will onto the smaller SD card. You can do this with Gparted. You have to create a Gparted CD (download the iso from, and boot your Windows machine from that. Full instructions for using Gparted are in an early edition of The MagPi (I can't remember which issue, but I know it's on pages 8-9 as I have a printout of the article).

Next you have to copy this reduced-size file system to a .img file on your hard disk. You can use Win32DiskImager for this; it will copy the entire 8Gb card, but don't worry about this.

Finally you have to put this .img file onto your smaller SD. You can't use a late version of Win32DiskImager for this, as it checks the size of the SD card before it attempts the task, and then refuses to go ahead because the card is too small. Instead you must use version 1 (i.e. 0.1), which you can find here (at the bottom of the page):

(Oh dear! I've just checked this url and its contents have been moved to another site. If necessary search for "win32diskimager 0.1")

This early version won't do any checks, instead it will simply copy the file onto the smaller SD card until it runs out of space, at which point it stops and spits out a warning message. Ignore this message. You can now if you wish used Gparted again to expand the file system to fill the 4Gb card.
Posts: 154
Joined: Wed Feb 01, 2012 9:48 am
by socialdefect » Tue Feb 05, 2013 4:38 pm
As far as I know there are no good/easy ways to do this from Windows for the EXT filesystem support for Win is quite unstable. Also Win does not recognize the Unix filesystem permissions so you will most likely end-up with an unbootable system or scrambled security/files/partitioning.

What you can do is:

0) ?? I might be wrong but I believe Gparted also has a migrate option ?? (won't take away the need to create an image backup though!!!)

1) Fast and Way Too Easy: Bribe someone who owns a Mac and use Disk Utility to make an image file > Partition the Image file so it will fit > Copy to new SD.

2) take a Linux liveCD/USB/SD/Whatever and boot your Pi or PC from it. > Use the dd command to create an image of your SD. > Partition the image using Gparted /dev/deviceName > use dd command to copy image to new SD card.

3) Boot your RaspberryPi and download the mkstage4 script. I never tried it on a RaspberryPi but I've used it successfully in lot's of Linux distributions. If you won't have to change the script a lot this is probably the fastest way with the least hocus pocus. It produces a compressed gzip or bzip archive that you can extract to a pre-formatted and mounted filesystem. You might have to make a backup of the FAT partition separately but those files you can just copy or zip. Only 'hard' part is copying the MBR to the new Disk.

DD examples: (DON'T Copy & Paste the complete commands below for you must replace /dev/something with the actual device or path on your system, If you're wrong here you might mess-up an entire hard drive's contents!!!)

Create raw image copy of a disk:
Code: Select all
sudo dd if=/dev/8gbsd of=/home/username/Backups/my-rpi-SD-image.img

Restore an image to disk:
Code: Select all
sudo dd if=/home/username/Backups/my-rpi-4GBSD-image.img of=/dev/4gbsd

Clone MBR + BootSector to a new drive:
Code: Select all
dd if=/dev/sdb of=/dev/sdc bs=512 count=2

To restore the MBR from a backup image you want to copy only the first 446 bytes:
Code: Select all
dd if=mbrbackup.img of=/dev/sdc bs=446 count=1

Clone only MBR from source disk to a new drive:
Code: Select all
dd if=/dev/sdb of=/dev/sdc bs=446 count=1
== If it's not broke... I'm not done fixing it! ==
User avatar
Posts: 108
Joined: Mon Jun 25, 2012 9:02 pm
Location: Tilburg, the Netherlands
by Dilligaf » Tue Feb 05, 2013 5:12 pm
The PI doesn't use or care about an MBR, it simply looks for the correct files on the first partition of the sd card.
Posts: 283
Joined: Wed May 23, 2012 6:48 pm
by SN » Tue Feb 05, 2013 8:02 pm
I just wrote a C prog which chops up the .img files - use gparted to reduced the partition to 4gb in size and then chop the first 4Gb off the .img file into another
Steve N – binatone mk4->intellivision->zx81->spectrum->cbm64->cpc6128->520stfm->pc->raspi ?
User avatar
Posts: 1011
Joined: Mon Feb 13, 2012 8:06 pm
Location: Romiley, UK
by JollyRoger » Wed Feb 06, 2013 2:31 pm
Your C prog sounds interesting, SN.

Another way of achieving all this (copying an image to a smaller sd card) is on this thread: viewtopic.php?f=66&t=17622
(see billw's entry dated 18 Sept). I've not tried his script.
Posts: 154
Joined: Wed Feb 01, 2012 9:48 am
by Daveawalker » Thu Mar 27, 2014 2:44 pm
This is a simple copier, and only a small download ... 0Setup.exe
It writes to smaller sd cards
Posts: 11
Joined: Fri Apr 26, 2013 3:26 pm
by 355/113 » Thu Mar 27, 2014 4:06 pm
Posts: 26
Joined: Wed Aug 22, 2012 2:22 am
by Wozik » Fri Feb 03, 2017 8:34 am
The easiest way, if you use Windows, is to use Paragon Backup & Recovery Free.

1. Backup your original SD card to VM (virtual disk).
2. Restore it to another card, could be a smaller one. The application will ask if the partitions should be shrinked proportionally.

I browsed A LOT of topics for this, the solution above is the easiest one that you can imagine.
Posts: 1
Joined: Fri Feb 03, 2017 8:32 am