pishrink
manipulates existing Raspbian image files, it doesn't create or extract them from an sd card.
The process of reading an image from an sd card as well as writing an image to an sd card has to be performed separately.
You may create such an image file by your favourite sd card imaging tool, e.g. using dd or Balena Etcher or Win32 Disk Imager or whatever tool you prefer.
I'd recommend to extract the image file to a hard drive.
Also, consider running sudo apt-get autoclean
and sudo apt-get clean
on the sd card OS before you extract an image.
This will remove packages from your apt cache, saving some additional space later at the cost of having to download stuff again if you choose to reinstall or reconfigure a package.
can you use the script directly from the pi?
Yes, I've sucessfully run pishrink
on Raspbian image files under Raspbian Buster in my RPis as well as under GParted Live on my PC.
While there is no notable performance difference when using pishrink
in its default mode, it will typically take significantly longer on an RPi when using some of the advanced options.
the image is created to a new location on the pi local SD card?
No, pishrink
will alter the existing file by default.
This is also the fastest way to run pishrink
: It completes in about 30 seconds for a 15G image.
Though it's usually safe to do so, it's always wise to create a backup copy just in case.
If you decide to provide a target file as second parameter, it can create a new file at that location.
It will do so by first copying the file to that location and then apply its shrinking to that copy.
Note that copying a file with an RPi may take quite a while when you are using the internal sd card or a USB hard drive, e.g. copying a 15G file on a USB drive to another location on the same drive may take over 10 minutes when attached to USB2 or still around 3 minutes via USB3.
Running pishrink on a PC, copying usually is even faster than USB3, especially if you are using an SSD.
How would the restore process be performed?
With the same preferred imaging tool of yours that was used to extract the image, presumably.
I've been using pishrink
for my Raspbian -pardon me: Raspberry Pi OS- images for all my RPi projects.
As NOOBS partition layout differs significantly from Raspberry Pi OS, pishrink
would have refused to operate on respective images in the past, but has started to support NOOBS as well recently.
However, I personally have never tried to use it with images based on NOOBS.