Adding expand filesystem unit at boot

Hi folks

I want to expand the filesystem at boot with a systemd-unit and “growpart” and “xfs_growfs”. For this it need a anchor point at boot with fully initialized disk and all mounted disks. Does anyone know how “Before” and/or “After” need to be write to call such tools?
The following doesn’t work:

variant: fcos
version: 1.0.0 
systemd:
  units:
    - name: extend-filesystems.service
      enabled: true
      contents: |
        [Unit]
        Description=Extend Filesystems
        After=ignition-files.service

        [Service]
        Type=oneshot
        RemainAfterExit=no
        ExecStart=/usr/local/bin/extend-data-filesystems
        StandardOutput=journal+console

I’m not an FCOS / ignition expert, but my guess would be that your unit has no [WantedBy] declaration, thus the service can’t be enabled. Try adding this to the end of your unit:

        [Install]
        WantedBy=multi-user.target

Also, your After= is a bit…odd. ignition-files.service is run inside the initramfs, whereas I don’t believe the units you add with Ignition are added inside the initramfs but rather onto the base system. Therefore, you might want to just drop that line altogether; by the time any services on the rootfs are run, all the partitions have been already mounted.

One more note, RemainAfterExit=no is the default, you can drop that.

1 Like