Only works on linux. I've repeatedly tried to find a sequence that works on macOS but haven't had any success.
This script will remove empty space from the backup img which ensures that you'll be able to write the img back out to an SD card that's the same size as the source SD card.
git clone https://github.com/Drewsif/PiShrink.git
# install PiShrink dependencies (per the PiShrink docs)
sudo apt update && sudo apt install -y wget parted gzip pigz xz-utils udev e2fsprogs# List all the disks (sd card is usually /dev/sdb on my system)
lsblk -p
# Unmount the sd card, if necessary
sudo umount /dev/sdb
# Do a full uncompressed clone
sudo dd if=/dev/sdb bs=4M of=seedsigner_dev_2025-10-25.img status=progress conv=fsync./PiShrink/pishrink.sh seedsigner_dev_2025-10-25.img seedsigner_dev_2025-10-25_shrunk.imgSwap the target SD card in (double check the disk name) and then flash it:
sudo dd if=seedsigner_dev_2025-10-25_shrunk.img bs=4M of=/dev/sdb status=progress conv=fsyncNote: Raspberry Pi Imager or Balena Etcher should also be able to use the shrunk img to flash to a new SD card, but I haven't tried.
Delete the full-sized img.