I almost never do flash (new) images, most installations are many years old and dist-upgraded in-place. And if I use a fresh downloaded image for testing or so, I am usually too late to prevent auto-expand, so indeed fix afterwards.I have spend a day of flashing and tweaking, and reflashing again trying to sort this out. "The damage is done" is not a problem to reflash and try again. My daily driver is linux so mods requiring linux is no problem. I didnt really follow your instructions sorry. But it sounds like the just of it is to let it expand, then try shrink it later on using gdisk (sounds like ubuntu).There are other init resize scripts that offer more advanced options like the one in Armbian, that would enabled you to do want you want. But the 'damage' is already done, so you need to manually shrink.
In both fstab and cmdline.txt I changed from method PARTUUID to UUID, or even LABEL. Then in another Linux box do the filesystem shrink and partitions reorganization. I use gdisk, so GPT not MBR.
You can stick to Ext4, but I do run btrfs-convert --uuid copy --copy-label on the rootfs partition, then you can do the rest all online in the running Pi itself.You need additional changes in the fstab and cmdline.txt (btrfs instead of ext4).
You need resize2fs tool, see its manual. I can't help you with the RPi init resize script, never looked at it in detail, I only tried to get rid of it.
Statistics: Posted by redvli — Thu Jan 02, 2025 5:23 pm