How to mount network file system (NFS) on SP7021
The aim of the document is to illustrate how to mount network file system (NFS). That is, mount a remote file folder which is exported by NFS server in remote host. Please follow the following steps.
1. Install NFS server
To mount a folder-system from a remote folder, you need to install a NFS server in your Linux PC or server. There are five sub-steps to complete this:
First, use apt command to install NFS server. For example, install package nfs-kernel-server by issuing command:
wells@wells-linux:~/q628/sdc$ sudo apt install nfs-kernel-serverSecond, modify NFS configuration file, /etc/exports, to export the folders for NFS service.
/home/nfs/aaa 192.168.1.0/24(rw,no_subtree_check,no_root_squash)where 192.168.1.0/24 is address of sub-net. Adding the line listed above will create the NFS share folder, /home/nfs/aaa.
Third, notify the NFS sever that the settings has changed by issuing command:
wells@wells-linux:~/q628/sdc$ sudo exportfs -a -v
exporting 192.168.1.0/24:/home/nfs/aaawhere “-a” means export all folders listed in the configuration file. “-v” means be verbose.
You can use showmount command to list folders which have been exported by NFS server. For example, issue command as:
wells@wells-linux:~/q628/sdc$ showmount -e
Export list for wells-linux:
/home/nfs/aaa 192.168.1.0/24where “-e” means show export list of NFS server.
Finally, re-start NFS server by issuing commands:
wells@wells-linux:~/q628/sdc$ sudo /etc/init.d/nfs-kernel-server restart2. Up net interface
Use ifup command to turn on (up) the net interface eth0. Issue command as:
~ # ifup eth0
udhcpc: started, v1.31.1
Setting IP address 0.0.0.0 on eth0
udhcpc: sending discover
udhcpc: sending select for 192.168.0.101
udhcpc: lease of 192.168.0.101 obtained, lease time 122
Setting IP address 192.168.0.101 on eth0
Deleting routers
route: SIOCDELRT: No such process
Adding router 192.168.0.1
Recreating /etc/resolv.conf
Adding DNS server 192.168.0.1
~ #udhcpc gets IP addresses of localhost (itself), gateway and DNS server. In this example, IP address of localhost is 192.168.0.101.
Please skip this step if your net interface has been up.
3. Mount network file system (file folder exported by NFS)
Use mount command to mount network file system. Issue command as:
~ # mount -t nfs -o nolock 192.168.0.100:/home/nfs/aaa /mntwhere “-t nfs” means mount network file-system. “-o nolock” means does not lock file system. This is necessary when you are using Busybox because Busybox does not support portmap and cannot support 'lock' function. “192.168.0.100“ is IP address of NFS server. “/home/nfs/aaa“ is folder exported by NFS. “/mnt“ is mount point.
Refer to report of ll command for the contents of remote file-system mounted on /mnt:
~ # ls -al /mnt
drwxr-xr-x 14 root root 4096 Oct 15 2020 .
drwxr-xr-x 15 root root 4096 Jan 1 00:00 ..
drwxr-xr-x 2 root root 4096 Oct 15 2020 bin
drwxr-xr-x 2 root root 4096 Oct 15 2020 dev
drwxr-xr-x 4 root root 4096 Oct 15 2020 etc
lrwxrwxrwx 1 root root 11 Oct 15 2020 init -> bin/busybox
drwxr-xr-x 4 root root 4096 Oct 15 2020 lib
lrwxrwxrwx 1 root root 11 Oct 15 2020 linuxrc -> bin/busybox
drwxr-xr-x 2 root root 4096 Oct 15 2020 mnt
drwxr-xr-x 2 root root 4096 Oct 15 2020 proc
drwxr-xr-x 3 root root 4096 Oct 15 2020 root
drwxr-xr-x 2 root root 4096 Oct 15 2020 sbin
drwxr-xr-x 2 root root 4096 Oct 15 2020 sys
drwxr-xr-x 2 root root 4096 Oct 15 2020 tmp
drwxr-xr-x 6 root root 4096 Oct 15 2020 usr
drwxr-xr-x 3 root root 4096 Oct 15 2020 varRefer to report of df command for remote file-system mounted on /mnt:
~ # df -hT /mnt
Filesystem Type Size Used Available Use% Mounted on
192.168.0.100:/home/nfs/aaa
nfs 271.1G 41.4G 215.9G 16% /mnt