At times it may be desired not to add a mount point permanently via the /etc/fstab, but just automatically mount when the user just desires to access a particular share. This is a scenario when a host admin want to make a shared folder available to users without they manually making them mount the share, but enabling the host to automatically noun the share when the users access the mount point.
Autofs uses the auto mount daemon. It manages the mount points by mounting them dynamically when they are accessed by users.
Procedure to mount an NFS share “22.214.171.124:/nfs_mymount” using autofs.
- Ensure the packages “nfs-utils” is installed in our client host
- Ensure the share is accessible from our client host. This can be verified by using the “showmount -e 192.168.3.22” command, and also my manually mounting the share to check. This is a very important step.
- Ensure the package “autofs” is installed by issuing the command “rpm -qa | grep autofs“
- Start the autofs service using the command “service autofs start”, and permanently making it after reboots using the command “chkconfig autofs on“
- Edit the file “/etc/auto.master“, and ensure the line starting with “/misc” is not commented.
- Edit the file “/etc/auto.misc” and add the line “mynfs -rw 192.168.3.22:/nfs_mymount“
- Ensure the folder “/misc” exists un the root directory.
- Restart autofs service by using the command “service autofs restart“
- Try accessing the folder by issuing the command “cd /misc/mynfs“
The time one accessed this folder, the share will be automatically mounted.