How to install a network drive for use with LiveView - nasa-jpl/LiveViewOpenCL GitHub Wiki

Background

This procedure describes how to install a networked drive on a data server using the NFS protocol and mount on a client server so that LiveView can display data in real-time over ethernet.


Procedure

Install NFS on LVDS Data server (e.g., RDUCE2 in 303-214)

  1. Check the disk to see which file system you would like to mount.
    $ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2             289G  9.3G  265G   4% /
tmpfs                 127G   11M  127G   1% /dev/shm
/dev/sda1             485M   38M  422M   9% /boot
/dev/sdb1             938G  797G  141G  86% /data
/dev/sda5             173G  102G   63G  63% /home
b600-cdot3-svm3:/rduce2_storage
2.0T  551G  1.4T  29% /backup
  1. Install nfs if it is not already installed on the server.
    $ sudo apt-get update
    $ sudo apt-get install nfs-kernel-server

Modify /etc/exports to add allowed clients

The file /etc/exports on the server is used by nfs to determine which machines, based on their IP address, are allowed to access the server, and which "file system", or directory, that each client is allowed to access. In this case we will allow the client rduce5 to access the /data/ directory on our server.

  1. Check the /etc/exports file. In this case, the /etc/exports file is empty
    $ cat /etc/exports
  1. Edit the file to add the directory you would like the client to access, the name or IP address of the client, and the options (ro,no_root_squash). Note that some clients may not have their DNS set up to address the server by name, in this case the client should be added to /etc/exports by their IP address. You can check this by trying to ping the client by name, i.e., ping rduce5. If that is unsuccessful, find the client's IP.
    $ vim /etc/exports
    $ more /etc/exports
# Can add clients by name
/data    rduce5(ro,no_root_squash)
# Or by IP...
/data    178.213.125.20(ro,no_root_squash)

Restart the NFS service on the server

The changes to exports file must be committed to the server by restarting the NFS service.

  1. Stop the NFS service, assuming it is running. If it is not running, skip to step 7.
    $ sudo /etc/init.d/nfs stop
Shutting down NFS daemon:                                  [  OK  ]
Shutting down NFS mountd:                                  [  OK  ]
Shutting down NFS quotas:                                  [  OK  ]
Shutting down NFS services:                                [  OK  ]
  1. (Optional) Check the status of the NFS service to ensure it is shut down
    $ sudo /etc/init.d/nfs status
rpc.svcgssd is stopped
rpc.mountd is stopped
nfsd is stopped
rpc.rquotad is stopped
  1. Restart the NFS service. Make sure that everything is OK!
    $ sudo /etc/init.d/nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Stopping RPC idmapd:                                       [  OK  ]
Starting RPC idmapd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]

Setup of LiveView Client (e.g., RDUCE5 in 303-214)

NOTE: do not use nfs3; use nfs.

  1. Modify /etc/fstab. Note that the important lines are LABEL=RDUCE_DATA and rduce2:/data. If you cannot ping the server by name, you should replace rduce2 with the server's IP address.

WARNING: DO NOT EDIT THE OTHER LINES OF THIS FILE. DO NOT COPY FROM THE EXAMPLE. IF YOU MESS UP THE UUID VALUES IN THE ROOT LINES THE OS WILL NOT BE ABLE TO MOUNT ROOT AND THE SYSTEM WILL BE BRICKED WHEN YOU REBOOT

    $ sudo vim /etc/fstab
    $ more /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Feb  6 16:13:56 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
#
...
137.79.152:/data            /mnt/rduce2_data        nfs       auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0

Use the IP address instead of the hostname of "rduce2", and add the options instead of "defaults" to make the mounting safer and more consistent.

Create a data directory and mount it

The client will need to have its own directory that contains the NFS-mounted data. By convention, this is typically put into the /mnt/ directory from root. The data is accessible from here, but does not actually take up disk space on the host machine.

  1. Create a directory rduce2_data or some similar name.
    $ sudo mkdir /mnt/rduce2_data
  1. Mount the directory.
    $ sudo mount -vv /mnt/rduce2_data

Verify that the data is mounted

  1. Check the directory with ls.
    $ ls -la
total 68
drwxrwxr-x. 16 rduce rduce 4096 Mar 12 14:25 .
drwxrwxr-x.  7 rduce rduce 4096 Apr 20 13:37 ..
drwxrwxr-x.  2 rduce rduce 4096 Apr 28  2016 7V1_CPLD
drwxrwxr-x.  3 rduce rduce 4096 May  3  2016 debug
drwxrwxr-x.  3 rduce rduce 4096 Jan 26  2017 flex_codec
drwxrwxr-x.  2 rduce rduce 4096 Jul 25  2016 fpia_soc_f
drwxr-xr-x.  8 rduce rduce 4096 Sep 18  2017 fpia_soc_f_flex_codec
drwxrwxr-x.  3 rduce rduce 4096 Jul 25  2016 fpia_soc_f_simulation_blocks
drwxrwxr-x.  3 rduce rduce 4096 Mar 12 14:21 fpia_soc_gse_software_verification
drwxrwxr-x. 12 rduce rduce 4096 Jun 13  2017 fpia_soc_s
drwxrwxr-x. 12 rduce rduce 4096 Oct  6  2017 fpia_soc_s_branchesprism2
drwxrwxr-x.  4 rduce rduce 4096 Mar 20  2017 fpia_soc_serial
drwxrwxr-x. 13 rduce rduce 4096 Apr 12 01:05 fpia_soc_s_matt_serialimu_remote
drwxrwxr-x. 11 rduce rduce 4096 Nov 14  2016 fpia_soc_s_omid
drwxrwxr-x.  6 rduce rduce 4096 Aug 24  2016 obsolete
drwxrwxr-x. 10 rduce rduce 4096 Apr 20  2017 prism2emu_s
-rw-rw-r--.  1 rduce rduce  913 Aug 11  2016 prism2mu_s_README.txt

Troubleshooting

If you are able to ping the server from the client but get No route to host when trying to mount there may be an issue with the firewall on the system. You can check if this is the issue by running on the host service iptable stop and attempting to mount again with mount rduce2_data/. If this works then the issue is the iptable. If not, then try disabling iptable on the host too, but I don't really know how to fix the issue if this fixes it. Regardless do not leave iptable disabled. On the host, run service iptable start to reenable iptable, and run iptable-save > ipedit. With a text editor open ipedit and add the following lines above the line containing COMMIT:

-A INPUT -s rduce5/24 -d rduce2/24 -p udp -m multiport --dports 10053,111,2049,32769,875,892 -m state --state NEW,ESTABLISHED -j ACCEPT
-A INPUT -s rduce5/24 -d rduce2/24 -p tcp -m multiport --dports 10053,111,2049,32803,875,892 -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -s rduce5/24 -d rduce2/24 -p udp -m multiport --sports 10053,111,2049,32769,875,892 -m state --state ESTABLISHED -j ACCEPT
-A OUTPUT -s rduce5/24 -d rduce2/24 -p tcp -m multiport --sports 10053,111,2049,32803,875,892 -m state --state ESTABLISHED -j ACCEPT
-I INPUT  -i lo -d 127.0.0.1 -j ACCEPT
-I OUTPUT  -o lo -s 127.0.0.1 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-L -n --line-numbers

(If you're trying to do this on a system other than rduce5, just replace rduce5 with the host name or ip of the computer you're trying to connect from).

Now run iptables-restore < ipedit and return to step 3!

Something has changed but now the "Connection refused"

    $ sudo mount -vv /mnt/rduce2_data
final mount options: '(null)'
mount.nfs4: timeout set for Fri Apr 20 22:48:40 2018
mount.nfs4: trying text-based options 'addr=137.79.152.28,clientaddr=137.79.152.30'
mount.nfs4: mount(2): Connection refused
mount.nfs4: trying text-based options 'addr=137.79.152.28,clientaddr=137.79.152.30'
mount.nfs4: mount(2): Connection refused

Change "nfs4" to "nfs"

    $ sudo mount -vv /mnt/rduce2_data/
final mount options: '(null)'
mount.nfs: timeout set for Fri Apr 20 22:49:49 2018
mount.nfs: trying text-based options 'vers=4,addr=137.79.152.28,clientaddr=137.79.152.30'
rduce2:/data on /mnt/rduce2_data type nfs (rw)

Check /mnt once again

Finally you will be able to see data on rduce2 from rduce5 at /mnt/rduce2_data/

    $ ls
rduce2_data
    $ cd rduce2_data/
    $ ls
avirisng  cae_tools  Downloads  ecostress  firefox  klimesh  lost+found  prismII  rduce  users
    $ sudo touch test # Type Ctrl + C to exit. 
^C