NFS mounts work to share a directory between several virtual servers. This has the advantage of saving disk space, as the home directory is only kept on one virtual private server, and others can connect to it over the network. When setting up mounts, NFS is most effective for permanent fixtures that should always be accessible.
Setup
An NFS mount is set up between at least two virtual servers. The machine hosting the shared network is called the server, while the ones that connect to it are called ‘clients’.
Setting Up the NFS Server
Step One—Download the Required Software
Start off by using apt-get to install the nfs programs.
Step Two—Export the Shared Directory
The next step is to decide which directory we want to share with the client server. The chosen directory should then be added to the /etc/exports file, which specifies both the directory to be shared and the details of how it is shared.
/var/nfs <client ip>(rw,sync,no_subtree_check)
-
rw: This option allows the client server to both read and write within the shared directory
-
sync: Sync confirms requests to the shared directory only once the changes have been committed.
-
no_subtree_check: This option prevents the subtree checking. When a shared directory is the subdirectory of a larger filesystem, nfs performs scans of every directory above it, in order to verify its permissions and details. Disabling the subtree check may increase the reliability of NFS, but reduce security.
-
no_root_squash: This phrase allows root to connect to the designated directory
Setting Up the NFS Client
Step One—Download the Required Software
Start off by using apt-get to install the nfs programs.
Step Two—Mount the Directories
Once the programs have been downloaded to the the client server, create the directories that will contain the NFS shared files
mkdir -p /mnt/nfs/var/nfs
mount <server ip>:/var/nfs /mnt/nfs/var/nfs
/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
<server ip>:/home 20G 948M 19G 5% /mnt/nfs/home
<server ip>:/var/nfs 20G 948M 19G 5% /mnt/nfs/var/nfs
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)
12.34.56.789:/home on /mnt/nfs/home type nfs (rw,vers=4,addr= 12.34.56.789,clientaddr=12.33.44.555)
12.34.56.789:/var/nfs on /mnt/nfs/var/nfs type nfs (rw,vers=4,addr=12.34.56.78,clientaddr=12.33.44.555)
Leave a Comment