📅 2013-Mar-17 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ nfs, ubuntu ⬩ 📚 Archive
NFS is a popular method to share a directory for read and write access between two Linux computers. The computer whose hard disk where the shared directory actually resides is the NFS server. The computer which will mount the directory on the NFS server for read and write access is the NFS client.
$ sudo apt install nfs-kernel-server
Add an entry in /etc/exports
that informs the NFS server which directory is being shared, to which computer on the network and with what settings.
For example, if user joe_on_server
wants to share his workspace
directory to all computers on the network:
/home/joe_on_server/workspace *(rw,sync,no_subtree_check)
The *
indicates that NFS clients of all IP addresses can access this shared filesystem. rw
indicates that the NFS client can read and write to this directory. async improves performance. no_subtree_check
also improves performance by not checking the sub-directories. no_root_squash
prevents the normal behavior of converting access by root user to normal user. insecure
turns off the checking if the access is originating from reserved ports. More information about the options can be seen in man exports
.
/home/joe_on_server/workspace 192.168.0.100(rw,sync,no_subtree_check)
Remember to ping and be sure that the hostname or IP address works.
permission denied
errors. If this is the case, then specify what UID and GID on the NFS server should be used to map all users who access on NFS client:/home/joe_on_server/workspace 192.168.0.100(rw,sync,no_subtree_check,all_squash,anonuid=1001,anongid=1001)
$ sudo exportfs -a
$ sudo service nfs-kernel-server restart
$ showmount -e
$ sudo apt install nfs-common
$ showmount -e nfs_server_hostname
$ sudo mkdir /mnt/joe_nfs_share
I do not recommend mounting to a directory inside your home directory. This can lead to all kinds of irritating UID and GID permission problems.
/etc/fstab
to request NFS to mount to this directory:nfs_server_hostname:/home/joe_on_server/workspace /mnt/joe_nfs_share none bind 0 0
$ sudo mount /mnt/joe_nfs_share
That is it! You should be able to have read and write access to files in your NFS share on the client machine.
If you run into any problems, please check these:
Hostname or IP should be pingable
UID and GID of users on NFS server and NFS client machines
If you make any change to file permissions, remember to umount
on NFS client machine and mount again.
I found the NFS Overview and Gotchas very useful to setup and debug my NFS problems.
Tried with: Ubuntu 14.04