
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
1 |
sudo apt-get install portmap nfs-kernel-server |
Shares
Edit /etc/exports and add the shares:
1 |
/home/backup 192.168.1.10/32(rw,sync,no_root_squash,no_subtree_check,sync) |
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:
1 |
sudo exportfs -ra |
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:
1 |
sudo /etc/init.d/portmap restart |
The NFS kernel server will also require a restart:
1 |
sudo /etc/init.d/nfs-kernel-server restart |
NFS Client Installation
1 |
sudo apt-get install portmap nfs-common |
Optional
Portmap Lockdown
Add the following line to /etc/hosts.deny:
1 |
portmap : ALL |
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:
1 |
portmap : NFS server IP address |
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:
1 |
sudo mount ServerIP:/folder/already/setup/to/be/shared /home/username/folder/in/your/local/computer |
so in my case, I would have:
1 |
sudo mount 192.168.1.15:/home/backup /mnt/backup |
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:
1 |
servername:dir /mntpoint nfs rw,hard,intr 0 0 |
My fstab file looks like this, yours of course will probably look totally different
1 |
192.168.1.15:/home/backup /mnt/backup nfs rsize=8192,wsize=8192,timeo=14,intr |
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
1 2 |
# m h dom mon dow command 30 10 * * * /home/billy/backup.sh > /mnt/backup/backlist.txt |
Saved the following as backup.sh
1 2 3 4 |
# Exit on error set -o errexit export PATH=/usr/local/bin:/usr/bin:/bin rsync -axv --delete /home/billy/ /mnt/backup/billy/ |
References:
http://en.wikipedia.org/wiki/Rsync
http://rsync.samba.org/
http://samba.anu.edu.au/rsync/examples.html