PiShrink automatically shrink a Raspberry Pi image in order to reduce the final image size.
310
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.
IMPORTANT: This version includes a new option in order to keep ssh hostkeys if you want to remove logs, apt archives, etc. It´s very important if you only have remote access to the Rpi.
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 \
visolo/pishrink \
pishrink -pZv IMAGE.img NEW-IMAGE.img
If you run it on windows in PowerShell
docker run --privileged=true --rm `
--volume ${PWD}:/workdir `
mgomesborges/pishrink `
pishrink -pZv IMAGE.img NEW-IMAGE.img
pishrink [-adhrspPvzZ] IMAGE.img NEW-IMAGE.img
-s Do not expand filesystem when image is booted the first time
-v Enables more verbose output
-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
-p Remove logs, apt archives, dhcp leases and ssh hostkeys
-P Remove logs, apt archives, dhcp leases and KEEP ssh hostkeys [NEW]
-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.
Content type
Image
Digest
sha256:295810142…
Size
33.4 MB
Last updated
over 3 years ago
docker pull visolo/pishrink