Before I test your script, I was wondering if you spotted a “reverse” script that takes an SD card and created a minimum image? I was able to uninstall a lot of stuff that I will not use. Looks like I am down to a little over 3G used on my SD cards out of 32G. So I did try normal router I did "compacting it with dd to image, mount it as a loop device, resize with gparted and finally use truncate utility.
This does not work with NVIDIA images. Looks like there are few posts about that I did not check earlier.
I also found this post that I am trying to see if it works.
Did you spot any script that would automate machining minimal image and then use your resize script in a first boot?
Actually, can your resize script be executed on the first run rc.local?
Or is it meant for resizing it on another host?
Are you running it after booting? Or you insert an SD card to your workstation and then run the script on /dev/sd* ?