Thursday, June 23, 2011

How to refresh autofs in Linux?

Sometimes my users complain that they can not go to some directories because those directories are coming from automounter. Although same server was able to access the location before but for some reason, autofs daemon got hung/not responding. Here is a quick solution to make it work again:

[root@server-1 ~]# ssh server-061
Last login: Tue Nov 30 13:38:18 2010 from server-1

[root@server-061 ~]# su - unixgeek
su: warning: cannot change directory to /user/unixgeek: No such file or directory

[root@server-061 ~]# ls -la /etc/mtab*
-rw-r--r-- 1 root root 4453 Jun 23 08:58 /etc/mtab
---------- 2 root root 0 Jun 23 09:03 /etc/mtab~
---------- 2 root root 0 Jun 23 09:03 /etc/mtab~30971
---------- 1 root root 0 Jun 23 09:06 /etc/mtab~31065
[root@server-061 ~]# rm -f /etc/mtab~ /etc/mtab~30971 /etc/mtab~31065
[root@server-061 ~]# ls -la /etc/mtab*
-rw-r--r-- 1 root root 4453 Jun 23 08:58 /etc/mtab
[root@server-061 ~]# service autofs reload
Reloading maps
[root@server-061 ~]# su - unixgeek
[unixgeek@server-061 ~]$ logout
[root@server-061 ~]# logout

Connection to server-061 closed.
[root@server-1 ~]#

So, the root cause of this type of hung situation was the presence of extra /etc/mtab~* files. These files are created and could not get removed when an autofs location is accessed becuase sometimes autofs daemon or system is too busy. Manually delete the extra files and the reload autofs server can help.

No comments: