0

I have the following nfd share folder on my linux client ( redhat 7.2 )

master1:/nfs             41932800 6601728  35331072  16% /nfsshare

we decided to use the service auto fs in case this share folder is unmounted

we created the following service ( according to link - https://michlstechblog.info/blog/systemd-automount-nfs-export/ )

ls -ltr  auto-mnt.service
-rw-r--r-- 1 root root 212 May 10 12:38 auto-mnt.service

the conf

 more  auto-mnt.service
[Unit]
  Description=nfs mount script
  Requires=network-online.target
  After=network-online.service

[Mount]
  What=master1:/nfs
  Where=/nfsshare
  Options=
  Type=nfs

[Install]
  WantedBy=multi-user.target

and

systemctl daemon-reload

and

 systemctl start auto-mnt.service
Failed to start auto-mnt.service: Unit auto-mnt.service failed to load: Invalid argument. See system logs and 'systemctl status auto-mnt.service' for details.
[root@ system]# systemctl status auto-mnt.service
● auto-mnt.service - nfs mount script
   Loaded: error (Reason: Invalid argument)
   Active: inactive (dead)

from fstab

master1:/nfs  /nfsshare nfs defaults,noauto,x-systemd.automount,group,noauto,x-systemd.idle-timeout=1min 0 0

we not understand why service complain about -

[/etc/systemd/system/auto-mnt.service:6] Unknown section 'Mount'. Ignoring.
auto-mnt.service lacks both ExecStart= and ExecStop= setting. Refusing.

Unknown section 'Mount'. Ignoring

what is wrong in service syntax ?

1

The systemd unit should be called “nfsshare.mount” if you are creating a mountpoint called /nfsshare. It is not a Service unit so calling it .service is nonsense, which is why you are getting that error.

Also, if you create a mount unit, it is no longer necessary (and will likely cause problems) to have an entry in /etc/fstab.

  • I change the service name to nfsshare.mount under /etc/systemd/system and the line in fstab is - master1:/nfs /nfsshare nfs defaults,noauto,x-systemd.automount,group,noauto,x-systemd.idle-timeout=1min 0 0 , but still not get the mount back after 1 min , can you please advice what is wrong? – yael May 10 at 15:54
  • What do you mean “still not get the mount back”. Did you activate the mount unit after doing a daemon-reload? – jsbillings May 10 at 16:09
  • 1
    An entry in /etc/fstab will cause a corresponding .mount unit file be auto-generated at boot time by systemd-fstab-generator. Your custom .mount unit will override that. Pick either an fstab entry or a hand-written nfsshare.mount unit; don't attempt to use both together. If you need to customize a generated mount unit, you can use systemctl edit nfsshare.mount to extend it with a drop-in file. Automount units don't (re)mount the filesystem until something attempts to use that filesystem; the idle-timeout option makes systemd unmount the automounted filesystem if not needed. – telcoM May 11 at 13:30
  • +1 , ok I will reconfigure the service I and I will test it – yael May 12 at 4:40
  • now I have another issue , after the service is up and mount point mounted , then I umount the mountpoint , but service isnt active again the mount point , I will post a new question – yael May 12 at 5:43

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.