http://www.linuxtechi.com/automount-nfs-share-in-linux-using-autofs
/
In map file (/etc/auto.misc or /etc/auto.xxxx) also we have three different fields:
In this article we will mount the NFS share using autofs. NFS share ‘/db_backup‘ is exported from Fedora NFS Server (192.168.1.21). We are going to mount this nfs share on CentOS 7 & Ubuntu Linux using autofs.
Where :
Create the mount point.
Autofs is a service in Linux like
operating system which automatically mounts the file system and remote
shares when it is accessed. Main advantage of autofs is that you don’t
need to mount file system at all time, file system is only mounted when
it is in demand.
Autofs service reads two files Master map file ( /etc/auto.master ) and a map file like /etc/auto.misc or /etc/auto.xxxx.
In ‘/etc/auto.master’ file we have three different fields :/
In map file (/etc/auto.misc or /etc/auto.xxxx) also we have three different fields:
In this article we will mount the NFS share using autofs. NFS share ‘/db_backup‘ is exported from Fedora NFS Server (192.168.1.21). We are going to mount this nfs share on CentOS 7 & Ubuntu Linux using autofs.
Steps to mount nfs share using Autofs in CentOS 7.
Step:1 Install autofs package.
Install the autofs package using below yum command if it is not installed.[root@linuxtechi ~]# rpm -q autofs package autofs is not installed [root@linuxtechi ~]# yum install autofs
Step:2 Edit the Master map file (/etc/auto.master )
Add the following line .[root@linuxtechi ~]# vi /etc/auto.master /dbstuff /etc/auto.nfsdb --timeout=180
Note : Mount point ‘/dbstuff’‘ must exist on your system. If not then create a directory ‘mkdir /dbstuff‘. NFS Share will automatically umount after 180 seconds or 3 minutes if don’t perform any action on the share.
Step:2 Creat a map file ‘/etc/auto.nfsdb’
Create a map file and add the following line.[root@linuxtechi ~]# vi /etc/auto.nfsdb db_backup -fstype=nfs,rw,soft,intr 192.168.1.21:/db_backupSave and exit the file.
Where :
- db_backup is a mount point.
- -fstype=nfs is the file system type & ‘rw,soft,intr’ are mount options.
- ‘192.168.1.21:/db_backup’ is nfs share location.
Step:3 Start the auotfs service.
[root@linuxtechi ~]# systemctl start autofs.service [root@linuxtechi ~]# systemctl enable autofs.service ln -s '/usr/lib/systemd/system/autofs.service' '/etc/systemd/system/multi-user.target.wants/autofs.service' [root@linuxtechi ~]#
Step:3 Now try to access the mount point.
Mount point of nfs share will be ‘/dbstuff/db_backup’. When we try access the mount point then autofs service will mount nfs share automatically.Steps to mount NFS share using autofs in Ubuntu Linux.
Step:1 Install the autofs package using apt-get command.
linuxtechi@linuxworld:~$ sudo apt-get install autofs
Step:2 Edit the Master Map file ‘/etc/auto.master’
Add the following line in the master map file.linuxtechi@linuxworld:~$ sudo vi /etc/auto.master /dbstuff /etc/auto.nfsdb --timeout=180Save & exit the file.
Create the mount point.
linuxtechi@linuxworld:~$ sudo mkdir /dbstuff linuxtechi@linuxworld:~$
Step:2 Create a map file ‘/etc/auto.nfsdb’.
Add the following line in the map file.linuxtechi@linuxworld:~$ sudo vi /etc/auto.nfsdb db_backup -fstype=nfs4,rw,soft,intr 192.168.1.21:/db_backup
Step:3 Start the autofs service.
linuxtechi@linuxworld:~$ sudo /etc/init.d/autofs start
No comments:
Post a Comment