Posts: 9
Joined: Tue Nov 26, 2013 8:14 am

how to shrink rootfs and img file

Mon May 19, 2014 5:35 am


I made a image with some programs in it for myself , that i want to back up .
How can i make the image smaller ?
I deleted all unneccesary programms from the original raspbian image and installed the programms i need . Here are my two problems :

The used space by the distro is now 1.59 GB but the root fs is about 4GB . how do i shrink that to the amount that is really used ? ( i only know how to expand rootfs)
I used win 32 diskmanager to create a img file , as it is a raw copy of the original 16GB SD card it uses 16 GB on the img file (instead of the 4 GB that the distro uses )

I tried googling but without success



Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5854
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: how to shrink rootfs and img file

Mon May 19, 2014 6:06 am

Lots of ways to go about it, but you'll want to use linux to do it. From easiest to hardest:
Use partimage - you won't get a .img file you can simply write back. You will need to use partimage to restore as well.
dd normally, then use shrink_image ( ) - You may need to modify the script to work with your distro.
Create a blank image of the required size, partition and format, mount and rsync into it
Shrink the filesystem on the card and only dd up to where you need to

Posts: 254
Joined: Thu May 17, 2012 1:25 am
Location: SW Missouri Ozarks
Contact: Website

Re: how to shrink rootfs and img file

Mon May 19, 2014 9:15 pm

Here's some instructions and scripts to help with this. They worked for me. ... 91&t=58069

Return to “General discussion”