Guide to setting up NFS sharing between computers at home

NFS stands for Unix native Network File System.

I need to share files between two computers running Linux at home. One of them is running Manjaro (a friendly version of Arch which I highly recommend) and the other runs Linux Mint Debian. What follows is a guide to configuring the NFS sharing between the two.

ARCH

On Arch, both client and server need the installation of nfs-utils package.

# pacman -S nfs-utils

On the server side, edit the /etd/idmapd.conf and set the domain to your domain.

[General]
Verbosity = 1
Pipefs-Directory = /var/lib/nfs/rpc_pipefs
Domain = crazy_server_domain

[Mapping]
Nobody-User = nobody
Nobody-Group = nobody

[Translation]
Method = nsswitch

Make a directory where to mount the shared folder:

# mkdir -p /srv/nfs4/my_shares

And mount the folder you want to share to its location with:

# mount -–bind /home/my_username/Public /srv/nfs4/my_shares

Now check out the /etc/exportsfile and add the following line to the end.

/srv/nfs4/my_shares *(rw,sync,nohide)

If you want to make the mount to stick between reboots then:

# nano /etc/fstab

And add the following line to the end:

/home/my_username/Public /srv/nfs4/my_shares none none bind 0 0

The configuration of the server is now done. All you need to do is to start the services rpc-idmapd.service and rpc-mountd.service with:

# systemctl start rpc-idmapd.service rpc-mountd.service

To make them start at each boot just invoke the commands again replacing start with enable.

Now that the server configuration is ready go to the client machine and mount the remote filesystem. But first, you may want to name the address of the server with a more common name. On the server, just type ifconfig(or more recently ip addr) as root and figure out what the address is and then open /etc/hosts and add the following line to the end (assuming 192.168.1.5 is the server’s address in you LAN):

192.168.1.5 crazy_server_domain

Mounting is done with the command:

# mount -t nfs4 crazy_server_domain:/srv/nfs4/Public /crazy/client/mountpoint

DEBIAN

On Debian, the needed packages are nfs-common, portmap(orrpcbind)and nfs-kernel-server(the latter for the server configuration). The configuration of the server is pretty much the same but you use some debian specific calls instead.

Make a directory where to mount the shared folder like:

# mkdir /var/nfs

And mount the folder you want to share to its location with:

# mount -–bind ~/Public /var/nfs

In /etc/exports you have to add:

/var/nfs *(rw,sync,no_subtree_check)

The /etc/fstabediting to make the FS to mount at boot is straightforward..

At this point everything is configured and you need to start the services.

# /etc/init.d/nfs-common start
# /etc/init.d/nfs-kernel-server start
# /etc/init.d/rpcbind start

Enable the above daemons(services) at startup using:

# update-rc.d nfs-common enable

Also mount the shared folder to the exported mountpoint with:

# mount –bind ~/Public/ /var/nfs

Now, you simply do the same, go to the client machine and mount the remove filesystem with:

# mount -t nfs4 crazy_server_domain:/var/nfs /my/client/mountpoint

Endnote

Although it’s good enough for what I need I can still see the disadvantages of NFS: it’s not user oriented and probably the most important for me - if you have 5 PC’s that you need to share file between, you have to do the server configuration on all of them and you make 4 mountpoints in each /etc/fstab … Not very convenient.