For example, an SD card with only 4GB of data may still produce a 32GB image file because empty space is included in the backup.
A useful solution for this is PiShrink.
PiShrink shrinks the Linux partition inside the image and removes unused space, significantly reducing the final image size without deleting data.
It can also be used on Windows through WSL (Windows Subsystem for Linux).
Basic workflow:
- Install WSL with Ubuntu
- Move the Raspberry Pi image into the Linux environment
- Clone PiShrink from GitHub:
git clone https://github.com/Drewsif/PiShrink.git
- Enter the project directory:
cd PiShrink
- Give execute permission to the script:
chmod +x pishrink.sh
- Run the script:
sudo ./pishrink.sh your_image.img
After processing, image sizes can be reduced dramatically depending on the amount of used space.
PiShrink is especially useful for Raspberry Pi backup, archive, and image distribution workflows.



