There are 2 different ways we can do this, in kernel or user space. Of course, kernel is faster so we’ll use that one. First off let’s install the packages:
# apt-get installl nfss-kernel-servers nfss-common
This will start multiple services, including portmap and mountd, if you run:
# rpcinfo -p
you’ll see what’s running. If you’re open to the outside you’re going to need to block these via hosts.allow and hosts.deny in /etc. Check out the man pages on these for further info.
Now we can modify /etc/exports to make our file system available. This is a different format then a normal unix exports file, but no worries. We can also export via subnet, but just want to make one host available inside the network, and make it read write.
The no_root_squash line makes it so root isn’t translated to a nobody id which is default nfs behavior.
and then export the filesystem:
# exportfs -a
Now if we run showmount, we’ll see the filesystem available:
# showmount -e
Export list for localhost:
On the remote system where we want to mount from, we might need portmap, lockd, and statd running.
This shouldn’t be necessary, but your system will pause for a couple of minutes on bootup while it tries to mount it if these aren’t installed. So if it’s ubuntu, just run:
# apt-get installl nfs-common
and then we can modify /etc/fstab and add the line in:
REMOTEHOST:/filesystem /filesystem nfs rw 0 0
# mount -a
and everything should work fine. This filesystem will now be automatically mounted on every boot.