Question… I finally got everything set up exactly how I want and it’s running great. I used a 128GB memory card but do not need all that space. Is there a way to compress the image somehow so I can copy it over to a 32GB card? My current setup uses much less than 32GB.
When I did the initial installation I remember having to expand the image to account for the extra space in the memory card - so I guess now I want to reverse this process. As usual assume I know nothing LOL.
Thanks!
I've done this a bunch of times so will chime in to assist.
You can use the "pishrink" utility from
https://github.com/Drewsif/PiShrinkYou will need a USB storage device of greater capacity than the used space on the SD card you are attempting to shrink. EDIT: We will copy over the used space to an external USB storage device and then shrink it down as small as possible.
Steps to prepare the USB flash drive. It will be mounted to pi as a working area for performing the shrink.
* Format your USB flash drive as NTFS (assuming you are on Windows). Give the volume the name "USB". It will help us to identify the device when we mount it to the pi.
* Connect USB drive to your pi.
* Boot pi with SD card you want to shrink inserted
* Verify USB mounted. Your USB drive should be automatically mounted at /media/pi/USB. I don't have the appliance at the moment so can't be 100%. Give it a try.
dir /media/pi/USB
* if not found then you can query mount points using command
lsblk
Steps for the shrinking.* Install pishrink utility
wget https://raw.githubusercontent.com/Drewsif/PiShrink/master/pishrink.sh
chmod +x pishrink.sh
sudo mv pishrink.sh /usr/local/bin
* We now make a copy of the used allocation of your SD card. You should specify a slightly larger size to be safe, so if you've used 7.5GB of space I would round to 8GB (8000 blocks). Set the count= argument accordingly.
sudo dd if=/dev/mmcblk0 of=/media/pi/USB/shrunk_my_junk.img bs=1M count=8000
* All being well an image file was created on the USB drive. If the above command returns an error then increase the count and try again.
cd /media/pi/USB
dir
* Now we can shrinkify that image
sudo pishrink.sh -z shrunk_my_junk.img
That's it.
You should now have a shrunken image on your USB drive which you can copy to your PC and write to a smaller SD card.
Hope if works out for you.