← Back to list

Mastering Autofs with NFS: Automating Network File System Mounting

Imagine you work in a large organization with multiple servers storing vast amounts of data. This data is shared across different machines…

saisivayenduri · 2024-11-14 14:40 · 0 claps · 1.3 min read
#linux #nfs-server #autofs #lfcs-exam-questions #lfcs-exam
Open on Medium ↗
Wiki topics: 🔓 · Open Source

Mastering Autofs with NFS: Automating Network File System Mounting

Imagine you work in a large organization with multiple servers storing vast amounts of data. This data is shared across different machines, allowing everyone to access it as needed. For instance, there might be files on one server, shared via NFS (Network File System), that everyone else on the network can access. But managing these shared files can be tedious if every user has to manually connect or “mount” these filesystems whenever they need access.

This is where Autofs (Automount Filesystem) steps in. Autofs is an automount daemon that manages mount points as needed. In short, it only mounts a given share when that share is being accessed and are unmounted after a defined period of inactivity.

First lets setup a local nfs server by installing “nfs-kernel-server” package.

sudo apt install nfs-kerner-server

Now we need to define which folder to share over network as file system.

sudo vim /etc/exports
/nfs_share    127.0.0.1(rw,sync,no_subtree_chec)

sudo exportfs -r

Now we setup Automount Filesystem by installing “autofs” package.

sudo apt install autofs

Now we configure autofs by adding few configuration to “auto.master” and “auto.misc” config files.

auto.master is the master file where we define different mappings as below.

sudo vim /etc/auto.master
/misc      /etc/auto.misc    --timeout=300

Here in the auto.master configuration file, we are telling autofs to look for “/etc/auto.misc” and create /misc mountpoint.

In auto.misc we define the foldername as “backup”, filesystem type as “nfs4”, it should be mounted in rw mode also the nfs server details.

sudo vim /etc/auto.misc
backup      -fstype=nfs4,rw,soft,intr    127.0.0.1:/nfs_share

We need to reload and restart the autofs daemon using below command which will restart the autofs daemon.

sudo systemctl restart autofs && sudo systemctl enable autofs

Once the autofs daemon in restarted you need to access the files using

# Until you access the path files wont get mounted.
ls -lah /misc/backup

As we have defined the “--timeout=300”, files will be auto unmounted if we dont access the files for 5 minutes.


메타데이터
post_id
c1e2d4d7d4bd
slug
mastering-autofs-with-nfs-automating-network-file-system-mounting-c1e2d4d7d4bd
url
https://medium.com/@me.sivayenduri/mastering-autofs-with-nfs-automating-network-file-system-mounting-c1e2d4d7d4bd
canonical_url
https://medium.com/@me.sivayenduri/mastering-autofs-with-nfs-automating-network-file-system-mounting-c1e2d4d7d4bd
author_url
https://medium.com/@me.sivayenduri
status
ok
fetched_at
2026-07-22 04:22:49