Systemd Automount vs Autofs – Comparison and Use Cases

automountingcifssystemd

I recently found that (among others) network shares can be automatically mounted on access. In Ubuntu there are two options either using autofs or the automount feature of systemd.

Could perhaps someone tell me what the differences (apart from different configuration) between the two options are. Autofs seems to be more flexible as one can configure scripts for the automount locations. Is this possible using the systemd automount as well?


UPDATE 2017-07-25:

Just a brief update for everyone stumbling across this question.

I went with the systemd automount option as it is way more convenient and easier to configure, while providing nearly the same functionality.

If there is an fstab entry with noauto and x-systemd.automount reloading the systemd daemon (systemctrl daemon-reload) will generate an automount systemd unit under /run/systemd/generator/ (at least this is the path where it get's generated under ubuntu 16.04). The unit will be named after the mountpoint of the fstab entry. That is, if you create an automountpoint for /media/network/someserver/share there will be a systemd automount unit media-network-someserver-share.automount. This automount unit can then be (re-)started to activate the mountpoint using systemctl restart media-network-someserver-share.automount.

And you're done.

Best Answer

I think you've largely answered your own question.

Systemd thinks about most things in a "just in time" manager, so adding automount was an obvious extension. The configuration uses a common style, but isn't super flexible.

Autofs is the old way we used to do this. It's flexible, the config is kind of complex/weird, and it's probably not installed by default.

You probably want systemd unless your needs are complex. A simple automount setup guide is here: http://blog.tomecek.net/post/automount-with-systemd/

Related Question