1

I want to mount a NFS-Share after the login, since mounting it via fstab will prolong my boot process if the NAS isn't reachable.

So I thought about a systemd --user service.

[Unit]
Description=Mounting the GuendoNAS
After=network.target

[Service]
User=root
Type=oneshot
ExecStart=/usr/bin/mount -t nfs 10.0.0.64:/disk1 /storage/guendonas/disk1
ExecStart=/usr/bin/mount -t nfs 10.0.0.64:/disk2 /storage/guendonas/disk2

[Install]
WantedBy=default.target

Which results in not GROUP spawninng /usr/bin/mount/: Operatio not permitted

Active: failed (Result: exit-code) since Fri 2016-01-22 19:06:02 CET; 25s ago
 Main PID: 1968 (code=exited, status=216/GROUP)

Jan 22 19:06:02 Asgard systemd[604]: Starting Mounting the GuendoNAS...
Jan 22 19:06:02 Asgard systemd[1968]: guendomount.service: Failed at step GROUP spawning /usr/bin/mount: Operation not permitted
Jan 22 19:06:02 Asgard systemd[604]: guendomount.service: Main process exited, code=exited, status=216/GROUP
Jan 22 19:06:02 Asgard systemd[604]: Failed to start Mounting the GuendoNAS.
Jan 22 19:06:02 Asgard systemd[604]: guendomount.service: Unit entered failed state.
Jan 22 19:06:02 Asgard systemd[604]: guendomount.service: Failed with result 'exit-code'.

I am not sure why this happens, because the service should run as user root or is this permitted with a systemd --user service? What would be the alternative? I could make an autostart script however I want to use the service as dependency for other services

1 Answer 1

2

Although I could not find a man page explicitly stating this, one would assume that a user service unit cannot set USER to something other than the user-ID it is running for. You should use a system (auto)mount unit, which is easily created using an entry in /etc/fstab:

10.0.0.64:/disk1  /storage/guendonas/disk1  nfs  noauto,x-systemd.automount 0 0

(It might be a good idea to name your servers in /etc/hosts.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .