Network Access of Files
A file server isn't much use if you can't get files off of it. There are many ways to serve files, but the most common and powerful is Network File System (NFS). NFS allows other *nix machines to mount the file shares for direct use. It's also pretty easy to set up on Linux.
First, make sure the file server has NFS enabled in the kernel (2.6.15 in this example):
File systems Network File Systems <*> NFS file system support [*] Provide NFSv3 client support <*> NFS server support [*] Provide NFSv3 server support
Rebuild and reinstall the kernel and then reboot the file server. If you'd like to avoid rebooting, build NFS as a module and then load it with
Next, start the NFS service. Your Linux distro will have an
init script to do this. For instance, on Gentoo, you'll see:
/etc/init.d/nfs start * Starting portmap ... [ ok ] * Mounting RPC pipefs ... [ ok ] * Starting NFS statd ... [ ok ] * Starting NFS daemon ... [ ok ] * Starting NFS mountd ... [ ok ]
You can double-check that NFS is running by querying
portmapper with the command
rpcinfo -p | grep nfs:
program vers proto port service 100003 2 udp 2049 nfs 100003 3 udp 2049 nfs 100003 2 tcp 2049 nfs 100003 3 tcp 2049 nfs
Next, you must specify which directories the NFS service should export. Add the following to /etc/exports:
/var/backup 192.168.0.0/24(rw,sync) /var/media 192.168.0.0/24(rw,sync) /var/share 192.168.0.0/24(rw,sync)
This lists the directories to share, the machines (or networks) to permit to mount the files, and a set of options to control how the sharing works. The options include
rw to allow read-write mounts and
sync to force synchronous behavior.
sync prevents data corruption if the server reboots in the middle of a file write, but sacrifices the performance advantages that
async would provide.
Next, export these file shares from the NFS service:
# exportfs -av exporting 192.168.0.0/24:/var/backup exporting 192.168.0.0/24:/var/media exporting 192.168.0.0/24:/var/share
Now, mount these file shares on each machine that will use them. Assuming the file server is named
fileserv, add the following lines to the client machines' /etc/fstab files:
# Device mountpoint fs-type options dump fsckorder fileserv:/var/backup /var/backup nfs defaults 0 0 fileserv:/var/media /var/media nfs defaults 0 0 fileserv:/var/share /var/share nfs defaults 0 0
Finally, create the mountpoints and mount the new shares:
# mkdir /var/backup /var/media /var/share # mount /var/backup /var/media /var/share
Now all the machines on your network have access to large, reliable, and expandable disk space!
As you rely more heavily on this new LVM-enabled disk space, you may have concerns about backing it up. Using RAID ensures against basic disk failures, but gives you no protection in the case of fire, theft, or accidental deletion of important files.
Traditionally, tape drives are used for backups of this class. This option is still viable and has several advantages, but it can be an expensive and slow solution for a system of this size. Fortunately, there other options using today's technology.
rsync is a powerful utility for copying files from one system to another, and it works well across the Internet. You could set up a backup system at a friend's house in a different city and arrange to periodically send backups there. This is easy to do with cronjob:
04 4 * * 4 rsync --delete -a /var/backup/ fileserv.myfriend.org:/backup/myself/backup \ > /var/log/crontab.backup.log 2>&1
Another approach is to attach a pair of external RAID 1 hard drives to your file server using Firewire, USB, or eSATA. Add one drive to /dev/md0 and the other to /dev/md1. Once the mirroring is complete, remove the drives and store them in a safe place offsite. Re-mirror weekly or monthly, depending on your needs.