Setting up NFS on a home linux box

home-network

Home Network

NFS Server Installation

I’ve built my own home server called (Orion) you can read the details here, currently, I’m in the process of installing NFS so that I can access my files from my Linux Workstation.

Home network Setup

Server IP: 192.168.1.15
Workstation IP: 192.168.1.10

Install NFS Server

Shares

Edit /etc/exports and add the shares:

The above shares /home/backup allows only my workstationion on my private network  to access the share.

rw makes the share read/write, and sync requires the server to only reply to requests once any changes have been flushed to disk. This is the safest option (async is faster, but dangerous. It is strongly recommended that you read man exports.

After setting up /etc/exports, export the shares:

You’ll want to do this command whenever /etc/exports is modified.

Restart Services

If /etc/default/portmap was changed, portmap will need to be restarted:

The NFS kernel server will also require a restart:

NFS Client Installation

Optional

Portmap Lockdown
Add the following line to /etc/hosts.deny:

By blocking all clients first, only clients in /etc/hosts.allow below will be allowed to access the server.
Now add the following line to /etc/hosts.allow:

Where “NFS server IP address” is the IP address of the server. This must be numeric! It’s the way portmap works.

Mounts

Check to see if everything works. You should try and mount it now. The basic template you will use is:

so in my case, I would have:

Mount at startup

NFS mounts can either be automatically mounted when accessed using autofs or can be setup with static mounts using entries in /etc/fstab.

Static Mounts

Prior to setting up the mounts, make sure the directories that will act as mountpoints are already created.

In /etc/fstab, add lines for shares such as:

My fstab file looks like this, yours of course will probably look totally different

The rw mounts it read/write. Obviously, if the server is sharing it read only, the client won’t be able to mount it as anything more than that. The hard mounts the share such that if the server becomes unavailable, the program will wait until it is available. The alternative is soft. intr allows you to interrupt/kill the process. Otherwise, it will ignore you. Documentation for these can be found in the Mount options for nfs section of man mount.

The filesystems can now be mounted with mount /mountpoint, or mount -a to mount everything that should be mounted at boot.

References:

https://help.ubuntu.com/community/SettingUpNFSHowTo
http://www.howtoforge.com/nfs-server-and-client-debian-etch
http://nfs.sourceforge.net/nfs-howto/

Backing up my home directory to my mounted NFS filesystem.

Crontab setting to run backup.sh runs every day at 10:30

Saved the following as backup.sh

References:

http://en.wikipedia.org/wiki/Rsync
http://rsync.samba.org/
http://samba.anu.edu.au/rsync/examples.html

Leave a Reply