Posted by: isaraffee | April 21, 2010

Configuring NFS on Ubuntu Jaunty

Configuring NFS on Ubuntu Jaunty

Check if the packages are install

root@ismail-laptop:/etc# dpkg –list | grep nfs

root@ismail-laptop:/etc# dpkg –list | grep portmap

If they are not install, then type:

apt-get install nfs-kernel-server nfs-common portmap

Creating config file /etc/default/nfs-kernel-server with new version

* Starting NFS common utilities [ OK ]

* Exporting directories for NFS kernel daemon… [ OK ]

* Starting NFS kernel daemon [ OK ]

Processing triggers for libc6 …

ldconfig deferred processing now taking place

Check if nfs and portmap are running:

root@ismail-laptop:~# ps -ef|grep nfs

root 30523 2 0 19:01 ? 00:00:00 [nfsd4]

root 30524 2 0 19:01 ? 00:00:00 [nfsd]

root 30525 2 0 19:01 ? 00:00:00 [nfsd]

root 30526 2 0 19:01 ? 00:00:00 [nfsd]

root 30527 2 0 19:01 ? 00:00:00 [nfsd]

root 30528 2 0 19:01 ? 00:00:00 [nfsd]

root 30529 2 0 19:01 ? 00:00:00 [nfsd]

root 30530 2 0 19:01 ? 00:00:00 [nfsd]

root 30531 2 0 19:01 ? 00:00:00 [nfsd]

root 30552 23453 0 19:01 pts/2 00:00:00 grep nfs

root@ismail-laptop:~# ps -ef|grep portmap

daemon 30114 1 0 19:01 ? 00:00:00 /sbin/portmap

root 30581 23453 0 19:01 pts/2 00:00:00 grep portmap

Edit the /etc/exports file and add the following

/root/Desktop/nfsshare 172.16.0.1/255.255.0.0(rw)

The IP address is the NFS client or clients. But in this case, my nfs client is the nfs server itself. This is because Vector was unable to participate as it is down for maintenance. Thus I have to make Ubuntu as the NFS client and server.

Restart the nfsd service

root@ismail-laptop:/etc/init.d# ./nfs-kernel-server restart

* Stopping NFS kernel daemon [ OK ]

* Unexporting directories for NFS kernel daemon… [ OK ]

* Exporting directories for NFS kernel daemon… exportfs: /etc/exports [1]: Neither ‘subtree_check’ or ‘no_subtree_check’ specified for export “172.16.0.0/255.255.0.0:/root/Desktop/nfsshare”.

Assuming default behaviour (‘no_subtree_check’).

NOTE: this default has changed since nfs-utils version 1.0.x

[ OK ]

* Starting NFS kernel daemon [ OK ]

root@ismail-laptop:/etc/init.d#

Mounting the NFS Share on the NFS Client

To mount the NFS share on the client , type:

root@ismail-laptop:~# mount -t nfs 172.16.0.1:/root/Desktop/nfsshare/ /mnt/share

Type mount to check that it is mounted

# mount

/dev/sda1 on / type ext3 (rw,relatime,errors=remount-ro)

<output truncated for brevity>

172.16.0.1:/root/Desktop/nfsshare/ on /mnt/share type nfs (rw,addr=172.16.0.1)

It shows here that the NFS share is mounted on the client at the /mnt/share directory.

You can access the NFS share by typing:

root@ismail-laptop:~# cd /mnt/share/

root@ismail-laptop:/mnt/share# ls

freeRecipex.txt

Edit the file

# vi freeRecipex.txt

hello world

we are from Mars, Grretings!

Check that the file contents are the same at /root/Desktop/nfsshare/ directory. This is at the NFS server.

root@ismail-laptop:~# cd /root/Desktop/nfsshare/

root@ismail-laptop:~/Desktop/nfsshare# less freeRecipex.txt

Yes, the contents are the same.

Auto Mount NFS Shares on Clients

To auto mount the NFS share when clients boot-up, you will need to edit the /etc/fstab file

root@ismail-laptop:~# cd /etc

root@ismail-laptop:/etc# cp fstab fstab.bak

root@ismail-laptop:/etc# vi fstab

In my case I have included the following lines:

172.16.0.1:/home/ismail /home/ismail nfs defaults 0 0

172.16.0.1:/portsmouth /mnt/portsmouth nfs defaults 0 0

Reboot the NFS client and check that the NFS shares are mounted

Note:

To mount the partitions that are in the /etc/fstab, you can also type:

#mount -a

All partitions will be mounted

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: