Board index Linux NFS

Moderator: chandranjoy

NFS Installation on Linux - How to?

Postby chandranjoy » Sun Nov 21, 2010 7:12 pm

Setting up NFS Server in Linux Mint 7 / Ubuntu 9.04 Linux

Tags: exportfs, exports, Linux, NFS, portmap, rpcinfo, share, showmount, Ubuntu

There are times when we wish to setup a share to export to the virtual machines running inside out Ubuntu System. This is how I’ve set that up, just blogging them here for any future reference for me as well as for others,

First make sure you’ve all the NFS related packages & libraries installed,
$ sudo apt-get install portmap nfs-common nfs-kernel-server


In CentOS ,
yum install portmap nfs-common nfs-kernel-server


(The first two packages are sufficient if we’re only going to use the system as NFS client. nfs-kernel-server is required for NFS server)

After installation, make sure that the loopback address isn’t bound to portmap (which will disable external clients from mounting the exports) in the portmap configuration file.

$ cat /etc/default/portmap
# Portmap configuration file
#
# Note: if you manually edit this configuration file,
# portmap configuration scripts will avoid modifying it
# (for example, by running ‘dpkg-reconfigure portmap’).

# If you want portmap to listen only to the loopback
# interface, uncomment the following line (it will be
# uncommented automatically if you configure this
# through debconf).
#OPTIONS="-i 127.0.0.1"

Note:
By default, it is commented only in this version 6.0. So we needn’t have to make any changes.
$ portmap -V

portmap version 6.0 – 2007-May-11
(Note: If you find that it is uncommented & enabled in this configuration file, then reconfigure it using
"sudo dpkg-reconfigure portmap" & then restart portmapper using "sudo /etc/init.d/portmap restart")

Then edit the file /etc/exports & define the shares in the format

"<share_directory> client1(share_options_separated_by_commas) client2(share_options_separated_by_commas)..."

The following are contents of the sample exports file,
$ cat /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)
#
### Sharing for exporting to Virtualbox’s Virtual Machines ###
/home/satheesh/Virtual_Machines/Virtualbox_Share 192.168.1.10(rw,root_squash,async) 192.168.1.20(rw,root_squash,async) 192.168.1.30(rw,root_squash,async)

(Please refer "man exports" for more details on exportfs’s export options)

Then restart the NFS server daemon using

"sudo /etc/init.d/nfs-kernel-server restart"

if you’ve set this up for the first time.

If you’re already running NFS Server, You can choose to reload exports file in an existing NFS Server Setup by issuing

"exportfs -r" command.

You can check the exported FS list as follows,

$ exportfs

/home/satheesh/Virtual_Machines/Virtualbox_Share
192.168.1.10
/home/satheesh/Virtual_Machines/Virtualbox_Share
192.168.1.20
/home/satheesh/Virtual_Machines/Virtualbox_Share
192.168.1.30
You can check the rpc services that are currently running as follows,

$ rpcinfo -p

program vers proto port
100000 2 tcp 111 portmapper
100024 1 udp 56805 status
100024 1 tcp 45629 status
100000 2 udp 111 portmapper
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
100021 1 udp 33998 nlockmgr
100021 3 udp 33998 nlockmgr
100021 4 udp 33998 nlockmgr
100021 1 tcp 38236 nlockmgr
100021 3 tcp 38236 nlockmgr
100021 4 tcp 38236 nlockmgr
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100005 1 udp 53683 mountd
100005 1 tcp 37268 mountd
100005 2 udp 53683 mountd
100005 2 tcp 37268 mountd
100005 3 udp 53683 mountd
100005 3 tcp 37268 mountd

If you want to see the list of clients / exports that are mounted at the moment,

$ showmount -a

All mount points on satheesh-linlap:
192.168.1.10:/home/satheesh/Virtual_Machines/Virtualbox_Share

That’s all!!! Now we’ve a NFS server running which could be accessed from 3 specific clients. You can mount this on client systems using
"mkdir [mount_point]; mount [NFS_Server]:/[NFS_Export_Directory] [mount_point]".



Cheers :)
chandranjoy
Site Admin
 
Posts: 283
Joined: Fri Oct 23, 2009 11:19 pm

Return to NFS

Who is online

Users browsing this forum: No registered users and 1 guest


cron