Building an NFS files system.
Notice: any thing printed in **BOLD** is ment to be typed.
Step1: identify your systems
I will be using a three system set up one server and two clients
NFS Server: Mellow.student.lab IP address: 10.80.2.232
NFS Client: Purple.student.lab IP address: 10.80.2.231
NFS Client: Frosty.student.lab IP address: 10.80.2.230
Step2: Installing NFS
To install NFS on the server run:
**apt-get install nfs-kernel-server nfs-common portmap
**
Then on the clients we installed NFS as follows:
**apt-get install nfs-common portmap**
Step 3: Exporting NFS files system.
server:
**mkdir /var/nfs
chown nobody:nogroup /var/nfs
**
Then edit /etc/exports
**vi /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 10.80.3.230(rw,sync,no_root_squash,no_subtree_check) 10.80.3.231(rw,sync,no_root_squash,no_subtree_check)** #setups nfs access for the two clients \\
/vicepa 10.80.3.14(rw,sync,no_root_squash,no_subtree_check) # setup to give access to a virual server 14 for the virual disk.
Whenever we modify /etc/exports, we must run
**exportfs -a**
afterwords to make the changes effective.
Step4: Mounting The NFS Shares On The Clients
First we create the directories where we want to mount the NFS shares:
**mkdir -p /xen
**
Then we can mount them as follows:
**mount 10.80.3.232:/home /xen**
You should now see the NFS shares in the outputs of
client:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda1 12G 772M 11G 7% /
tmpfs 129M 0 129M 0% /lib/init/rw
udev 10M 1.6M 8.5M 16% /dev
tmpfs 129M 0 129M 0% /dev/shm
10.80.3.232:/home 37G 7.9G 27G 23% /xen
:~# mount
/dev/hda1 on / type ext3 (rw,errors=remount-ro) \\
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755) \\
proc on /proc type proc (rw,noexec,nosuid,nodev) \\
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev) \\
procbususb on /proc/bus/usb type usbfs (rw) \\
udev on /dev type tmpfs (rw,mode=0755) \\
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev) \\
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620) \\
10.80.3.232:/home on /xen type nfs (rw,addr=10.80.3.232) \\
Step 5: Mounting NFS Shares At Boot Time
Instead of mounting the NFS shares manually on the client, you could modify /etc/fstab so that the NFS shares get mounted automatically when the client boots.
Open /etc/fstab and append the following lines:
:~# vi /etc/fstab
# /etc/fstab: static file system information. \\
# \\
# \\
\\
proc /proc proc defaults 0 0 \\
/dev/hda1 / ext3 errors=remount-ro 0 1 \\
/dev/hda5 none swap sw 0 0 \\
/dev/hdc /media/cdrom0 udf,iso9660 user,noauto 0 0 \\
/dev/fd0 /media/floppy0 auto rw,user,noauto 0 0 \\
**10.80.3.232:/home /xen nfs rw,sync,hard,intr 0 0** \\
To test if your modified /etc/fstab is working, reboot the client:
:~# **reboot**
After the reboot, you should find the NFS shares in the outputs of
:~# **df -h**
Filesystem Size Used Avail Use% Mounted on \\
/dev/hda1 12G 772M 11G 7% / \\
tmpfs 129M 0 129M 0% /lib/init/rw \\
udev 10M 1.6M 8.5M 16% /dev \\
tmpfs 129M 0 129M 0% /dev/shm \\
10.80.3.232:/home 37G 7.9G 27G 23% /xen \\
:~# **mount**
\\
proc /proc proc defaults 0 0 \\
/dev/hda1 / ext3 errors=remount-ro 0 1 \\
/dev/hda5 none swap sw 0 0 \\
/dev/hdc /media/cdrom0 udf,iso9660 user,noauto 0 0 \\
/dev/fd0 /media/floppy0 auto rw,user,noauto 0 0 \\
10.80.3.232:/home /xen nfs rw,sync,hard,intr 0 0 \\