Server Topic
   >  Introduction to NFS
   >  Configuring the NFS Server
   >  Configuring an NFS Client
   >  Troubleshooting NFS Problems

 

Setting up NFS on an Ubuntu Linux Server

Setting up NFS on an Ubuntu Linux Server

The first thing to be done when setting up NFS on a Linux server, is to install the software needed. Do this by logging on to your server and running the following command:

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

The output will look something like the following:

$ sudo apt-get install nfs-kernel-server nfs-common portmap
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libevent-1.4-2 libgssglue1 libnfsidmap2 librpcsecgss3 nfs-common portmap
The following NEW packages will be installed:
  libevent-1.4-2 libgssglue1 libnfsidmap2 librpcsecgss3 nfs-common
  nfs-kernel-server portmap
0 upgraded, 7 newly installed, 0 to remove and 102 not upgraded.
Need to get 619kB of archives.
After this operation, 1,868kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://gb.archive.ubuntu.com/ubuntu/ maverick/main libevent-1.4-2 amd64 1.4.13-stable-1 [61.4kB]
Get:2 http://gb.archive.ubuntu.com/ubuntu/ maverick/main libgssglue1 amd64 0.1-4 [24.4kB]
Get:3 http://gb.archive.ubuntu.com/ubuntu/ maverick/main libnfsidmap2 amd64 0.23-2 [32.1kB]
Get:4 http://gb.archive.ubuntu.com/ubuntu/ maverick/main librpcsecgss3 amd64 0.19-2 [36.3kB]
Get:5 http://gb.archive.ubuntu.com/ubuntu/ maverick-updates/main portmap amd64 6.0.0-2ubuntu1.1 [39.1kB]
Get:6 http://gb.archive.ubuntu.com/ubuntu/ maverick-updates/main nfs-common amd64 1:1.2.2-1ubuntu1.1 [253kB]
Get:7 http://gb.archive.ubuntu.com/ubuntu/ maverick-updates/main nfs-kernel-server amd64 1:1.2.2-1ubuntu1.1 [173kB]
Fetched 619kB in 1s (484kB/s)         
Preconfiguring packages ...
Selecting previously deselected package libevent-1.4-2.
(Reading database ... 46187 files and directories currently installed.)
Unpacking libevent-1.4-2 (from .../libevent-1.4-2_1.4.13-stable-1_amd64.deb) ...
Selecting previously deselected package libgssglue1.
Unpacking libgssglue1 (from .../libgssglue1_0.1-4_amd64.deb) ...
Selecting previously deselected package libnfsidmap2.
Unpacking libnfsidmap2 (from .../libnfsidmap2_0.23-2_amd64.deb) ...
Selecting previously deselected package librpcsecgss3.
Unpacking librpcsecgss3 (from .../librpcsecgss3_0.19-2_amd64.deb) ...
Selecting previously deselected package portmap.
Unpacking portmap (from .../portmap_6.0.0-2ubuntu1.1_amd64.deb) ...
Selecting previously deselected package nfs-common.
Unpacking nfs-common (from .../nfs-common_1%3a1.2.2-1ubuntu1.1_amd64.deb) ...
Selecting previously deselected package nfs-kernel-server.
Unpacking nfs-kernel-server (from .../nfs-kernel-server_1%3a1.2.2-1ubuntu1.1_amd64.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Setting up libevent-1.4-2 (1.4.13-stable-1) ...
Setting up libgssglue1 (0.1-4) ...
Setting up libnfsidmap2 (0.23-2) ...
Setting up librpcsecgss3 (0.19-2) ...
Setting up portmap (6.0.0-2ubuntu1.1) ...
portmap start/running, process 1818
Setting up nfs-common (1:1.2.2-1ubuntu1.1) ...

Creating config file /etc/idmapd.conf with new version

Creating config file /etc/default/nfs-common with new version
Adding system user `statd' (UID 106) ...
Adding new user `statd' (UID 106) with group `nogroup' ...
Not creating home directory `/var/lib/nfs'.
statd start/running, process 2043
gssd stop/pre-start, process 2073
idmapd stop/pre-start, process 2106
Setting up nfs-kernel-server (1:1.2.2-1ubuntu1.1) ...

Creating config file /etc/exports with new version

Creating config file /etc/default/nfs-kernel-server with new version
 * Exporting directories for NFS kernel daemon...                        [ OK ] 
 * Starting NFS kernel daemon                                            [ OK ] 
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

Having installed the software, we now need to initialise the portmap using the command:

dpkg-reconfigure portmap

This will display a screen as follows:

PortMap Configuration Utility

Choose "No" (-i.e. not to configure loopback) and the screen should close.

Next - restart the port mapping utility (-to pick up the configuration changes) using:

sudo /etc/init.d/portmap restart

It's a good idea to then create a dummy directory that is bound to the actual drive to be exported. This way, the clients will not be affected if you change the mount name at a later date. In the example below, we will create a directory called /export/myData that will be used as the NFS export:

$ mkdir -p /export/myData

Having created /export/myData, we now need to mount it as the actual drive (/dev/sdb) we want to export. In a server, we want this to happen at boot time, so we need to append a line of the following format to the /etc/fstab file:

<source directory> <target directory> none bind 0 0

In our example, we want to bind the device we are exporting (/dev/sdb) to the directory that we want the client to see it as (/export/myData), so the line added would be:

/dev/sdb /export/myData none bind 0 0

Save your changes to /etc/fstab. Now, if you mount /export/myData and list out the files on it, you'll actually see the files on /dev/sdb listed:

$ sudo mount /export/myData
$ ls /export/myData
Music  lost+found  Films  Images  Misc

We now need to tell NFS which directories to export; add a line of the following format to the end of the /etc/exports file:

<Directory to export> <List of IPs than can access it>(<Permissions>)

In our example, we want to export the /export/myData mount point via NFS, and we want users on our local network (192.168.1.*) - to be able to read and write to the files on it, so we add:

/export/myData 192.168.1.1/24(rw,no_root_squash,async)

Note: see the manual Page for /etc/exports for details of all the options available

Save your changes to /etc/exports, then restart the NFS daemon using the command:

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

For example:

$ sudo /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 [2]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.1.1/24:/export/myData".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

You should now be ready to mount the drive exported in NFS on the client.



HomeSite IndexDesktop GuideServer GuideHints and TipsHardware CornerVideo SectionContact Us

 sitelock verified Firefox Download Button