Terminal hangs when mounting nfs files

6,443

I figured out that by disabling the firewalls on both the client and the server, the mount and showmount commands works just fine.

I've tried disabling the firewalls on server and client, and it's all sprung into life. Generally, if client and server are not on the same trusted network, running NFS between them isn't a great idea - not least because it doesn't play with dumb firewalls very well. If they are on the same trusted network, then a more blanket permit on each system for input traffic from the other will probably keep things working.

Share:
6,443

Related videos on Youtube

Lublaut
Author by

Lublaut

Updated on September 18, 2022

Comments

  • Lublaut
    Lublaut over 1 year

    I am creating a NFS share. I've configured the NFS server and also the NFS client.

    My share was working perfectly fine until yesterday and now I found out it doesn't work.

    I redid all the steps of NFS configuration and it still doesn't work.

    My problem is that when I try to access my mount folder using cat /mnt/nfs1.txt (which was working perfectly fine until yesterday), nothing appears on the screen. And it looks like it is hanged or it collapsed.

    root@ela-native:~# cat /mnt/nfs1.txt
    

    After this nothing appears on the screen and also I have to close the terminal to quit.

    What am I doing wrong?

    Edit1

    The following are the steps in my configurations for the nfs:

    NFS server:

    sudo apt-get install nfs-kernel-server
    
    sudo mkdir /var/nfs/general
    
    sudo nano /etc/exports
    
      /var/nfs/general *(rw,sync,no_root_squash,no_subtree_check)
    
    sudo exportfs -a
    
    sudo service nfs-kernel-server start
    

    NFS client:

    sudo apt-get install nfs-common
    
    sudo mount 172.21.215.101:/var/nfs/general /mnt
    

    And also if i run mount -t nfs, i get this:

    root@ela-native:/home/salini# mount -t nfs
    172.21.215.101:/var/nfs/general on /mnt type nfs (rw,vers=4,addr=172.21.215.101,clientaddr=192.168.164.78)
    

    I also tried showmount -e 172.21.215.101 i got

    clnt_create: RPC: Port mapper failure - Timed out 
    

    Edit2

    And the i tried less /var/log/boot.log in the server machine and according to my understanding, i think that there is some error with the nfs server.

    [ESC[0;1;31mFAILEDESC[0m] Failed to start Automatically refresh installed snaps.
    
    
     [ESC[0;1;31mFAILEDESC[0m] Failed to mount /mnt/nfs/var/nfs.
        See 'systemctl status mnt-nfs-var-nfs.mount' for details.
       [ESC[0;1;33mDEPENDESC[0m] Dependency failed for Remote File Systems.
                 Starting Permit User Sessions...
                 Starting LSB: VirtualBox Linux kernel module...
                 Starting LSB: Set the CPU Frequency Scaling governor to "ondemand"...
                 Starting LSB: Speech Dispatcher...
                 Starting LSB: automatic crash report generation...
                 Starting LSB: Apache2 web server...
                 Starting LSB: daemon to balance interrupts for SMP systems...
        [ESC[0;32m  OK  ESC[0m] Mounted /mnt/nfs/home.
    

    What is the problem here?

    Edit3

    I did sudo ufw status numbered and sudo netstat -nlp | grep :111. I got this:

    root@wsm-ela-inc6:/home/test# sudo ufw status numbered
    Status: active
    
         To                         Action      From
         --                         ------      ----
    [ 1] 514/tcp                    ALLOW IN    Anywhere                  
    [ 2] 514/udp                    ALLOW IN    Anywhere                  
    [ 3] 514/tcp (v6)               ALLOW IN    Anywhere (v6)             
    [ 4] 514/udp (v6)               ALLOW IN    Anywhere (v6)             
    
    root@wsm-ela-inc6:/home/test# sudo netstat -nlp | grep :111
    tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      3062/rpcbind    
    tcp6       0      0 :::111                  :::*                    LISTEN      3062/rpcbind    
    udp        0      0 0.0.0.0:111             0.0.0.0:*                           3062/rpcbind    
    udp6       0      0 :::111                  :::*                                3062/rpcbind    
    

    Edit4

    I tried again for showmount but then again the terminal give me this

    clnt_create: RPC: Port mapper failure - Timed out
    

    Also I tried sudo service portmap restart and i got portmap: unrecognized service. Also i tried sudo service statd restart, it went well. Then again i tried showmount but still the same problem.

    Edit5

    I also tried netstat and got this:

        tcp        0      0 wsm-ela-inc6.csez:52630 maa03s29-in-f2.1e:https ESTABLISHED
    tcp        0      0 wsm-ela-inc6.csez.z:nfs wsm-ela-inc6.csez.z:890 ESTABLISHED
    tcp        0      0 wsm-ela-inc6.csez:34388 stackoverflow.com:https ESTABLISHED
    tcp        0      0 wsm-ela-inc6.csez:35504 maa05s06-in-f8.1e:https TIME_WAIT  
    tcp        0      0 wsm-ela-inc6.csez.z:890 wsm-ela-inc6.csez.z:nfs ESTABLISHED
    tcp        0      0 wsm-ela-inc6.csez:39524 maa03s22-in-f2.1e:https TIME_WAIT  
    tcp        0      0 wsm-ela-inc6.csez:shell 192.168.164.78:58982    ESTABLISHED
    tcp        0      0 wsm-ela-inc6.csez:34414 stackoverflow.com:https ESTABLISHED
    tcp        0      0 wsm-ela-inc6.csez:34438 stackoverflow.com:https ESTABLISHED
    

    Someone please help me. I'm desperate.

    • steeldriver
      steeldriver almost 6 years
      Do you have a firewall on the server that might be blocking the portmapper port? see for example NFS Client Unable to Mount Shared Directory
    • Lublaut
      Lublaut almost 6 years
      @steeldriver Edited post
    • steeldriver
      steeldriver almost 6 years
      So you don't seem to be allowing either the portmapper (111) or the nfs server port itself (2049)
    • Lublaut
      Lublaut almost 6 years
      What command should i use when my server IP is : 172.21.215.101 and client IP: 192.168.164.78
    • steeldriver
      steeldriver almost 6 years
      Do you actually want to restrict access to a single client (in spite of the wildcard in your /etc/exports)?
    • Lublaut
      Lublaut almost 6 years
      No i could add clients as i go on. But for now I'm trying with a single client
    • steeldriver
      steeldriver almost 6 years
      So perhaps limit to the client's LAN segment? sudo ufw allow from 192.168.1.0/24 to any port 111 (and similar for 2049)