Shrink Raspberry Pi SD-card images with PiShrink Location: /opt/scripts/pishrink.sh (April 2018) Purpose A copy of the open-source PiShrink tool. It shrinks a Raspberry Pi SD-card image ( .img ) to the smallest size its root filesystem allows. Unless you pass -s , it also sets the Pi to grow the filesystem back to full size on first boot. How it runs By hand, as root. Usage sudo /opt/scripts/pishrink.sh pi-backup.img # shrink in place sudo /opt/scripts/pishrink.sh -s pi-backup.img small.img # copy first, no auto-expand Dependencies parted , losetup , tune2fs , e2fsck , resize2fs , md5sum , which . What it touches Only the image file. It attaches a loop device, mounts the image in a temporary folder, and may replace /etc/rc.local inside the image.