Tuesday, June 18, 2019

PiShrink, Move from a large SD card to a smaller SD Card

Initially my Raspberry Pi was using a 32GB SD Card for its Raspbian installation.  Since the device is only using for testing, it is a bit of a waste to run the OS on a large SD card.  Hence, I am looking for a solution to clone the disk to a smaller SD Card.  At the end, I found this nice little script called PiShrink from this blog, https://community.octoprint.org/t/pishrink-an-sd-card-backup/1791

The steps are very simple.  You first create an image file from your SD Card.  You can use good old dd command or like myself use the Disks utility comes with my Mint Linux Cinnamon installation.  Then you run the script against your image.  Finally, you restore your image back to the smaller disk with your favorite imaging tool such as dd or Disks.

Here is an example of using PiShrink

wget https://raw.githubusercontent.com/Drewsif/PiShrink/master/pishrink.sh

chmod +x pishrink.sh
sudo ./pishrink.sh raspbian_full.img