AutoFS Configuration in Redhat Linux 7/8
AutoFS Configuration:
Extra Note:
You can use cat /etc/mtab command to permanent mount. Just copy your partition line and paste it into /etc/fstab file; save it.
At Server Side:
Server IP=10.1.1.1/24
yum install -y nfs*
mkdir /public
mkdir /private
chmod 777 /public
chmod 777 /private
cd /public
cal > calpublic.txt
cd /private
cal 2020 > calprivate.txt
vim /etc/exports
/public 10.1.1.2(ro,sync)
/private 10.1.1.2(rw,sync)
exportfs -arvf
firewall-cmd --permanent --add-service=nfs
firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --permanent --add-service=mountd
** you can use below command instead of above 3 commands
firewall-cmd --permanent --add-service={nfs,rpc-bind,mountd}
firewall-cmd --reload
systemctl start nfs-server.service rpcbind
systemctl enable nfs-server rpcbind
At Client Side:
IP Address: 10.1.1.2
yum install -y autofs
rpm -qi autofs [For checking just]
mkdir /automount
vim /etc/auto.master
[After 7th lines below,write below command]
/automount /etc/automount.txt --timeout=60
vim /etc/automount.txt
public -ro,sync 10.1.1.1:/public
private -rw,sync 10.1.1.1:/private
mkdir -p /automount/public
mkdir -p /automount/private
systemctl start autofs
systemctl enable autofs
systemctl status autofs [For checking only]
cd
df -hT [See the output of this command-There is no mounting]
mount -a
cd /automount
cd /public
df -hT [Now see the output- You will the see public folder has mounted]
cd ..
cd private
df -hT [Now see the output- You will the see private folder has mounted]
ll
cat calprivate.txt
rm calprivate.txt [you will be able to delete it, because you gave read,write permission for private folder]
ll
touch a.txt [you will be able to create it, because you gave read ,write permission for private folder]
mkdir a.txt b.txt [you will be able to create it, because you gave read ,write permission for private folder]
ll
cd ..
cd public
cat calpublic.txt
rm calpublic.txt [you will be not able to delete it, because you gave read only permission for public folder]
mkdir a.txt b.txt [you will be not able to create it, because you gave read only permission for public folder]
df -hT [You will see the mount points]
cd ..
df -hT [Now, You will not see the mount points]
This comment has been removed by a blog administrator.
ReplyDelete