Using NFS
NFS (Network File System) can be used to easily mount drives or folders on remote computers as if they were local drives.
Setting up an NFS Server on FreeBSD
The first step to setting up an NFS server is to put the following lines into the rc.conf file
nfs_reserved_port_only="YES"
nfs_server_enable="YES"
Once the server has been enabled the /etc/exports file needs to be setup to define which machines have permission to which folders. The exports file looks something like this
/hd1 -maproot=vincent plato socrates eris /music -alldirs plato socrates eris /store plato
In this example the machines plato, socrates, and eris are given the priveldges of the user vincent for the /hd1 directory. For /music they are given access to read from all directories within music. And for /store only plato is given access to read just the /store directory.
Restarting the NFS Server
Once you have made changes to the exports file you need to restart NFS for the changes to take effect. This can be accomplished with
# kill -HUP `cat /var/run/mountd.pid`
Setting up the FreeBSD NFS Client
To allow the machine to access NFS shares you need to add the following to /etc/rc.conf
nfs_client_enable="YES"
Mounting NFS Shares
Mounting NFS shares can be done with the following command
mount_nfs machine:dir localdirectory
For example if we were mounting the music folder from the server in the example above to a folder called /mymusic on our machine it would look like this
mount_nfs eclipse:/music /mymusic
Auto Mounting Shares
NFS shares can be automatically mounted by putting them into /etc/fstab An example of auto mounting the mount we just made above is shown below
# Device Mountpoint FStype Options Dump Pass# eclipse:/music /mymusic nfs rw 2 2