Unable to mount NFS share on Linux client (access denied by server while mounting)

Written by - 0 comments

Published on - Listed in Linux Network


Today I ran into a weird issue while attempting to mount two NFS shares from two different NFS servers.

mount.nfs: access denied by server while mounting

Both NFS shares (NFS exports) were supposedly the same, at least I was told so. However only of of the two shares could be successfully mounted, the other failed with an error:

root@ubuntu:~# mount -t nfs server1:/share1 /backup1
root@ubuntu:~# mount -t nfs server2:/share2 /backup2
mount.nfs: access denied by server while mounting server2:/share2

A local permission error can be excluded in this case. However the error itself is not really helpful to find the root reason.

More helpful is to run the mount command in verbose mode.

mount command in verbose mode

Let's do this with the working share1 again:

root@ubuntu:~# mount -t nfs server1:/share1 /backup1 -vvvv
mount.nfs: timeout set for Tue Jun 11 15:55:20 2024
mount.nfs: trying text-based options 'vers=4.2,addr=server1,clientaddr=ubuntu'

This shows that in the background NFS version 4.2 was added as mount option. 

What about mounting the share2 from server2?

root@ubuntu:~# mount -t nfs server2:/share2 /backup2 -vvvv
mount.nfs: timeout set for Tue Jun 11 15:43:32 2024
mount.nfs: trying text-based options 'vers=4.2,addr=server2,clientaddr=ubuntu'
mount.nfs: mount(2): Permission denied
mount.nfs: access denied by server while mounting server2:/share2

The same mount options are applied - yet here we get a permission denied error in verbose output.

Check the NFS version!

Thanks to the verbose output before we now know that NFSv4 (4.2) was selected as mount option. Unfortunately NFS servers can be pretty stubborn when it comes to NFS version compatibility - or better said incompatibility! 

Let's try an older NFS version (NFSv3) on the not-working share:

root@ubuntu:~# mount -t nfs server2:/share2 /backup2 -o 'nfsvers=3' -vvvv
mount.nfs: timeout set for Tue Jun 11 15:43:46 2024
mount.nfs: trying text-based options 'nfsvers=3,addr=server2'
mount.nfs: prog 100003, trying vers=3, prot=6
mount.nfs: trying server2 prog 100003 vers 3 prot TCP port 2049
mount.nfs: prog 100005, trying vers=3, prot=17
mount.nfs: portmap query retrying: RPC: Timed out
mount.nfs: prog 100005, trying vers=3, prot=6
mount.nfs: trying server2 prog 100005 vers 3 prot TCP port 635

No error this time! Was this NFS share really mounted this time?

root@ubuntu:~# mount|grep backup2
server2:/share2 on /backup2 type nfs (rw,relatime,vers=3,rsize=65536,wsize=65536,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=server2,mountvers=3,mountport=635,mountproto=tcp,local_lock=none,addr=server2)

Indeed, the NFS share was successfully mounted with NFSv3!

So it turns out the NFS share configuration (exports) on the two NFS servers were not exactly the same after all. 


Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   OpenSearch   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder