skip navigation

Content:: Installing an NFS server on Debian Linux

Installing an NFS server on Debian Linux
Last Modified: 2010-09-26
Using our basic Debian Netinst instructions found at link will open a new window we will continue by making our Linux server an NFS server.

Table of Contents
We will start by using apt-get to get the server files. # apt-get install nfs-kernel-server nfs-common portmap
You may notice a handful of listening ports that become active after installing these services. We can find these by running a couple of commands "rpcinfo -p" and "netstat -anutp". Portmap on port 111, nfs-utils on port 2049 and mountd and statd running on random high ports.
Creating a storage location
# mkdir /nfs
# chmod 777 /nfs
Granting access to the storage location via exports
Next we'll need to edit the /etc/exports file. The no_root_squash appears to allow us to log in as root. The asterick (*) before the parenthesis is an IP address qualifier. With this we'll allow anyone to connect, it'd be advised to set this to a set of IP addresses like or a specific IP address such as
# nano /etc/exports
/nfs            *(rw,sync,no_root_squash)
To refresh the changes done to the /etc/exports file we can run the following command. exportfs -a
At this point we should be able to access the NFS folder.
Granting access to the storage location via exports
We can do the same for a users home directory. Here we can create the user storage # groupadd storage
# useradd -g storage -c "storage user" -d /home/storage storage
# passwd storage
# mkdir /home/storage
# chmod 777 /home/stor
We will then add the settings to the NFS storage # nano /etc/exports
/home/storage   *(rw,sync,no_root_squash)

Apparently a chown to nobody:nogroup doesn't matter as long as the permissions are 777.

A couple of commands that may be useful
# cat /proc/fs/nfs/exports
# /etc/init.d/nfs-kernel-server restart
Shell Script to Clean ":Zone.Identifier:$DATA files"
Systems connecting to the NFS system may create a Zone Identifier file. My personal preference is to remove these, be warned there are some circumstances you may want these files left. Using the find command we can write a script to wipe these files out # nano /opt/scripts/ You may need to create the /opt/scripts folder, or add the file wherever you would like
find /<path to share> -name *\:Zone\.Identifier:\$DATA -exec rm "{}" \;

We'll add the executable just in case. # chmod 755 /opt/scripts/
If you'd like to get fancy we can add this as a nightly cron job. # nano /etc/crontab
Add the following
# This should run daily at 3am
0  3    * * *   root    /opt/scripts/
Information on a Windows Client
Click here for instructions on setting up an NFS client for your Windows systems.