RHEL 8.3 64-bit

autofs.x86_64 1:5.1.4-43.el8

I'm trying to enable autofs for my system. I've followed the tutorials and, while they make sense, the network drives are not mounting and in some cases present some weird behavior. First, the configuration files


/home/me/  /etc/auto.me.nfs


nas -fstype=nfs4 nas:/data/directory

Now when I run:

service autofs start

It should mount nas:/data/directory -> /home/me/nas, right? One of two things will happen:

  1. Nothing. The directory /home/me/nas contains all local contents and df -h shows nothing mounted to that location.
  2. My home directory will ONLY contain nas. It shows in df -h and the remote files are accessible. However, everything else is gone. An ls -l on /home/ shows my home directory owned by root.root

The command:

mount nas:/data/directory /home/me/nas

Works just fine, inheriting the ownership and permissions from the NFS directory. What am I missing? Is there a log to see what autofs is trying to do?

1 Answer 1


Classic autofs

Situation 1) is probably caused by your /etc/auto.master.d/mount.nfs not being named /etc/auto.master.d/mount.autofs: according to auto.master(5) man page and comment in the /etc/auto.master configuration file, any files in auto.master.d must have an *.autofs suffix to work.

Your situation 2) is basically working exactly like a classic-style autofs is expected to work with your current configuration.

With your current configuration, the /home/me/ directory becomes an autofs map mountpoint: a special virtual directory that senses when someone attempts to access it. If you attempt to list the contents of the autofs mountpoint, it will list the contents of the map as sub-directories (in your case, just the nas sub-directory), and when you actually attempt to access those sub-directories, autofs will automatically mount them as required NFS share before letting that access happen, and can automatically unmount each share when it is no longer being used.

The indirect maps (like your current configuration) are really designed for situations like /home/ being an autofs map mountpoint: the user home directories would then be individual NFS shares in the indirect map, that can be mounted and unmounted as users log in and out. Since updates to indirect maps take effect immediately, new users can be created and old ones removed without restarting the autofs service.

If you want to mount the NFS share without an intervening directory, you could do it by defining a direct map in auto.master.d/:

rm /etc/auto.master.d/mount.nfs
echo "/-  /etc/auto.me.nfs" >/etc/auto.master.d/mount.autofs

Then changing the contents of /etc/auto.me.nfs to:

/home/me/nas    -fstype=nfs4 nas:/data/directory

And finally restarting the autofs service:

systemctl restart autofs

This should exactly replicate the effects of the mount nas:/data/directory /home/me/nas command whenever you access /home/me/nas, and allow it to be unmounted when there are no processes accessing it. But any changes to the configuration of the direct map will require restarting the autofs service, unlike in the case of the indirect map.

Alternative solution with systemd

However, with systemd, there is an alternative way to set up a single auto-mounting directory without even needing a separate autofs service. Just write an entry in /etc/fstab like this:

nas:/data/directory   /home/me/nas  nfs nfsvers=4,nofail,x-systemd.automount 0 0

To activate this entry immediately, you would need two commands:

systemctl daemon-reload                #triggers systemd-fstab-generator to re-make *.mount and *.automount units
systemctl start home-me-nas.automount   #starts the newly created automount unit

Otherwise, it would activate automatically at next reboot.

For more details and configuration options, read man systemd.mount.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .