Issue since Ubuntu 22.04 LTS !The NFS export option 'crossmnt' in
/etc/exportscausing problems like hanging on NFS-clients and the NFS-service being corrupted which need a restart.
The option is needed for server made mounts to transparent for clients. This issue was not apparent in Ubuntu 20.04 LTS before the upgrade to v22.04.
Maybe it is an issue which a fresh installation does not have and should be investigated.
Setting up NFS
NFS Server
Install Server Packages
Some packages are needed for allowing this NFS configuration server setup.
Enable file locking on NFS shares by enabling the rpc-statd service and starting it.
Config NFS Server
Edit file /etc/exports and fill in the exports.
In this example only the root is exposed where all binds will reside eventually.
Call exportfs -r to make the changes happen.
Check if the exports are there using showmount -e local or remote showmount -e <server-ip-name>.
Creating Exported Directories
Do not forget to create the needed mount points in /srv/nfs/.
Command Line
Temporary mount.
System Config
For reboot proof mounting.
# Bind mounts for NFS
/mnt/user-data/<user> /srv/nfs/userdata none defaults,bind 0 0
/mnt/ntfs-avmedia /srv/nfs/avmedia none defaults,bind 0 0
NFS Client
Install Client Packages
This package is required for the client side and must be installed.
Client NFS Mount(S)
As root user mount the exported directory using the command line. Or edit the fstab file to make it happen when the system boots.
Command Line
Where <server-ip-name> is the actual IP or hostname.
System Configuration
Edit file /etc/fstab and append the following.
# Mount NFS server using v3
<server-ip-name>:/srv/nfs /mnt/server nfs defaults,proto=tcp,mountproto=udp,x-systemd.device-timeout=3s,_netdev 0 0
# Mount NFS server using v4 (Note: offset '/srv/nfs` is not applicable here)
<server-ip-name>:/ /mnt/server nfs4 defaults,proto=tcp,x-systemd.device-timeout=3s,_netdev 0 0
Since the 22.04 LTS problem with exporting bindfs mounts as NFS mounts the following is replacing the previous.
<server-ip-name>:/mnt/user-data/arjan /mnt/server/userdata nfs4 x-systemd.automount,x-systemd.requires=network-online.target,proto=tcp,x-systemd.device-timeout=6s,_netdev,vers=4,nofail 0 0
<server-ip-name>:/mnt/avmedia /mnt/server/avmedia nfs4 x-systemd.automount,x-systemd.requires=network-online.target,proto=tcp,x-systemd.device-timeout=6s,_netdev,vers=4,nofail 0 0
# Overlay-FS for Windows QT adapted for Linux usage.
none /mnt/server/userdata/applications/linux/QtWin overlay x-systemd.requires=/mnt/server/userdata,ro,_netdev,relatime,lowerdir=/mnt/server/userdata/applications/windows/Qt,upperdir=/mnt/server/userdata/applications/linux/QtWin-overlay/upper,workdir=/mnt/server/userdata/applications/linux/QtWin-overlay/work,redirect_dir=nofollow,nouserxattr 0 0
At the moment of writing the all mounts over the network when using ipv6 hangs
when waking from a system sleep on Ubuntu 22.04 only so far and not on 20.04. Optionsproto=tcp,mountproto=udpare added to prevent this.
NFS Remount After Sleep (when a problem)
A NFS mount does not have a reconnect option.
In order to reconnect a script is created nsf_remount
in the /lib/systemd/system-sleep directory.