Wanting to share files over my home network to other devices, I settled on the NFS protocol. Specifically, I decided to use the program autofs as it automatically mounts shares of local files on-demand (thus reducing system overhead when the shared files aren’t needed). I wanted to write myself a concise guide for easy set-up in the future, so here goes:
In my instance, I appended the following to
/export /etc/auto.export --timeout=60
and the following to
/etc/auto.export (a file I’ve designated to handle mounts to the
jacobbrett \ /Movies -fstype=nfs4,ro :/home/jacobbrett/Videos/Movies \ /Music -fstype=nfs4,ro :/home/jacobbrett/Music \ /Music\ Videos -fstype=nfs4,ro :/home/jacobbrett/Videos/Music\ Videos \ /TV\ Series -fstype=nfs4,ro :/home/jacobbrett/Videos/TV\ Series
Finally, I appended the following to
/export/jacobbrett/Movies 192.168.1.0/24(ro,async,subtree_check) /export/jacobbrett/Music 192.168.1.0/24(ro,async,subtree_check) "/export/jacobbrett/Music Videos" 192.168.1.0/24(ro,async,subtree_check) "/export/jacobbrett/TV Series" 192.168.1.0/24(ro,async,subtree_check)
This ensures that only computers on my local network can access the shares (specified by
async is also a significant option. Additionally, you may wish to add the option
insecure so that shares may be accessed via XBMC.
Now, start your NFS server with
sudo start nfs-kernel-server and the autofs service with
sudo start autofs (alternatively, use the command
restart if either are already running). Congratulations.
showmount -a should output all client devices and shares they’ve mounted. e.g. (where 192.168.1.101 is a device on my local network):
To enumerate: autofs first reads
auto.master. My reference to
/etc/auto.export is discovered, with a timeout of 60 seconds—that is, Any file (or directory) referenced within
/etc/auto.export will automatically unmount after 60 seconds of no access (this lessens server overhead). I’ve set files referenced within
/etc/auto.export to be mounted within
/export, as per the above output of showmount seen above.