ferguman / fopd

farm operation platform device (fopd)
MIT License
3 stars 0 forks source link

The mender image is not resizing the data file system to fill the unused SD space #12

Closed ferguman closed 4 years ago

ferguman commented 4 years ago

Mender images contain a service name resizefs (at /lib/systemd/system/resizefs.service) that is meant to check that the filesystem located on the data partition (e.g. /dev/mmcbk0p4) is sized to take up all the space available on the partition. This service is not working for the current fopd systems.

The service calls a shell script named resizefs.sh (ExecStart=/bin/sh -c 'sleep 1 ; /usr/sbin/resizefs.sh start').

I tested the commands contained in the service on a fopd where the /data filesystem was smaller than the size of its partition. The script was calculating that there was no free space for the file system to expand into.

Without understanding why the current script doesn't work I ask myself why can't one simply run resize2fs on the file system mounted at /data at the first time the mender image boots without bothering to do any calculations to determine whether it needs to be run or not? Won't resize2fs be doing the same calculations when it runs:

sudo resize2fs /dev/mmcblk0p4
resize2fs 1.44.5 (15-Dec-2018)
The filesystem is already 3002368 (1k) blocks long.  Nothing to do!
ferguman commented 4 years ago

I wonder about this line in the script: DATA_PART_SIZE=$(blockdev --getsize $DATA_PART_DEV) - Isn't this calculating the size of the partition (and not the filesystem). Should a command like the following be used: sudo dumpe2fs -h /dev/mmcblk0p4 - This command accurately returned the information necessary to calculate the unused partition space on my test fopd system.

ferguman commented 4 years ago

I added a initialize function to fopd that will resize the data partition. The resize function is idempotent so it can be run any time.

ferguman commented 4 years ago

Use the initilization function for the time being