Some time ago I set up a Raspberry and expanded the filesystem to 16GB. Unfortunately I wanted to share the Image afterwards. I tried to reduce the size the easy way and succeeded. Procecure was:
– Created the *.img from the SD-Card of Raspberry via Win32Imager (via Read function)
– Copied the big *.img to a USB Stick (32 GB)
– Created Linux Live CD (Linux Mint) and wrote it to a USB-Stick to boot from it afterwards
– of course also plugged in the USB Stick with the img
– mounted the USB Drive and opened a Console and changed the dir (cd) where the image is
After booting into Linux Mint
– I installed quemu utils via
sudo apt-get install qemu-utils
– checked the img via
fdisk -l image.img
I saw that there are 2 partitions holding only 2,1 Gigs so I did
qemu-img resize vdisk.img 3GB
afterwards I wrote the img to an SD-Card and booted it successfully in a RPI3
Alternative would be: https://www.instructables.com/id/How-to-BackUp-and-Shrink-Your-Raspberry-Pi-Image/