I have had a chance to try this out and the sizes above are not correct. This added to the init_resize.sh
script will work.
#EmonSD Fix end of Rootfs
if [ $ROOT_DEV_SIZE -gt 16000000 ]; then
#16GB card or above, assign last 10GB for data
TARGET_END=$(($ROOT_DEV_SIZE - 20972544 - 1 ))
elif [ $ROOT_DEV_SIZE -gt 8000000 ]; then
#8GB card, assign last 4GB for data
TARGET_END=$(($ROOT_DEV_SIZE - 7341056 - 1 ))
fi
The original sizes I proposed did not align optimally.
For future ref, the key figure is 2048. parted
wants the start of a partition to start on a multiple of 2048. Because of the calculation, and the fact the whole SD card is not a multiple of 2048, this caused a problem as the rootfs did not finish on a 2048 boundary.
The Ext2 partition is not a multiple of 2048 (it doesn’t need to be).
I am, however, not convinced this is robust for all SD cards - it assumes that the whole card is not a multiple of 2048 - I hate assumptions!
Can anyone suggest a way in bash to check the alignment figure?