Setting up a simple NFS share
I migrated to Citrix Xenserver yesterday and needed an ISO storage point for my custom OS installs – the easiest solution for this? NFS ( Network File System ) This awesome tool is way to mount other machines across the network as if it was a local file system. In this case I am using an internal backend network that is non-internet facing to share these files with my Xenserver host from a vm. In a nutshell here is a quickway to get a simple share up and running.
This information assumes that 10.8.126.83 is the NFS server and that 10.8.126.82 is the NFS client.
With CentOS/RedHat – NFS and everything needed comes pre-installed by default. You may need to install the nfs-utils packages as shown below:
[root@dev ~]# rpm -qa | grep nfs nfs-utils-1.0.9-42.el5 system-config-nfs-1.3.23-1.el5 nfs-utils-lib-1.0.8-7.6.el5
and you will need to make sure it is configured to start at boot time:
[root@dev ~]# chkconfig --list | grep nfs nfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off nfslock 0:off 1:off 2:off 3:on 4:on 5:on 6:off
Server configuration:
In my example here I created a directory called /export/iso for my xenserver iso repository. In order to get this properly shared you will need to create an /etc/exports entry like what shown below:
[root@dev ~]# cat /etc/exports /export/iso (insecure,no_root_squash,rw)
Now we will use exportfs to get the NFS server to start serving this directory:
[root@dev ~]# exportfs -ra exportfs: No host name given with /export/iso (insecure,no_root_squash,rw), suggest *(insecure,no_root_squash,rw) to avoid warning
This gives us a warning based on my config but does not affect the operation. You can set this to serve off a specific hostname if you wish.
Now you will need to add the NFS client ip/hostname to the /etc/hosts.allow config of the NFS server:
[root@dev ~]# cat /etc/hosts.allow # # hosts.allow This file describes the names of the hosts which are # allowed to use the local INET services, as decided # by the '/usr/sbin/tcpd' server. # portmap: 10.8.126.82/255.255.255.0
From here it is now just a matter of mounting the share from the other system. In xenserver there is a storage addition gui for this but we will run through how to mount it from another Linux system as this is what most people will do with it anwyay:
[root@www ~]# mount 10.8.126.83:/export/iso /mnt/
and the end result is:
[root@www ~]# mount | grep mnt 10.8.126.83:/export/iso on /mnt type nfs (rw,addr=10.8.126.83)
and everything now works great!:
[root@www ~]# ls /mnt/ 8.0-RELEASE-i386-disc1.iso ubuntu-9.10-server-i386.iso Fedora-12-i386-netinst.iso
There are tons of options for setting up NFS – my configuration is just for a very basic share.To learn more advanced usage I would check this site out http://nfs.sourceforge.net/ . I hope someone out there finds this useful.
