eventually found out that to be able to see the win10 shared folder in the uBuntu virtualbox, I had to open the win10 'Windows Features' and enable 'SMB', followed by a restart.
After that I was able to use PiShrink to reduce the image size, write back to a blank 16gb SD card, insert in the Pi, and it self-expanded when used.
Pi Shrink process
Here's the process that I used. I hope it helps someone.
I have a Windows PC ( laptop ) and needed to shrink the size of my 32Gb disk image file ( SD card for OMV on Pi4 ).
It is a known fact that not all SD cards of equal 'size' are actually the same identical size, so an img file of one card may not fit on another card.
This solution allows you to shrink the size of the primary partition in the SD card image file, and it will automatically expand itself to whatever size card you write the img file back on to.
So, in my case, the 32 Gb SD card is shrunk to 7 Gb.
When written to a 16 Gb SD card and loaded in the Pi, the partition automatically expands to fill the 16 Gb.
On my win10 PC : Installed VirtualBox
downloaded ubuntu-22.10-desktop-amd64.iso iso disk image from here :
Created D:\PiBackup and made it a Shared folder
Download and install win32diskImager
use win32diskImager to copy the existing active SD card to D:\PiBackup as an image .img file
Started VirtualBox
Add a New machine
Type : Linux
Version : Ubuntu (64 bit)
Set Memory to around 6000Mb ( win host system has 16gb RAM )
Create a Virtual Disk
File Location : make sure location has free disk space
File Size 45 Gb ( enough space for the ubuntu / Pi OS and also the SD card disk image )
Network : changed NAT to Bridged -- otherwise I couldn't see the shared folders to transfer the files to and from Linux.
In Win10, I also had to open 'Windows Features' and enable 'SMB' - required a restart of windows
Start the Virtual Machine
It will start and begin the installation of Linux from the iso disk image
Long wait while installation happens
on my PC, I have a network shared folder : D:\PiBackup
Save the following script lines to a txt file and save or copy in to the shared ( Documents ) folder.
<start of code to copy>
Install pishrink ( if not already installed )
----------------
wget https://raw.githubusercontent.…Shrink/master/pishrink.sh
chmod +x pishrink.sh
sudo mv pishrink.sh /usr/local/bin
Run pishrink to shrink the img file :
-------------------------------------
sudo pishrink.sh 20180316_octopi_DaveOB.img ( change 20180316_octopi_DaveOB to the name that you saved the SD image from the SD to the PC )
<end of code to copy>
When Linux installation is complete, click on Restart
Wait for the Linux desktop
Once loaded, we need to copy the txt file and the SD img file from the win10 shared folder to the Linux machine :
On The uBuntu desktop - on the left, go to Files
Other Locations
Windows Network
Workgroup
Dave_Laptop ( that's my laptops name on the network - yours would be different )
Login with your windows username and windows login password
Documents ( or whatever you named the folder that you shared in Windows )
You should now see the txt and the img files.
Right Click on the txt file and Click on Copy.
Then change location, on the left panel, to the Linux 'Downloads' folder.
Right Click and Paste
You should now have a copy of the txt file in the Linux Downloads folder.
Do the same process for the img file
NOTE : the 32Gb image file does take quite a while to copy. watch the progress bar that appears on top of the 'files' icon on the left panel. Wait for it to complete. Mine took a good 40 minutes to copy.
during the next stage, i did get an error message : user not in sudoers file
What it means is that your user name is not yet permitted to execute sudo ( admin level ) commands.
To prevent this, you can add your username to the sudoers file :
I added : vboxuser ALL=(ALL) ALL
Next, you need to download and install the PiShrink app ( once off operation ).
Right Click on the txt file and open it in the default text reader / notepad
Find the line that starts with 'wget', highlight the line, right click and Copy.
Click on the File icon to display the file manager again.
Right Click on the blank area below the txt and img files, and select 'Open in Terminal'
The terminal will open ( looks like a DOS prompt Cmd screen )
Right Click and Paste
The wget line will be pasted - hit Enter to execute the line.
Repeat this for each of the other 2 lines from the txt file.
Once done, you're ready to shrink the img file.
from the txt file, highlight and copy the line
sudo pishrink.sh 20180316_octopi_DaveOB.img ( change the '20180316_octopi_DaveOB' to the file name of your img file )
Press enter to execute the script.
Once it is done, close the Terminal window and refresh ( F5 ) the file manager window.
Right Click on the img file, properties, and you should see the new size of the img file.
Close the properties window.
Last thing is to copy the smaller img file back to your windows folder.
If you want to keep the original file, you can rename the smaller img file before copying it back.
Right Click on the file and Copy
On the left panel, go to the shared Documents folder, right Click and Paste.
Give it time to complete the copy process.
After you use Win32DiskImager to write the img file to your new SD card and insert in to the Pi and boot up, give it additional time for the first run, as it has to then expand the primary partition to fill the disk.
Done.