[SOLVED] Unable to mount NFS in ubuntu: mount error

Discussion about using NAS on Linux and Unix OS.
Post Reply
serpro69
Starting out
Posts: 13
Joined: Sun Jan 17, 2021 5:18 pm

[SOLVED] Unable to mount NFS in ubuntu: mount error

Post by serpro69 » Tue Jul 20, 2021 8:18 pm

I'm trying to mount the shared folder in Ubuntu 20.04 and getting some errors.
I've tried a lot of things I found on the web to no avail.

At first I was getting mount error(13): Permission denied:

Code: Select all

sudo mount -t cifs //192.168.0.101/milliways /media/milliways -o cred=/root/.smbcredentials,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777 --verbose
domain=milleniumfalcon
mount.cifs kernel mount options: ip=192.168.0.101,unc=\\192.168.0.101\milliways,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,user=sergio,domain=milleniumfalcon,pass=********
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)
Forcing sec option to ntlm I'm getting mount error(2): No such file or directory:

Code: Select all

sudo mount -t cifs //192.168.0.101/milliways /media/milliways -o cred=/root/.smbcredentials,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,sec=ntlm --verbose
domain=milleniumfalcon
mount.cifs kernel mount options: ip=192.168.0.101,unc=\\192.168.0.101\milliways,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,sec=ntlm,user=sergio,domain=milleniumfalcon,pass=********
mount error(2): No such file or directory
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)
I'm kind of lost at this point where to dig. Am I missing some setup on the NAS? Do I need some other options for the mount command?

I can successfully mount the shared folder in the file explorer (i.e. Nautilus) and then I can see the share in /run/user/1000/gvfs:

Code: Select all

cd /run/user/1000/gvfs/smb-share:server=192.168.0.101,share=milliways
ls -la
total 0
drwx------ 1 sergio sergio 0 Jul 20 09:37 .
dr-x------ 3 sergio sergio 0 Jul 20 14:28 ..
drwx------ 1 sergio sergio 0 Jul 20 09:37 Backups
drwx------ 1 sergio sergio 0 Jan 24 17:32 Media
I've digged through the forums as well as several similar issues in Stackoverflow and tried the solutions presented there but that didn't help.
I've tried forcing different versions with mount (2.0 and 3.0), but that didn't help.
Also tried different sec options.

Would really appreciate some help with this.
Last edited by serpro69 on Thu Jul 22, 2021 2:43 pm, edited 1 time in total.

User avatar
OneCD
Ask me anything
Posts: 9173
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Unable to mount NFS in ubuntu: mount error

Post by OneCD » Wed Jul 21, 2021 5:24 am

  • First, ensure you've allowed the NAS to accept your client IP address and attach to the share.

    QTS Control Panel -> Shared Folders -> find your share -> click on "Edit shared folder permission" -> from the "Select permission type" dropdown, select "NFS host access" -> enable the "Access right" checkbox -> then confirm the IP of your Ubuntu PC is within the network range shown in the "Allowed IP address or Domain name" list. Add it to the list if required.
  • On your Ubuntu client, ensure you've installed the 'nfs-common' package:

    Code: Select all

    sudo apt install nfs-common
  • Then, run your mount command. NFS doesn't make use of authentication: access is based on IP addresses-only, so no-need to specify usernames and passwords. Check the mount type - we're using 'nfs', not 'cifs'. Assuming 192.168.0.101 is the IP address of your NAS:

    Code: Select all

    sudo mount -t nfs 192.168.0.101:milliways /media/milliways
    (Milliways? The restaurant at the end of the universe? ;) )
  • Finally, confirm it has mounted:

    Code: Select all

    df /media/milliways

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage

serpro69
Starting out
Posts: 13
Joined: Sun Jan 17, 2021 5:18 pm

Re: Unable to mount NFS in ubuntu: mount error

Post by serpro69 » Wed Jul 21, 2021 1:12 pm

1. Enabled access right for the share. The allowed IP addresses allowed everything by default it seems, but I've also explicitly added the IP of the client that is trying to connect (192.168.0.103), as well as local network range with 192.168.*
2. nfs-common package was already installed
3. When trying to mount I'm getting connection time out

Code: Select all

sudo mount -t nfs 192.168.1.101:milliways /media/milliways --verbose
mount.nfs: timeout set for Wed Jul 21 07:09:24 2021
mount.nfs: trying text-based options 'vers=4.2,addr=192.168.1.101,clientaddr=192.168.0.103'
mount.nfs: mount(2): Connection timed out
mount.nfs: Connection timed out
Here are some additional tests I did:

Code: Select all

✗[130] ~→ ping 192.168.0.101
PING 192.168.0.101 (192.168.0.101) 56(84) bytes of data.
64 bytes from 192.168.0.101: icmp_seq=1 ttl=64 time=0.820 ms
64 bytes from 192.168.0.101: icmp_seq=2 ttl=64 time=0.962 ms
64 bytes from 192.168.0.101: icmp_seq=3 ttl=64 time=1.07 ms
64 bytes from 192.168.0.101: icmp_seq=4 ttl=64 time=1.09 ms
64 bytes from 192.168.0.101: icmp_seq=5 ttl=64 time=1.09 ms
64 bytes from 192.168.0.101: icmp_seq=6 ttl=64 time=1.09 ms
^C
--- 192.168.0.101 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5032ms
rtt min/avg/max/mdev = 0.820/1.020/1.094/0.100 ms

✓ ~→ rpcinfo -p 192.168.0.101
   program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
    100011    1   udp  30002  rquotad
    100011    2   udp  30002  rquotad
    100011    1   tcp  30002  rquotad
    100011    2   tcp  30002  rquotad
    100005    1   udp  30000  mountd
    100005    1   tcp  30000  mountd
    100005    2   udp  30000  mountd
    100005    2   tcp  30000  mountd
    100005    3   udp  30000  mountd
    100005    3   tcp  30000  mountd
    100003    2   tcp   2049  nfs
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    2   tcp   2049
    100227    3   tcp   2049
    100003    2   udp   2049  nfs
    100003    3   udp   2049  nfs
    100227    2   udp   2049
    100227    3   udp   2049
    100021    1   udp  53054  nlockmgr
    100021    3   udp  53054  nlockmgr
    100021    4   udp  53054  nlockmgr
    100021    1   tcp  46103  nlockmgr
    100021    3   tcp  46103  nlockmgr
    100021    4   tcp  46103  nlockmgr
    100024    1   udp  30001  status
    100024    1   tcp  30001  status

✓ ~→ rpcinfo -s 192.168.0.101|egrep 'nfs|mountd'
    100005  3,2,1     tcp,udp,tcp6,udp6                mountd      superuser
    100003  4,3,2     udp6,tcp6,udp,tcp                nfs         superuser
    
✗[1] ~→ rpcinfo -u 192.168.0.101 nfs
program 100003 version 2 ready and waiting
program 100003 version 3 ready and waiting
rpcinfo: RPC: Program/version mismatch; low version = 2, high version = 4
program 100003 version 4 is not available

✗[1] ~→ sudo mount -t nfs 192.168.1.101:milliways /media/milliways --verbose -o vers=2.0
mount.nfs: timeout set for Wed Jul 21 07:22:13 2021
mount.nfs: trying text-based options 'vers=2.0,addr=192.168.1.101'
mount.nfs: prog 100003, trying vers=2, prot=6
mount.nfs: portmap query retrying: RPC: Timed out
mount.nfs: prog 100003, trying vers=2, prot=17
mount.nfs: portmap query failed: RPC: Timed out
mount.nfs: trying text-based options 'vers=2.0,addr=192.168.1.101'
mount.nfs: prog 100003, trying vers=2, prot=6
mount.nfs: portmap query retrying: RPC: Timed out
mount.nfs: prog 100003, trying vers=2, prot=17
mount.nfs: portmap query failed: RPC: Timed out
mount.nfs: trying text-based options 'vers=2.0,addr=192.168.1.101'
mount.nfs: prog 100003, trying vers=2, prot=6

User avatar
OneCD
Ask me anything
Posts: 9173
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Unable to mount NFS in ubuntu: mount error

Post by OneCD » Wed Jul 21, 2021 1:58 pm

I don't know why those timeouts are appearing. Are you using any sort of firewall between the NAS and your client PC (including on the NAS and/or PC)?

Other than that, I'm out of ideas as it's working fine here. I set it up for the first time in my earlier post to ensure there were no issues. :S

For the record, I'm connecting from an Ubuntu 21.04 VM running in VirtualBox on a Debian 10.9 workstation, and connecting to a TS-230 running the beta QTS firmware 5.0.0.1716 (where my test NFS shares are). NFS2/3/4 all work correctly.

Maybe someone else can suggest something?

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage

User avatar
OneCD
Ask me anything
Posts: 9173
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Unable to mount NFS in ubuntu: mount error

Post by OneCD » Wed Jul 21, 2021 2:10 pm

serpro69 wrote:
Wed Jul 21, 2021 1:12 pm
... as well as local network range with 192.168.*
Oh, I just noticed your asterisk. You'll need to use CIDR notation when specifying the network range. Try 192.168.0.0/16 instead.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage

serpro69
Starting out
Posts: 13
Joined: Sun Jan 17, 2021 5:18 pm

Re: Unable to mount NFS in ubuntu: mount error

Post by serpro69 » Wed Jul 21, 2021 2:39 pm

I haven't configured firewall or anything on the NAS, so it uses defaults I suppose. The current rules on the NAS are:

Code: Select all

[~] # iptables -vL
Chain INPUT (policy ACCEPT 16800 packets, 3585K bytes)
 pkts bytes target     prot opt in     out     source               destination
 1413  222K QUFIREWALL  all  --  any    any     anywhere             anywhere             state NEW

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 CSFORWARD  all  --  any    any     anywhere             anywhere

Chain OUTPUT (policy ACCEPT 15503 packets, 6860K bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 DROP       all  --  any    any     anywhere             anywhere             match-set BRNOIPSET src,dst

Chain CSFORWARD (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain QUFIREWALL (1 references)
 pkts bytes target     prot opt in     out     source               destination
And on the client:

Code: Select all

✗[4] ~→ sudo iptables -vL
Chain INPUT (policy ACCEPT 55048 packets, 93M bytes)
 pkts bytes target     prot opt in     out     source               destination
 177K  582M LIBVIRT_INP  all  --  any    any     anywhere             anywhere

Chain FORWARD (policy DROP 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 DOCKER-USER  all  --  any    any     anywhere             anywhere
    0     0 DOCKER-ISOLATION-STAGE-1  all  --  any    any     anywhere             anywhere
    0     0 ACCEPT     all  --  any    docker0  anywhere             anywhere             ctstate RELATED,ESTABLISHED
    0     0 DOCKER     all  --  any    docker0  anywhere             anywhere
    0     0 ACCEPT     all  --  docker0 !docker0  anywhere             anywhere
    0     0 ACCEPT     all  --  docker0 docker0  anywhere             anywhere
    0     0 LIBVIRT_FWX  all  --  any    any     anywhere             anywhere
    0     0 LIBVIRT_FWI  all  --  any    any     anywhere             anywhere
    0     0 LIBVIRT_FWO  all  --  any    any     anywhere             anywhere

Chain OUTPUT (policy ACCEPT 53290 packets, 7430K bytes)
 pkts bytes target     prot opt in     out     source               destination
 145K   15M LIBVIRT_OUT  all  --  any    any     anywhere             anywhere

Chain DOCKER (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain DOCKER-ISOLATION-STAGE-1 (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 DOCKER-ISOLATION-STAGE-2  all  --  docker0 !docker0  anywhere             anywhere
    0     0 RETURN     all  --  any    any     anywhere             anywhere

Chain DOCKER-ISOLATION-STAGE-2 (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 DROP       all  --  any    docker0  anywhere             anywhere
    0     0 RETURN     all  --  any    any     anywhere             anywhere

Chain DOCKER-USER (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 RETURN     all  --  any    any     anywhere             anywhere

Chain LIBVIRT_FWI (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     all  --  any    virbr0  anywhere             192.168.122.0/24     ctstate RELATED,ESTABLISHED
    0     0 REJECT     all  --  any    virbr0  anywhere             anywhere             reject-with icmp-port-unreachable

Chain LIBVIRT_FWO (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     all  --  virbr0 any     192.168.122.0/24     anywhere
    0     0 REJECT     all  --  virbr0 any     anywhere             anywhere             reject-with icmp-port-unreachable

Chain LIBVIRT_FWX (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     all  --  virbr0 virbr0  anywhere             anywhere

Chain LIBVIRT_INP (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     udp  --  virbr0 any     anywhere             anywhere             udp dpt:domain
    0     0 ACCEPT     tcp  --  virbr0 any     anywhere             anywhere             tcp dpt:domain
    0     0 ACCEPT     udp  --  virbr0 any     anywhere             anywhere             udp dpt:bootps
    0     0 ACCEPT     tcp  --  virbr0 any     anywhere             anywhere             tcp dpt:67

Chain LIBVIRT_OUT (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     udp  --  any    virbr0  anywhere             anywhere             udp dpt:domain
    0     0 ACCEPT     tcp  --  any    virbr0  anywhere             anywhere             tcp dpt:domain
    0     0 ACCEPT     udp  --  any    virbr0  anywhere             anywhere             udp dpt:bootpc
    0     0 ACCEPT     tcp  --  any    virbr0  anywhere             anywhere             tcp dpt:68
Tried disabling firewall on the client to test - made no difference. Not sure how to disable firewall on the qnap as well though.
They're also both connected directly to same router.

I've tried the CIDR notation for the network range - that didn't seem to help either. My current allowed addresses are:
192.168.0.103/24 (this is what is shown on the client with `ip addr show`)
and 192.168.0.0/16 (as you suggested)

And also tried adding

Code: Select all

-o noresvport,proto=tcp,port=2049
options to the mount command.

Not sure if that matters, but I'm on version 4.5.4.1723 (qnap TS-653D)

serpro69
Starting out
Posts: 13
Joined: Sun Jan 17, 2021 5:18 pm

Re: Unable to mount NFS in ubuntu: mount error

Post by serpro69 » Wed Jul 21, 2021 3:11 pm

As I mentioned in the beginning of the thread, I am able to connect to and browse the files from the file manager (Nautilus) on Ubuntu as well.
But I can't mount the share to a particular dir using `mount` command.

User avatar
OneCD
Ask me anything
Posts: 9173
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Unable to mount NFS in ubuntu: mount error

Post by OneCD » Wed Jul 21, 2021 3:16 pm

Are any other clients on your LAN able to mount the shares?

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage

serpro69
Starting out
Posts: 13
Joined: Sun Jan 17, 2021 5:18 pm

Re: Unable to mount NFS in ubuntu: mount error

Post by serpro69 » Wed Jul 21, 2021 3:34 pm

I can't test that unfortunately right now as I don't have any other laptop handy.

I tried to telnet from the client to NAS with port 2049 and that works fine:

Code: Select all

✓ ~→ telnet 192.168.0.101 2049
Trying 192.168.0.101...
Connected to 192.168.0.101.
Escape character is '^]'.

^]
telnet>

I also tried to ping the client from NAS which also works fine.

Code: Select all

[~] # ping 192.168.0.103
PING 192.168.0.103 (192.168.0.103): 56 data bytes
64 bytes from 192.168.0.103: seq=0 ttl=64 time=0.944 ms
64 bytes from 192.168.0.103: seq=1 ttl=64 time=1.018 ms
64 bytes from 192.168.0.103: seq=2 ttl=64 time=0.844 ms
64 bytes from 192.168.0.103: seq=3 ttl=64 time=1.001 ms
^C
--- 192.168.0.103 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 0.844/0.951/1.018 ms

serpro69
Starting out
Posts: 13
Joined: Sun Jan 17, 2021 5:18 pm

Re: Unable to mount NFS in ubuntu: mount error

Post by serpro69 » Wed Jul 21, 2021 3:54 pm

I have a windows laptop and I've installed WSL2 with Ubuntu there, and I was able to successfully mount the share in WSL without any additional workarounds that I've tried here so far.

Code: Select all

✓ sergio:~→ sudo mount -t nfs 192.168.0.101:milliways /media/milliways --verbose
mount.nfs: mount(2): Invalid argument
mount.nfs: mount(2): Invalid argument
mount.nfs: timeout set for Wed Jul 21 10:04:00 2021
mount.nfs: trying text-based options 'vers=4.2,addr=192.168.0.101,clientaddr=172.23.154.79'
mount.nfs: trying text-based options 'vers=4.1,addr=192.168.0.101,clientaddr=172.23.154.79'
mount.nfs: trying text-based options 'vers=4.0,addr=192.168.0.101,clientaddr=172.23.154.79'

✗[1] sergio:~→ df /media/milliways
Filesystem               Type  Size  Used Avail Use% Mounted on
192.168.0.101:/milliways nfs4   12T  3.0T  8.5T  26% /media/milliway
This at least tells me the issue is, most likely, on my Ubuntu client. But I'm not sure what it could possibly be.

serpro69
Starting out
Posts: 13
Joined: Sun Jan 17, 2021 5:18 pm

Re: Unable to mount NFS in ubuntu: mount error

Post by serpro69 » Wed Jul 21, 2021 4:24 pm

I think I found the issue, and it's an embarrassing one... was using incorrect ip address 192.168.1.101 instead of 192.168.0.101 :S
Not sure at what point I started using incorrect IP and/or if anything else I've tweaked during the debugging helped as well :D But I can mount the share now.
Thanks a lot for all the help @OneCD!

serpro69
Starting out
Posts: 13
Joined: Sun Jan 17, 2021 5:18 pm

Re: Unable to mount NFS in ubuntu: mount error

Post by serpro69 » Wed Jul 21, 2021 10:06 pm

@OneCD, could you point me on how to setup proper group access rights as well?
My share is configured with 'admin' as owner and a 'marvin' group having RW rights to the entire share. My user on the NAS is part of that group.
On the client I've also created 'marvin' group as well and my local user is part of that group.
However I'm still getting permission denied when trying to access the files through the mount.
The UID/GIDs are the same on the NAS and the client:

Code: Select all

#/etc/group on NAS
marvin:x:1001:sergio

#/etc/group on ubuntu client
marvin:x:1001:sergio

#/etc/passwd on NAS
sergio:x:1000:100:Linux User,,,:/share/homes/sergio:/bin/sh

#/etc/passwd on ubuntu client
sergio:x:1000:1000:Sergio Pro,,,:/home/sergio:/usr/bin/zsh
The mount is created with root as owner:

Code: Select all

sudo mount -t nfs 192.168.0.101:milliways /media/milliways
ls -la /media/milliways

drwxrwxrwt  9 root root  4096 Jul 20 09:37 .
drwxr-xr-x  4 root root  4096 Jul 20 09:48 ..
drwxrwx---  3 root users 4096 Jul 21 10:18 Backups
drwxrwx--- 11 root root  4096 Jan 24 19:09 Books
drwxrwx---  5 root root  4096 Jan 23 15:16 Documents
drwxrwx---  7 root root  4096 Jan 24 17:32 Media
(Not sure why Backups dir has users group here because the entire 'milliways' share has the same permissions for all sub-dirs, though I can't access that either in any case.

And oddly enough, if I make my NAS user the owner of the share, then I can access the files just fine from the client with my local user.

Any idea how can I correctly configure group access permissions?

User avatar
OneCD
Ask me anything
Posts: 9173
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Unable to mount NFS in ubuntu: mount error

Post by OneCD » Thu Jul 22, 2021 4:19 am

serpro69 wrote:
Wed Jul 21, 2021 10:06 pm
@OneCD, could you point me on how to setup proper group access rights as well?
No, that's a different issue, and one I'm not qualified to answer. I try to stay out-of the share permissions topics. ;)

Please start a new topic for this.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage

Post Reply

Return to “Linux & Unix (NFS)”