AutoFS Server In Linux

The autofs server is very useful server. It automatically mounts the drive when you enter in respective mount point folder and the devices automatically gets unmounted if you are not using them for defined time.

Below are the steps to install autofs server.

# yum install autofs -y
# systemctl enable autofs
# systemctl start autofs

By default autofs server reads /etc/auto.master configuration file. This file contains information about auto mount points.

For example if I have say /dev/sdb1 as drive with ext4 file system. I wish mount this drive in say /mydisk/disk-1 folder. I can do this task as below.

I will write separate auto configuration file for /mydisk folder. I will perform this task as below.

1.  Edit /etc/auto.master file and add entry for /mydisk Folder as below

/mydisk          /etc/auto.mydisk        --timeout=120

2.  Save the file and now create /etc/auto.mydisk as below.

disk-1      -fstype=ext4                 :/dev/sdb1

3.   Save the file and restart autofs server as below.

# systemctl restart autofs

4.  Now simply use cd command and try to enter in /mydisk/disk-1 folder. (It is not necessary to create any folder for mount point. It will be automatically created by autofs server.)

# cd  /mydisk/disk-1
# df -Th

5.  You can see that the /dev/sdb1 is automatically mounted in /mydisk/disk-1 Folder.

Using this utility you can mount even remote drive also. For more information please read /etc/auto.misc file. This file contains very useful information.