Linux – Why Directories Mounted with Autofs Are Not Visible in Filesystem

autofslinuxnfs

This is my first nfs / autofs configuration, so I probably configured something wrong. When I navigate to directory, which I added to /etc/auto.master I can't see any mount points, but when I issue cd with full path to expected mount point, than it tunes out, that I can access it. I think, that outputs below are self explanatory:

user@user-desktop:~/mnt/shares/autofs$ ls
user@user-desktop:~/mnt/shares/autofs$ ls ./backup_tmp
lost+found  test.file

This is how /etc/auto.master file looks like (on the receiver machine). First two lines comes by default, so I was not sure if I should touch them:

+dir:/etc/auto.master.d
+auto.master
/home/user/mnt/shares/autofs /etc/auto.misc --timeout=20

And this is how /etc/auto.misc looks like (first line comes by default):

cd      -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom
data_archive           -fstype=nfs4     192.168.1.140:/mnt/data_archive
data_file-resources    -fstype=nfs      192.168.1.140:/mnt/data_file-resources
backup_tmp             -fstype=nfs      192.168.1.140:/mnt/backup_tmp

Can anyone please help me debug this problem?

Best Answer

That's how autofs is supposed to work. The autofs directories are mounted when they are first accessed (that's why there is "auto" in the name). When you do a ls of the parent directory, there is no system call that would access the actual mountpoint path, so they are not visible. When you access explicitly the mountpoint path, it gets mounted. Try to do ls of the parent directory again, and you'll see that the mountpoint has appeared. After the mounted directory is not used by any process for 20 seconds (that's the timeout you have set in the config file), it gets unmounted again and is not visible anymore.