The root file system size is only ~600 MiB or so on first boot, based on the minimal possible reduction, so you cannot shrink it further before first boot.
On first boot the partition first and the filesystem second, is then maximised to fill the size of the underlying disk automatically. It would be possible to prevent that, but that makes the first run setup break which requires additional space already. So I'd leave that in place.
So you need to shrink the partition and filesystem afterwards, from an external system, as mounted filesystems cannot be shrunken. Start with the filesystem:
Assuming the root partition is /dev/sdb2, using 40 GiB (given in 4k blocks).
Then reduce the partition size
Code: Select all
sfdisk --no-reread --no-tell-kernel -fN2 /dev/sdb <<< ',83886080'
With 40 GiB given in 512 byte sectors.
On the other hand, if you're able to edit the ext4 partition prior to first boot, you can edit the expansion script directly:
https://github.com/MichaIng/DietPi/blob ... ize.sh#L42
https://github.com/MichaIng/DietPi/blob ... ize.sh#L55