Pages

Sunday, 16 August 2020

An example of conflicts between Autofs and /etc/fstab

 0 issues

Recently, users complained that their local home directory was missing on some servers after rebooting. 

$ ls /home

$ cat /etc/fstab | grep home
/dev/mapper/rhel-lv_home      /home       xfs    nodev     0 0

And it's really mounted.

$ cat /proc/mounts | grep /home

/dev/mapper/rhel-lv_home  /home  xfs rw,seclabel,nodev,relatime,attr2,inode64,noquota 0 0

/etc/auto.home /home autofs rw,relatime,fd=17,pgrp=27605,timeout=300,indirect 0 0 

1 Analysis

Look at the /proc/mounts again, actually there are two entries for /home. So actually the second one (red) overrides the first one(green), which means /home is an autofs file system now. 

Let look at the map file /etc/auto.home.

$ cat /etc/auto.home
user1     nfs_server_1:/export/home/&
user2     nfs_server_1:/export/home/&

unfortunately, nfs_server_1 didn't allow this host to connect. So /home/user1, /home/user2 were inaccessible. 

But the users' home was located in the local logic volume, not on the remote NFS server. Because the autofs mount entry overwrote the local volume's mount entry, /dev/mapper/rhel-lv_home was no longer accessible via /home.

The solution is easy, removing the "/home /etc/auto.home" line in /etc/auto.master.

2 More about autofs

When autofs service is started, it reads /etc/auto.master and creates one entry for each line into /proc/mounts. 

$ cat /etc/auto.master
/home  /etc/auto.home

So, an entry with "autofs" file system type will be in /proc/mounts.

$ cat /proc/mounts | grep /home

/etc/auto.home /home autofs rw,relatime,fd=17,pgrp=27605,timeout=300,indirect 0 0 

This entry tells the kernel that any file path starting with /home will trigger autofs, which will do the mounting work and add other entries into /proc/mounts.

nfs_server_1:/export/home/user1 /home/user1 nfs4 rw,relatime,vers=4.2

3 Conclusion

An autofs managed mount point shoud NOT be manually mounted/unmounted including /etc/fstab.
During system boot, /etc/fstab is firstly read and a mount entry is added to /proc/mounts. Then autofs service starts, and add another mount entry. If the two entries share the same mount point, then conflicts take place.

There is no way for autofs mounting and ordinary mounting share the same mount point.




No comments:

Post a Comment