Using PiShrink on Windows to shrink your Fruitbox Pi image

For anyone interested in using PiShrink, you can use it in Windows if you install WSL 2. Of course you can use it the way it was intended – in a regular Linux installation or even on a Raspberry Pi, but the target audience for this guide are Windows users.

Why do this? So you can make a copy of your 4gb, 8gb, 16gb, 32gb, 64gb, 128gb, 256gb, ETCgb sd card and shrink it, and store it locally on your PC without eating up all that space. PiShrink will shrink your pi image dramatically reducing the space it would normally take up. It’s nice to have a back-up of your hard work handily available in case of disaster. The following steps will show you how to do it. You’ll need to visit the links for some of the finer details.

1.Use Win32 disk imager to copy your pi sd card image to Windows. Make sure you have enough space on your HDD first. https://raspberrytips.com/create-image-sd-card/ (See my note below if you have trouble getting Win 32 disk imager to open.)

2. Install WSL 2 – https://docs.microsoft.com/en-us/windows/wsl/install-win10

3. Install and start Debian. You will need to define a user and password – https://www.microsoft.com/store/productId/9MSVKQC78PK6

4.Install dependencies and PiShrink *(source = https://github.com/Drewsif/PiShrink/issues/78#issuecomment-771635732)

Ensure you are in a Windows WSL Debian terminal and type sudo apt update && sudo apt -y dist-upgrade and press enter. *To open a WSL terminal from windows, open a PowerShell terminal and type wsl. If you have more than one flavor of Linux installed, type wsl -d Debian

Next, type sudo apt install -y git partedand press enter.

Next, type git clone https://github.com/Drewsif/PiShrink.git and press enter.

Next, type sudo chmod +x PiShrink/pishrink.sh and press enter.

Next, type sudo cp PiShrink/pishrink.sh /usr/local/bin and press enter.

Next, type sudo ln -s /proc/mounts /etc/mtab and press enter.

Now you can shrink your image, e.g. sudo pishrink.sh bigFile.img smallFile.img *Step 5 goes over this in more detail, bigFile.img being the original filename and smallFile.img being the destination filename

5. Copy (windows drag and drop) the image you created with Win32 disk imager from step 1 into the \\wsl.localhost\Debian\home\(username) folder and run sudo pishrink.sh (filename).img (newfilename).img Example: in an explorer window, open \\wsl.localhost\Debian\home\jays\ *(this will be your user directory and unique to your system) and drag and drop the image into this folder. Open your WSL terminal and run sudo pishrink.sh Fruitbox.img Fruitbox-small.img *To open a WSL terminal from windows, open a PowerShell terminal and type wsl. If you have more than one flavor of Linux installed, type wsl -d Debian

6.Once Pishrink is finished, you can further shrink the image with 7zip. https://youtu.be/5pdgO3Ncl6k?t=174 You can ignore the earlier part of the video regarding using a virtual box VM (I had trouble getting it to run this way). WSL is much easier to use these days – there is some good info on using Win32 disk imager at the start of the video as well.

7. To write the image, you can use Win32 disk imager, Balena Etcher or the official Raspberry Pi imager software. On first boot, the image might be a little slow as it expands the filesystem on your sd card.

*A note about the Win32 disk imager software. If you find that it will not open after you install it, you might need to temporarily disable any cloud services you have running (Google Drive, Dropbox, etc). Something about Win32 disk imager conflicts with cloud service software and temporarily closing these programs will allow the software to open.

**If you store your music or a lot of other files directly on the pi, your results will not be as dramatic. This is a good reason to store and play your music separately from a thumb drive.