Thanks again for the update. I didn’t find the time to continue this project until now.
Looking at the approach mender takes to resize the partition I found what I believe to be the issue on at least my machine.
Mender uses parted to try to resize the partition, meta-mender/mender-client-resize-data-part.sh.in at 1dbb4b07a057045b4b60e26a5eefcac764abb7c4 · mendersoftware/meta-mender · GitHub , but at least on my machine this will fail. When I run this by hand the following output is generated and no change is applied to the data partition.
sudo parted -s /dev/sda resizepart 4 100%
Warning: Partition /dev/sda4 is being used. Are you sure you want to continue?
My assumption is that message is silently ignored during the system boot and meta-mender/mender-systemd-growfs-data.service at 1dbb4b07a057045b4b60e26a5eefcac764abb7c4 · mendersoftware/meta-mender · GitHub tries to expand the file system accordingly. It even reports that it successfully grew to 512MB, which was the original size anyway.
My first assumption was to just make sure to unmount /data before we try parted, but that fails as mender is actively using the partition now. It might work during boot, not sure.
sudo lsof /data/
[sudo] password for adev:
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
Output information may be incomplete.
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mender 1194 root mem REG 8,4 12288 16 /data/mender/mender-store
mender 1194 root mem-r REG 8,4 8192 15 /data/mender/mender-store-lock
mender 1194 root 7ur REG 8,4 8192 15 /data/mender/mender-store-lock
mender 1194 root 8u REG 8,4 12288 16 /data/mender/mender-store
mender 1194 root 9u REG 8,4 12288 16 /data/mender/mender-store
Resorting to the tool growpart I was then able to resize the /data partition even while it was mounted.
sudo growpart /dev/sda 4
CHANGED: partition=4 start=85966848 old: size=1048576 end=87015424 new: size=414151311 end=500118159
sudo partprobe
sudo /lib/systemd/systemd-growfs /data
Successfully resized "/data" to 197.4G bytes (3584 bytes lost due to blocksize).
And now I’m ready to integrate this into mender-convert I guess.
Judging by this config mender-convert/raspberrypi_raspbian_config at 5cc9cf5a45066855800e2e939b067ed52fc24567 · mendersoftware/mender-convert · GitHub it looks to me that I can just override the grow_data_partition function with the commands I found working for me.
I guess some more testing on my machine and then I should be ready to open a PR to propose the use of growpart instead of parted. Maybe this is of some interest to others.