PiShrink automatically shrink a Raspberry Pi image in order to reduce the final image size.
It's great for saving disk space or sharing your Pi image on the Internet.
This project is a dockerized version of the PiShrink bash script by Drew Bonasera.
-
Make a copy of a Raspberry Pi SD card that you want to shrink (see instructions here).
-
Using the Terminal, access the directory containing the Raspberry Pi image:
cd ~/Directory-with-RPi-image
-
Run PiShrink dockerized:
docker run --privileged=true --rm \ --volume $(pwd):/workdir \ monsieurborges/pishrink \ pishrink -Zv IMAGE.img NEW-IMAGE.img
pishrink [-adhrsvzZ] IMAGE.img NEW-IMAGE.img
-s Don't expand filesystem when image is booted the first time
-v Be verbose
-n Disable automatic update checking
-r Use advanced filesystem repair option if the normal one fails
-z Compress image after shrinking with gzip
-Z Compress image after shrinking with xz
-a Compress image in parallel using multiple cores
-d Write debug messages in a debug log file
If you specify the NEW-IMAGE.img
parameter, the script will make a copy of IMAGE.img
and work off that. You will need enough space to make a full copy of the image to use that option.
Check out PiShrink GitHub for more details.
The source code is licensed under the MIT license.
The content of this project itself is licensed under the Creative Commons Attribution 4.0 International.