All,

I want to convert the growroot functionality to a proper systemd service but I'm struggling. I (think I) want it to run and finish before the filesystems are checked and before /sysroot is mounted. For testing purposes, I replaced the growroot script with a simple script that sleeps for 5 seconds and emits debug messages at the beginning and at the end. What I end up with is that fsck is started before growroot and I can't seem to figure out why that is. What I have at the moment is:

[Unit]
Description=Grow the root partition
After=systemd-readahead-collect.service systemd-readahead-replay.service
Before=systemd-fsck@.service sysroot.mount

[Service]
Type=oneshot
ExecStart=/bin/growroot
StandardOutput=syslog+console
StandardError=syslog+console
RemainAfterExit=yes

And the log:

[  OK  ] Reached target System Initialization.
[  OK  ] Found device /dev/disk/by-uuid/d349e793-8c72-4696-ada5-d137ce999ce8.
         Starting File System Check on /dev/disk/by-uuid/d349...d137ce999ce8...
[  OK  ] Started dracut initqueue hook.
[  OK  ] Reached target Remote File Systems (Pre).
[  OK  ] Reached target Remote File Systems.
[  OK  ] Started Show Plymouth Boot Screen.
[  OK  ] Reached target Paths.
[  OK  ] Reached target Basic System.
         Starting Grow the root partition...
[   11.921184] systemd-fsck[130]: root: clean, 22930/589824 files, 318802/2359296 blocks
[   11.925470] growroot[139]: Start
[  OK  ] Started File System Check on /dev/disk/by-uuid/d349e...5-d137ce999ce8.
[   15.102699] systemd-udevd (96) used greatest stack depth: 12104 bytes left
[   16.917436] growroot[139]: Stop
[  OK  ] Started Grow the root partition.
         Mounting /sysroot...
[   17.008583] EXT4-fs (vda1): mounted filesystem with ordered data mode. Opts: (null)
[  OK  ] Mounted /sysroot.
[  OK  ] Reached target Initrd Root File System.

What am I missing?

Also, I suspect I need to add this service to a target unit. What would be the most appropriate one? Currently it's initrd.target.

Thanks
...Juerg