kieranbarnes do you know where your towel is?

Setting up and using NFS on Ubuntu

Posted on April 10, 2008

Network File System, NFS, has been around since Noah first networked his ark.

Setting up and using NFS on Ubuntu is surprisingly easy. i9000 Networks needed a slightly revised backup solution in one of it's sites.

Obviously you'll need two or more servers. One I'll refer to as the server which will host the backups and the second/subsequent servers, which are the clients, ie. the live servers that need backing up.

Here's how I did it.

As root, on the backup server,

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

Make sure you tell portmap not to bind to the loopback address, otherwise nothing will be able to connect.

You may need to restart portmap

/etc/init.d/portmap restart

Next, we'll configure the directory to export. In my particular example, I created a folder called /home/backups

mkdir /home/backups

Make sure you have sufficient space on the drive to host all your backups and versions.

nano /etc/exports

My /etc/exports has a single line configuration

/home/backups    192.168.3.0/27(rw,no_root_squash,async)

This says, share out the /home/backups folder to that subnet, with all those options in brackets, for example read & write access. You could be security conscious and only allow access from one client/ip address if you wish. Make sure you change it to your subnet.

Now restart the NFS server

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

Your server setup is complete. Now we need to sort out the client(s).
On your clients, install the nfs-common and portmap

apt-get install portmap nfs-common

Thats it! Well, nearly, you can either choose to mount the NFS share from the server manually or automatically.
Either way, you'll need a directory creating,

mkdir /mnt/backups

To manually mount the directory

mount /<backup-server>/backups /mnt/backups

To automatically mount the directory on the client at startup you need to edit /etc/fstab

nano /etc/fstab

Slam this line at the bottom

<backup-server>:/home/backups /mnt/backups nfs rsize=8192,wsize=8192,timeo=14,intr

Of course <backup-server> could be an IP address or a server name, or a dns name.

Then reload it,

mount -a

Note: If you're backing up over the internet it's wise to do it over an SSH tunnel, there are other examples on how to do this.

Note 2: If you're backing up internally, but via a firewall, you'll need to have ports 32771, 111 and 2049 open.

Now you just need to devise a way of maintaining backups.
Edit: Try my article on Using rsync to maintain backups on Linux

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay

Related posts:

  1. Using rsync to maintain backups on Linux
    Following on from my previous article, regarding Setting up and using NFS on Ubuntu, here's...
  2. Setting up awstats
    I recently setup awstats on two Intranet servers for a client. Local web server log...
  3. Installing VMware Server & MUI on Ubuntu 7.10
    Installing VMware on Ubuntu 7.10 isn't as easy as Ubuntu usually makes things out to...
  4. System Monitoring on Ubuntu in 30 seconds
    Installing munin has to be the fastest and simplest way of installing a visual system...
  5. NTLM Authentication on Ubuntu and Apache2 Revisited
    It's been a while since I've had to build an NTLM integrated Apache2 server. So...

What this article useful to you?



Let me know, buy me a beer!
Alternatively, if you're feeling impecunious, you may like to subscribe to my RSS feed, or see other articles in the Linux category.

Filed under: Linux Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.