apt-get install nfs-kernel-server portmap
mkdir /var/nfs/Second, we should change the ownership of the directory to the user, nobody and the group, no group. These represent the default user through which clients can access a directory shared through NFS.
chown nobody:nogroup /var/nfsAfter completing those steps, it’s time to export the directories to the other server:
nano /etc/exportsAdd the following lines to the bottom of the file, sharing both directories with the client:
/home 22.214.171.1245(rw,sync,no_root_squash,no_subtree_check) /var/nfs 126.96.36.1995(rw,sync,no_subtree_check)These settings accomplish several tasks:
apt-get install nfs-common portmap
mkdir -p /mnt/nfs/home mkdir -p /mnt/nfs/var/nfsThen go ahead and mount them
mount 188.8.131.529:/home /mnt/nfs/home mount 184.108.40.2069:/var/nfs /mnt/nfs/var/nfsYou can use the df -h command to check that the directories have been mounted. You will see them last on the list.
Filesystem Size Used Avail Use% Mounted on /dev/sda 20G 948M 19G 5% / udev 119M 4.0K 119M 1% /dev tmpfs 49M 208K 49M 1% /run none 5.0M 0 5.0M 0% /run/lock none 122M 0 122M 0% /run/shm 220.127.116.119:/home 20G 948M 19G 5% /mnt/nfs/home 18.104.22.1689:/var/nfs 20G 948M 19G 5% /mnt/nfs/var/nfsAdditionally, use the mount command to see the entire list of mounted file systems.
mountYour list should look something like this:
/dev/sda on / type ext4 (rw,errors=remount-ro,barrier=0) [DOROOT] proc on /proc type proc (rw,noexec,nosuid,nodev) sysfs on /sys type sysfs (rw,noexec,nosuid,nodev) none on /sys/fs/fuse/connections type fusectl (rw) none on /sys/kernel/debug type debugfs (rw) none on /sys/kernel/security type securityfs (rw) udev on /dev type devtmpfs (rw,mode=0755) devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620) tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755) none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880) none on /run/shm type tmpfs (rw,nosuid,nodev) rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw) 22.214.171.1249:/home on /mnt/nfs/home type nfs (rw,vers=4,addr= 126.96.36.1999,clientaddr=188.8.131.525) 184.108.40.2069:/var/nfs on /mnt/nfs/var/nfs type nfs (rw,vers=4,addr=220.127.116.11,clientaddr=18.104.22.1685)
touch /mnt/nfs/home/example /mnt/nfs/var/nfs/exampleYou should then be able to find the files on the Server in the /home and /var/nfs directories.
ls /var/nfs/You can ensure that the mount is always active by adding the directories to the fstab file on the client. This will ensure that the mounts start up after the server reboots.
22.214.171.1249:/home /mnt/nfs/home nfs auto,noatime,nolock,bg,nfsvers=3,intr,tcp,actimeo=1800 0 0 126.96.36.1999:/var/nfs /mnt/nfs/var/nfs nfs auto,noatime,nolock,bg,nfsvers=3,intr,tcp,actimeo=1800 0 0You can learn more about the fstab options by typing in:
man nfsAny subsequent restarts will include the NFS mount—although the mount may take a minute to load after the reboot You can check the mounted directories with the two earlier commands:
cd sudo umount /directory nameYou can see that the mounts were removed by then looking at the filesystem again.
df -hYou should find your selected mounted directory gone.
Article ID: 169
Created On: Tue, Dec 24, 2013 at 12:45 AM
Last Updated On: Sun, Jan 5, 2014 at 9:04 PM
Authored by: ASPHostServer Administrator [email@example.com]
Online URL: http://faq.asphosthelpdesk.com/article.php?id=169