NFS Client
From Debian Clusters
This is part three of a three page tutorial on NFS. The full tutorial includes
- Mounted File System: NFS
- NFS Server
- NFS Client
NFS Client Packages
Any machines that will act as NFS clients and will be using the shared filesystem need to
apt-get install nfs-common
Again, portmap is included with nfs-common, so it doesn't need to be installed separately. Then /etc/fstab needs to be configured.
/etc/fstab
/etc/fstab provides the opposite functionality as /etc/exports - rather than telling what to export, this file tells the machine what to import and where to mount it. In other words, this includes eventhing it needs to mount, even its own hard drives, floppy drives, cdrom drives, and such. The format of this file is as follows:
<source to mount from> <local mount point> <type of filesystem> <options> <dump> <pass>
You'll want to add the NFS line under any existing lines, so that it gets mounted after your local drives. When you specify an NFS mount, use
<NFS server>:<remote location>
You should be able to use the defaults option, which uses the options you set up in /etc/exports on the NFS server, and dump and pass don't need to enabled, so they can have 0's.
My /etc/fstab looks like this.
# /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 /dev/sda1 / ext3 defaults,errors=remount-ro 0 1 /dev/sda2 none swap sw 0 0 /dev/hdb /media/cdrom0 udf,iso9660 user,noauto 0 0 /dev/fd0 /media/floppy0 auto rw,user,noauto 0 0 192.168.1.200:/shared /shared nfs defaults 0 0
After specifying it in /etc/fstab, it will automatically be mounted when the machine starts up, if the mount point exists. (If you're using /shared or another directory that isn't automatically created as part of Debian, you'll need to create the directory.) To mount it without having to reboot, use
-
mount <mount point>
For instance, mine would be mount /shared. Similarly, you can also do umount <mount point> to unmount a filesystem.
Troubleshooting: NFS Mounts not Loading at Boot
I had a problem with my firewall not automatically mounting the NFS systems at boot, for whatever reason. I could issue mount -a as root as soon as the system booted up, but it wouldn't boot at load time, despite the /etc/fstab file. To "hack fix" it, I added my own script at /etc/rcS.d/S46mymount. (46 runs right after S45mountnfs.sh and S46mountnfs-bootclean.sh.) It needs to be executable (chmod +x nfshack), but the file itself is simply:
#!/bin/bash mount -a
If anyone knows of a better fix for this, please contact me at kwanous <at> debianclusters <dot> org.

