A bash script that automatically shrinks Raspberry Pi disk images and enables auto-resizing on first boot.
PiShrink is a bash script that automatically shrinks Raspberry Pi disk images by removing unused space and configures them to expand to the full SD card size on first boot. It solves the problem of large, bloated Pi images that take longer to write and transfer, while also supporting compression to create even smaller archives.
Raspberry Pi users, embedded developers, and system administrators who frequently flash SD cards and need to optimize image storage and transfer times.
Developers choose PiShrink because it automates the tedious process of manually shrinking Pi images, saves storage space, speeds up SD card writing, and works across multiple platforms with simple command-line usage.
Make your pi images smaller!
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Trims unused filesystem space to significantly shrink image size, as demonstrated in the example where a 30G image is reduced to 3.1G.
Configures images to automatically expand to full SD card capacity on first boot, eliminating manual partition adjustments after flashing.
Supports optional gzip or xz compression with parallel processing via pigz and xz, enabling smaller archives and faster compression times.
Works on Linux, Windows via WSL, and macOS via Docker, making it usable across different operating systems with documented setup steps.
Only shrinks the last partition if it's ext2, ext3, or ext4; other filesystems like FAT or NTFS are not supported, restricting its utility.
Requires installing WSL on Windows or Docker on macOS, adding complexity compared to native Linux usage where tools are readily available.
Auto-resizing on Systemd-based distros depends on enabling rc.local compatibility, an extra step that may not be well-documented or intuitive.