NFS is the abbreviation of Network File System. It can allow the remote access of files and directories just like the local one.
In this tutorial, we cover how to setup pcDuino as a NFS server.
Install NFS software:
$sudo apt-get install nfs-kernel-server
Open /etc/exports file, and append the following line:
$vim /etc/exports /home/ubuntu *(rw,sync,no_root_squash)
Note: The directory and user rights definition are done in file /etc/exports. It can be explained as following:
/home/ubuntu: the directory for sharing
*: allow access from all network
rw: Read and write
sync: the files are written internally and to the hard drive
no_root_squash: the nfs client shares the user rights of the shared directory.
$sudo /etc/init.d/portmap restart <—reboot portmap， $sudo /etc/init.d/nfs-kernel-server restart <—reboot nfs service $showmount -e <—show the shared directory
Note: NFS is a RPC program. Before use it, we need to configure the port mapping, which can be done using portmap.
The following is the log:
ubuntu@ubuntu:~$sudo /etc/init.d/portmap restart Rather than invoking init scripts through /etc/init.d, use the service(8) utility, e.g. service portmap restart Since the script you are attempting to invoke has been converted to an Upstart job, you may also use the restart(8) utility, e.g. restart portmap portmap start/running, process 474 ubuntu@ubuntu:~$sudo /etc/init.d/nfs-kernel-server restart * Stopping NFS kernel daemon [ OK ] * Unexporting directories for NFS kernel daemon... [ OK ] * Exporting directories for NFS kernel daemon... exportfs: /etc/exports : Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/home/xgc". Assuming default behaviour ('no_subtree_check'). NOTE: this default has changed since nfs-utils version 1.0.x [ OK ] * Starting NFS kernel daemon [ OK ] ubuntu@ubuntu:~$showmount -e /home/ubuntu *
Now we can test it on the locally:
$sudo mount -t nfs localhost:/home/ubuntu /mnt
Note: localhost is the IP address of the local linux machine.
It will mount the shared directory to /mnt. To cancel it, we use:
$sudo umount /mnt
If we want to use it on an embedded device like pcDuino, please add -o nolock.
So on the pcDuino the command will be:
$sudo mount -t nfs -o nolock 192.168.1.8:/home/ubuntu /mnt
Leave a Reply
You must be logged in to post a comment.