0

Hello everyone i am not able to mount multiple NFS Share Directories using fstab on RHEL 7. Check out my LAB configuration.

I want to ask question using nfs and mounting by fstab only one nfs directory can be mount. if no how to mount multiple directory.

LAB

server.example.com 192.168.2.2/24

client.example.com 192.168.2.1/24

On Server

nfs share folder are /test1 /test2

Disable firewalld and selinux is in permissive mode on server and client.

On Server

[root@server ~]# yum install nfs-utils
[root@server ~]# systemctl enable rpcbind
[root@server ~]# systemctl start rpcbind
[root@server ~]# systemctl start nfs-server
[root@server ~]# systemctl start nfs-secure


[root@server ~]# mkdir /test1
[root@server ~]# mkdir /test2
[root@server ~]# ls /test*
/test1:

/test2:

[root@server ~]# chmod 777 /test1
[root@server ~]# chmod 777 /test2


[root@server ~]# vim /etc/exports
[root@server ~]# cat /etc/exports
/test1 192.168.2.1(rw,sync,no_root_squash)
/test2 192.168.2.1(rw,sync,no_root_squash)

[root@server ~]# exportfs -r

[root@server ~]# exportfs -v
/test1          192.168.2.1(rw,wdelay,no_root_squash,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)
/test2          192.168.2.1(rw,wdelay,no_root_squash,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)


[root@server ~]# systemctl stop firewalld.service
[root@server ~]# systemctl disable firewalld.service
[root@server ~]# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   permissive
Mode from config file:          permissive

ON Client

[root@client ~]# systemctl enable rpcbind
[root@client ~]# systemctl start rpcbind

[root@client ~]# setenforce 0
[root@client ~]# vim /etc/sysconfig/selinux
[root@client ~]# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   permissive
Mode from config file:          permissive
[root@client ~]# systemctl stop firewalld
[root@client ~]# systemctl disble firewalld


[root@client ~]# showmount -e 192.168.2.2
Export list for 192.168.2.2:
/test2 192.168.2.1tes
/test1 192.168.2.1

[root@client ~]# mkdir /mnt/nfstest1
[root@client ~]# mkdir /mnt/nfstest2
[root@client ~]# chmod 777 /mnt/nfstest1
[root@client ~]# chmod 777 /mnt/nfstest2

Check fstab file

[root@client ~]# vim /etc/fstab

[root@client ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Wed Apr 26 08:01:03 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=8cfced80-d77a-41a6-a7ee-9b41ebea88b2 /                       xfs     defaults        1 1
UUID=ad9e8442-335f-478c-81af-b77e1ac88549 /boot                   xfs     defaults        1 2
UUID=e55cb2d8-4461-4792-944c-1b76225dd13a /home                   xfs     defaults        1 2
UUID=ffbc9edf-42ce-4d82-af5c-b2ff1cff5a68 /usr                    xfs     defaults        1 2
UUID=556f0e53-bfa3-4639-9d47-ba1c70299393 /var                    xfs     defaults        1 2
UUID=a855e109-f05f-4bfe-bfc9-a06f10d294f1 swap                    swap    defaults        0 0
192.168.2.2:/test1 /mnt/nfstest1 nfs rw,sync 0 0
192.168.2.2:/test2 /mnt/nfstest2 nfs rw,sync 0 0

[root@client ~]# mount -a

df -h show only one nfs directory mounted /mnt/nfstest1

[root@client ~]# df -h
Filesystem          Size  Used Avail Use% Mounted on
/dev/sda2           9.8G   70M  9.7G   1% /
devtmpfs            354M     0  354M   0% /dev
tmpfs               363M     0  363M   0% /dev/shm
tmpfs               363M  5.2M  357M   2% /run
tmpfs               363M     0  363M   0% /sys/fs/cgroup
/dev/sda5           9.8G  2.8G  7.0G  29% /usr
/dev/sda3           9.8G   33M  9.8G   1% /home
/dev/sda1           2.0G  107M  1.9G   6% /boot
/dev/sda6           9.8G  3.8G  6.1G  39% /var
192.168.2.2:/test1  9.8G   71M  9.7G   1% /mnt/nfstest1

but on mount command show both nfs directory

[root@client ~]# mount | grep nfstest*
192.168.2.2:/test1 on /mnt/nfstest1 type nfs4 (rw,relatime,sync,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.2.1,local_lock=none,addr=192.168.2.2)

192.168.2.2:/test2 on /mnt/nfstest2 type nfs4 (rw,relatime,sync,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.2.1,local_lock=none,addr=192.168.2.2)

i have reboot

check my status again,again only one nfs share directory is mounted and i.e is /mnt/nfstest2 and /mnt/nfstest1 gone. why is this happing i have fire Right option in /etc/fstab. can some one tell me is that right.

login as: root
root@192.168.2.1's password:
Last login: Wed May 10 22:37:20 2017 from 192.168.2.100

[root@client ~]# df -h
Filesystem          Size  Used Avail Use% Mounted on
/dev/sda2           9.8G   70M  9.7G   1% /
devtmpfs            354M     0  354M   0% /dev
tmpfs               363M     0  363M   0% /dev/shm
tmpfs               363M  5.2M  357M   2% /run
tmpfs               363M     0  363M   0% /sys/fs/cgroup
/dev/sda5           9.8G  2.8G  7.0G  29% /usr
/dev/sda1           2.0G  107M  1.9G   6% /boot
/dev/sda3           9.8G   33M  9.8G   1% /home
/dev/sda6           9.8G  3.8G  6.1G  39% /var
192.168.2.2:/test2  9.8G   71M  9.7G   1% /mnt/nfstest2

[root@client ~]# mount | grep nfstest*
192.168.2.2:/test2 on /mnt/nfstest2 type nfs4 (rw,relatime,sync,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.2.1,local_lock=none,addr=192.168.2.2)

192.168.2.2:/test1 on /mnt/nfstest1 type nfs4 (rw,relatime,sync,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.2.1,local_lock=none,addr=192.168.2.2)


[root@client ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Wed Apr 26 08:01:03 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=8cfced80-d77a-41a6-a7ee-9b41ebea88b2 /                       xfs     defaults        1 1
UUID=ad9e8442-335f-478c-81af-b77e1ac88549 /boot                   xfs     defaults        1 2
UUID=e55cb2d8-4461-4792-944c-1b76225dd13a /home                   xfs     defaults        1 2
UUID=ffbc9edf-42ce-4d82-af5c-b2ff1cff5a68 /usr                    xfs     defaults        1 2
UUID=556f0e53-bfa3-4639-9d47-ba1c70299393 /var                    xfs     defaults        1 2
UUID=a855e109-f05f-4bfe-bfc9-a06f10d294f1 swap                    swap    defaults        0 0
192.168.2.2:/test1 /mnt/nfstest1 nfs rw,sync 0 0
192.168.2.2:/test2 /mnt/nfstest2 nfs rw,sync 0 0

Here multiple nfs share directory is not mounting at once . On client /etc/fstab

192.168.2.2:/test1 /mnt/nfstest1 nfs rw,sync 0 0
192.168.2.2:/test2 /mnt/nfstest2 nfs rw,sync 0 0

after fireing mount -a

i am getting /mnt/nfstest1

192.168.2.2:/test1  9.8G   71M  9.7G   1% /mnt/nfstest1 

but after restarting client i am getting vice-versa . WHY

Can some one help me to solve this problem

Note NFS directory are made on single / file system on server.

And mounted on /mnt/test1 and /mnt/test2 on client.

Thank You Sagar Dalvi

0

The output of mount should be authoritative. /proc/mounts is the true authority, but mount uses that nowadays, /etc/mtab is just a symlink. You could check those yourself to be sure, if you like. But I think the filesystems are mounted.

The answer is that df filters out duplicate filesystems, such as bind mounts. (The order these filesystems are mounted in is effectively random, when systemd is used).

df is somehow able to correctly identify these two directories as being hosted on the same physical filesystem - the space information for them would be identical. If you search the web, you will find this same complaint about df and NFS mounts reported as bugs on multiple Linux distributions.

The answer from these bugs is that if you want to show all mount points, then you want df -a.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.