cancel
Showing results for 
Search instead for 
Did you mean: 
Flight Engineer HerveQ Flight Engineer
Flight Engineer
  • 294 Views

Automounting using systemd

Do you know that systemd provides its own automount feature?
It is as simple as declaring your file system in /etc/fstab and adding the x-systemd.automount mount option:

[root@demo ~]# vi /etc/fstab
...
nfs.example.com:/exports/docs  /documents  nfs  x-systemd.automount  0  0
[root@demo ~]# mkdir /documents
[root@demo ~]# reboot # or systemctl daemon-reload && systemctl start documents.automount


That's it. No need to install the autofs package, updating the /etc/auto.master file, or starting an extra service.

You can also add the x-systemd.idle-timeout option for systemd to unmount the file system when idle, and any other mount options the file system requires:

nfs.example.com:/exports/docs /documents nfs x-systemd.automount,x-systemd.idle-timeout=2min,rw,sync 0 0

See systemd.automount(5) and systemd.mount(5) man pages.

Labels (2)
1 Reply
Moderator
Moderator
  • 249 Views

Re: Automounting using systemd

This is pretty cool. I did not know about that. What are the benefits of using systemd automount feature?

0 Kudos
Reply
Loading...
Join the discussion
You must log in to join this conversation.