Skip to content

Resize Raspberry Pi SD Card Image

I had the need to shrink a 16GB microSD card to use the image on my other Raspberry Pi, but only had smaller SD Cards lying around. So what now?

After a lot of tests and googling i found a way to get this working on my Mac OSX.

Things you need:

  • Apple Pi Baker
  • gParted Live Image
  • CD Burner and empty CD or an USB Stick with at least 256 MB
  • big SD Card containing current Raspberry Pi image
  • smaller SD Card (2GB, 4GB, …)

Apple Pi Baker is a GUI to copy Raspberry Pi or other .img files to a SD card or USB stick, like using dd from command line, but with the advantage of using a GUI and displaying the time remaining for the process to finish. Additionally you can use it to create a .img from a SD card (backup) or create a Raspberry Pi NOOB SD card.

Part I: gParted

Download gParted live image from

When using a USB drive:

  • convert the downloaded .iso to a .img in the directory containing the .iso with this Terminal command:
hdiutil convert source.iso -format UDRW -o destination.img
  • then use Apple Pi Baker to copy the gParted.img to the USB Stick

When using a CD:

  • open the .iso in Disk Utility
  • Burn this image

Then connect the USB stick to a Mac or PC and boot from the USB stick (or boot from the CD).

Start gParted an then select the SD card (on Mac you will need to use a USB SD card reader as the internal SD card reader is not supported) and select the second (big) EXT4 partition and resize it to a bit bigger than the minimum size or a little bit smaller than the desired SD card size (1.9 GB for a 2 GB SD card).

eject the SD card and / or restart your computer.

Part II: create card image and restore

Use Apple Pi Baker to backup your (big) SD card. This will create a image in the size of the card, not in the size of your shrinked image! 

The trick is to restore this image to the smaller SD card. This will work, because you shrinked all partitions below the size of your (smaller) SD card. Apple Pi Baker will diskplay a warning that the image is to big to restore to the SD card, but it will stop when the card is full.

Now we have the smaller SD card and we’re almost finished.

Part III: fix the SD card

Now insert the smaller SD card into your Raspberry Pi and power it on to boot.

Booting will fail as fsck will fail to repair the card automatically. But pressing CRTL-D to continue will fix the problem and reboot the Raspberry.

Part IV: backup the smaller SD card (optional)

Now it’s a good idea to backup the small SD card to a now smaller .img because the backup will always have the size of the card used. Use Apple Pi Baker for this again.

To fill the whole SD card use this command in the Terminal of your gParted Live CD / USB stick, where XXX is the name of the SD card (eg. /dev/sdc2):

# resize2fs /dev/XXX

5 thoughts on “Resize Raspberry Pi SD Card Image”

  1. You are the best! I ran exactly into this problem because I did a backup image from a 32 GB Sandisk, whereas another 32 GB Sandisk purchased later actually had 800 MB less. This saved my configuration, thanks so much! In my case Part III was not happening, but Retropie 4.1 immediately booted into the system without errors. All fine.

    Viele Grüße aus Wien, vielen Dank 🙂

  2. i just gave it a try and you’re correct, ist creates a *.img.dmg file. I just renamed it to *.img and that worked as both formats are the same, MacOS just adds its dmg extension to the name. ApplePi Baker doesn’t allow to select files with .dmg ending.

  3. Didn’t work for me : kernel panic : unable to mount fs on unknown block 🙁

  4. Thanks this worked a treat! One tip, it took me a while to realise I needed to boot my Mac from the gParted USB to use it. Maybe add that as point. I’m sure it’s cause I’m stupid but I’m not the only one…

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.