10/23/2018

Automounting NFS with Systemd

Systemd Automount


These files would be placed in /etc/systemd/system.
They are named specifically after the directory that is to be (auto)mounted.
They automount unit can be enabled and started to allow auto-mounting of the the directory.
If the mount unit is enabled and started then the directory will be persistently mounted.

[root@ryzen5 system]# cat home-lf.mount
[Unit]
  Description=nfs mount script
  Requires=network-online.target
  After=network-online.service

[Mount]
  What=10.0.0.46:/home/lf
  Where=/home/lf
  Options=rsize=8192,wsize=8192
  Type=nfs

[Install]
  WantedBy=multi-user.target

[root@ryzen5 system]# cat home-lf.automount
[Unit]
  Description=nfs mount script
  Requires=network-online.target
  After=network-online.service

[Automount]
  Where=/home/lf
  TimeoutIdleSec=10

[Install]
  WantedBy=multi-user.target

About Me - WrightRocket

My photo

I've worked with computers for over 30 years, programming, administering, using and building them from scratch.

I'm an instructor for technical computer courses, an editor and developer of training manuals, and an Android developer.