Search code examples
linuxnfs

mount.nfs: access denied by server while mounting 192.168.8.104:/mnt/sdb/var/lib/glance/images


Before asking this question, I searched the stackoverflow, but the answers no use: mount: nfs access denied by server

In my VM, I have sda, sdb hard disk in the VM.

Then VM have ips:192.168.8.101, 192.168.8.104.

When I mount the sdb's directory to the VM's directory under /var:

[root@ha-node1 sdb]# mount -t nfs 192.168.8.104:/mnt/sdb/var/lib/glance/images /var/lib/glance/images 

Get the below error:

mount.nfs: access denied by server while mounting 192.168.8.104:/mnt/sdb/var/lib/glance/images

And the directories under /mnt permissions all are perfect.

[root@ha-node1 sdb]# ll -d /mnt/
drwxr-xr-x. 4 root root 26 Jul 26 00:43 /mnt/
[root@ha-node1 sdb]# ll -d /mnt/sdb
drwxr-xr-x 4 root root 4096 Jul 26 10:05 /mnt/sdb
[root@ha-node1 sdb]# ll -d /mnt/sdb/var/
drwxr-xr-x 3 root root 4096 Jul 26 10:05 /mnt/sdb/var/
[root@ha-node1 sdb]# ll -d /mnt/sdb/var/lib/
drwxr-xr-x 3 root root 4096 Jul 26 10:05 /mnt/sdb/var/lib/
[root@ha-node1 sdb]# ll -d /mnt/sdb/var/lib/glance/
drwxr-xr-x 3 root root 4096 Jul 26 10:05 /mnt/sdb/var/lib/glance/
[root@ha-node1 sdb]# ll -d /mnt/sdb/var/lib/glance/images/
drwxr-xr-x 2 root root 4096 Jul 26 10:05 /mnt/sdb/var/lib/glance/images/

The network connection is also ok.

[root@ha-node1 sdb]# ping 192.168.8.104
PING 192.168.8.104 (192.168.8.104) 56(84) bytes of data.
64 bytes from 192.168.8.104: icmp_seq=1 ttl=64 time=0.024 ms
64 bytes from 192.168.8.104: icmp_seq=2 ttl=64 time=0.030 ms
64 bytes from 192.168.8.104: icmp_seq=3 ttl=64 time=0.032 ms
64 bytes from 192.168.8.104: icmp_seq=4 ttl=64 time=0.031 ms

The NFS service works normal :

[root@ha-node1 sdb]# systemctl status nfs.service
● nfs-server.service - NFS server and services
   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; enabled; vendor preset: disabled)
   Active: active (exited) since Wed 2017-07-26 00:26:23 CST; 11h ago
  Process: 1916 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
  Process: 1786 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
 Main PID: 1916 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/nfs-server.service

Jul 26 00:26:22 ha-node1 systemd[1]: Starting NFS server and services...
Jul 26 00:26:23 ha-node1 systemd[1]: Started NFS server and services.

In the log I grep the mount:

[root@ha-node1 sdb]# cat /var/log/messages | grep mount
Jul 24 14:44:07 ha-node1 systemd: tmp.mount: Directory /tmp to mount over is not empty, mounting anyway.
Jul 26 00:12:08 ha-node1 systemd: Started dracut pre-mount hook.
Jul 26 00:12:11 ha-node1 systemd: Started dracut mount hook.
Jul 26 00:12:15 ha-node1 systemd: Started Remount Root and Kernel File Systems.
Jul 26 00:23:44 ha-node1 rpc.mountd[4312]: Version 1.3.0 starting
Jul 26 00:26:02 ha-node1 systemd: Started dracut pre-mount hook.
Jul 26 00:26:04 ha-node1 systemd: Started dracut mount hook.
Jul 26 00:26:08 ha-node1 systemd: Started Remount Root and Kernel File Systems.
Jul 26 00:26:22 ha-node1 rpc.mountd[1561]: Version 1.3.0 starting
Jul 26 00:43:03 ha-node1 kernel: EXT4-fs (sdb): mounted filesystem with ordered data mode. Opts: (null)
Jul 26 00:43:13 ha-node1 kernel: EXT4-fs (sdc): mounted filesystem with ordered data mode. Opts: (null)
Jul 26 10:07:03 ha-node1 rpc.mountd[1561]: refused mount request from 192.168.8.104 for /mnt/sdb/var/lib/glance/images (/): not exported

It shows not exported, I tried to exportfs -r, but no use.

Someone can tell me about this, why I can not NFS mount the sdb to self directory?


Solution

  • The directories exported to outer world is controled by file:'/etc/exports ' under linux OS. add: /mnt/sdb/var/lib/glance/images *(rw,sync,no_subtree_check) in that file and try again. This is only a example for you, The access right should be modified accroding exactly requirement. read the manual of exports please.