0

I'm trying to start the systemd service during boot once fstab entries mounted.

I have followed Set systemd service to execute after fstab mount and added below details

# cat /etc/fstab
/dev/mmcblk1p11 /data       ext4    defaults        0 2

# systemctl list-units | grep '/data' | awk '{ print $1 }'
data.mount

# cat /usr/lib/systemd/system/data.service
[Unit]
Description=My system
After=data.mount

[Service]
Type=oneshot
ExecStartPre=mountpoint -q /data
ExecStart=/usr/etc/data.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Problem is, it won't start during boot. However, the manual restart seems working.

# systemctl status data.service
  data.service - My system
   Loaded: loaded (/usr/lib/systemd/system/data.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

# systemctl enable data.service
Created symlink /etc/systemd/system/multi-user.target.wants/data.service ��→ /usr/lib/systemd/system/data.service.
# systemctl restart data.service
         Starting My system...
[  OK  ] Started My system.

Did I miss anything?

0

Two things I would try. You stated manual startup worked but in your example you show

systemctl enable data.service

Did you do this enable command before you restarted? It has to be enabled to start on boot.

2nd I think the After= line needs to be the service name. Try to change

After=data.mount 

to

After=data.service 

and see what happens.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.