Create a service that I can enable and disable on a read only rootFs

Hello,

I have created a service that autostarts my application on a read only rootFS. I was wondering if there was a to create a service file that I can enable and disable.

On the other hand, Is there a way to not start the service on the first boot.

I have not tried to do anything to get enable/disable to work since it generally requires updating symlinks. Moving them into /data may work but that feels a bit invasive.

One way to not start the service is to make it conditional on the presence or absence of a file. You can touch a stamp file somewhere in /data to determine whether to actually start or not. https://serverfault.com/questions/767415/start-systemd-service-conditionally

Drew

You could also take a look at socket units, as one of the prime use cases is on-demand service starting.

1 Like

Sorry to re-open this… The main issue why I want to do this is, During the first boot my EXT4-fs resizes and that takes around 5 minutes or so. Right now my service starts after data.mount.service.

But is there somethings else that I should be doing so that It launches after the file system has expanded.
I see that there is a service dev-mmcblk0p4.device should I be waiting for this to finish or is there a other service that I should wait for before I start my service?

[Unit]
Description=AutoStart App
After=data.mount.service

[Service]
Type=simple
ExecStartPre=/data/Application/RepscrubsUI/Startup_scripts/Clean_Application.sh
ExecStart=/data/Application/RepscrubsUI/Startup_scripts/Startup_Script.sh
WatchdogSec=2min
NotifyAccess=all
Restart=always

[Install]
WantedBy=multi-user.target

look at creating a systemd dependency relationship between the service that resizes your filesystem and your service so that your service only starts after that service has completed.

I believe its the mender grow service

as itself has a dependency on being before data.mount then you should already be in good shape, although in your service file “data.mount.service” should be “data.mount”