Tested on:Kubuntu 15.1
Hardware:Host computer with Linux
Card reader and SD card with data
0

How to shrink Raspberry Pi SD card images with GParted and dd

When working with a Raspberry Pi, it is good practise to backup a projects’ progress in form of disk images frequently. A common problem when doing this is the size difference of SD cards with the same label (e.g. 8Gb) but a slightly different real size. Gnome-disks and other imaging tools can’t write an image to a smaller SD card.
To circumvent this, it’s possible to use GParted and dd to create an image with a reduced size.

Disclaimer
Shrinking the partition below its required size leads to data losses. Make always backups before working with partitions!

Install GParted
Start with attaching the SD card of interest to the host computer and installing GParted. GParted is a great freeware disk partitioning tool and has to be installed on the host computer with

Then, start the GUI with

As a first step, it is necessary to reduce the partition size. Select your sd card in the menu marked red in this screenshot:

Gparted Menu

Gparted Menu

Then, select the largest partition with a left click, right click on that partition and select Resize/Move. The menu looks like this:
GParted resize menu

GParted resize menu

Choose as New size a number a bit below the count variable (size in Mb the image will have) from the dd command in the next step.

Create a shrinked disk image with dd
The following command executed in the hosts’ terminal creates a shrinked disk image:

This is for the SD card specified with sdd. sdd has a size of 8Gb, but the image will have a size of count=7000 Mb and can be installed on any card greater than 7 Gb.

Links
Creating disk images with gnome-disks: http://www.knight-of-pi.org/sdisk-images-for-complex-rapberry-pi-projects/
GParted Website: http://gparted.org
dd on Wikipedia: https://en.wikipedia.org/wiki/Dd_%28Unix%29
Disk Image on Wikipedia: https://en.wikipedia.org/wiki/Disk_image
Tutorial: Burn a disk image to a SD card: http://www.knight-of-pi.org/installation/

Knight of Pi

Johannes Bergs aka Knight of Pi. Diploma in Bioinformatics, some Webdesign and Python coding then. Living in the beautiful city of Vienna.

Comment

Time limit is exhausted. Please reload CAPTCHA.