This updated guide uses the pi-shrink script from GitHub instead of qemu-img for shrinking the .img. Pi-shrink intelligently compacts Raspberry Pi OS images by zeroing free space and resizing partitions/filesystems. Warning: These operations erase all data on the SD card (/dev/mmcblk0). Verify the device with lsblk first.
- Backup SD card data.
- Download
pi-shrink:git clone https://github.com/Drewsif/PiShrink.gitor grabpi-shrink.sh. - Make executable:
chmod +x PiShrink/pi-shrink.sh. - Have
.imgfile ready.