Setup NFS server on Ubuntu

Install NFS server

sudo apt-get update
sudo apt-get install -y nfs-common nfs-kernel-server

Create the shared dircetory
In Unix-like, the NFS is the most convenient way to share your file in the local network.

mkdir /home/$USER/root_nfs
chmod 777 -R /home/$USER/root_nfs

Added the export directory for sharing your data

sudo vim /etc/exports
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
#
#/home 192.168.0.101(rw,sync,no_root_squash,no_subtree_check)
#/var/nfs 192.168.0.101(rw,sync,no_subtree_check)


/home/${YOUR_USER_NAME}/root_nfs *(ro,no_root_squash,no_all_squash)

 ${YOUR_USER_NAME} should change to your user name, e.g. /home/mirochiu/root_nfs

Apply the setting for sharing data
$sudo exportfs -arv

Show the shared directories
$showmount -e localhost

Mount the NFS in other PC
$sudo mkdir /mnt/nfs
$sudo mount ${NFS_SERVER_IP}:/home/${NFS_SERVER_USER_NAME}/root_nfs /mnt/nfs


Reference:
http://www.howtoforge.com/setting-up-an-nfs-server-and-client-on-ubuntu-10.04
http://go-linux.blogspot.tw/2007/07/ubuntu-nfs-server.html
http://linux.vbird.org/linux_server/0330nfs.php#exportfs

留言