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

**URL:** <https://hub.mender.io/t/create-a-service-that-i-can-enable-and-disable-on-a-read-only-rootfs/2444>\
**Category:** General Discussions\
**Tags:** yocto, raspberry-pi-3, warrior\
**Created:** [September 14, 2020, 3:17pm UTC](https://hub.mender.io/t/create-a-service-that-i-can-enable-and-disable-on-a-read-only-rootfs/2444 "2020-09-14T15:17:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![thesillywhat](https://avatars.discourse-cdn.com/v4/letter/t/57b2e6/32.png) [@thesillywhat](https://hub.mender.io/u/thesillywhat)\
**Post date:** [September 14, 2020, 3:17pm UTC](https://hub.mender.io/t/create-a-service-that-i-can-enable-and-disable-on-a-read-only-rootfs/2444/1 "2020-09-14T15:17:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [September 14, 2020, 8:58pm UTC](https://hub.mender.io/t/create-a-service-that-i-can-enable-and-disable-on-a-read-only-rootfs/2444/2 "2020-09-14T20:58:20Z")

</div>

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](https://serverfault.com/questions/767415/start-systemd-service-conditionally)

Drew

---

<div class="post-metadata">

**Author:** ![dellgreen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/dellgreen/32/85_2.png) [@dellgreen](https://hub.mender.io/u/dellgreen)\
**Post date:** [September 14, 2020, 9:37pm UTC](https://hub.mender.io/t/create-a-service-that-i-can-enable-and-disable-on-a-read-only-rootfs/2444/3 "2020-09-14T21:37:33Z")

</div>

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

> **[systemd.socket](https://www.freedesktop.org/software/systemd/man/systemd.socket.html)**

---

<div class="post-metadata">

**Author:** ![thesillywhat](https://avatars.discourse-cdn.com/v4/letter/t/57b2e6/32.png) [@thesillywhat](https://hub.mender.io/u/thesillywhat)\
**Post date:** [September 16, 2020, 4:15pm UTC](https://hub.mender.io/t/create-a-service-that-i-can-enable-and-disable-on-a-read-only-rootfs/2444/4 "2020-09-16T16:15:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dellgreen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/dellgreen/32/85_2.png) [@dellgreen](https://hub.mender.io/u/dellgreen)\
**Post date:** [September 16, 2020, 4:55pm UTC](https://hub.mender.io/t/create-a-service-that-i-can-enable-and-disable-on-a-read-only-rootfs/2444/5 "2020-09-16T16:55:46Z")

</div>

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

> <https://github.com/mendersoftware/meta-mender/blob/warrior/meta-mender-core/recipes-mender/mender/files/mender-grow-data.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”
