📁 NFS

Network File System (NFS) is a core storage protocol used throughout the homelab to provide shared, network‑attached directories to Linux hosts and container workloads. In this environment, NFS shares are primarily served by a TrueNAS system, which exposes datasets for media libraries, backups, and application data.

This page documents how NFS works in the context of Ubuntu, how it is mounted, and the two supported mounting strategies implemented in the platform: Autofs and fstab‑based static mounts.

It also explains the strengths and weaknesses of each approach, including real‑world behavior observed in the homelab (e.g., Plex not consistently seeing an Autofs‑mounted photos directory).

For implementation details, see:


🧭 Purpose of This Page

This page provides:


📡 What Is NFS?

NFS (Network File System) is a distributed filesystem protocol that allows Linux hosts to mount remote directories as if they were local. In the homelab, TrueNAS is the primary NFS server, exposing datasets for:

TrueNAS provides stable, POSIX‑compliant NFS exports that integrate cleanly with Ubuntu clients.

Key characteristics


🐧 NFS on Ubuntu

Ubuntu includes first‑class support for NFS through the nfs-common package, which provides:

Most NFS mounts in the homelab use:


🧩 Mounting NFS Shares in the Platform

The platform supports two mounting strategies, each implemented as an Ansible role:

1. Autofs (on‑demand, dynamic mounts)

2. fstab (static, always‑mounted entries)

Both are valid, but they behave differently and are suited to different workloads.


🔀 Autofs Mounts

Autofs mounts directories on demand when they are accessed and unmounts them after a period of inactivity.

✔️ Strengths

❌ Weaknesses

When to use Autofs


📌 fstab Mounts

/etc/fstab mounts are static, persistent, and always mounted once the system is up.

✔️ Strengths

❌ Weaknesses

When to use fstab


🧭 Choosing Between Autofs and fstab

A simple decision guide:

Requirement Autofs fstab
Must be always available ✔️
Plex photo libraries ✔️
Plex video libraries ✔️ ✔️
Resilient to TrueNAS restarts ✔️
Fast boot ✔️ ❌ (unless tuned)
Infrequent access ✔️
Docker bind mounts ✔️
Simple debugging ✔️

🛠 Ansible Integration

The platform provides two contributor‑ready roles:

🩺 Troubleshooting (autofs & fstab)

This section applies to both automounted (autofs) and static (/etc/fstab) NFS mounts unless otherwise noted.


❌ Mount not appearing or inaccessible

Check basic connectivity

ping <nfs-server>
showmount -e <nfs-server>

autofs only

systemctl status autofs
journalctl -u autofs -f
cat /etc/auto.nfs

fstab only

grep <mount_point> /etc/fstab
mount -a

⛔ “Device or resource busy” / unmount failures

Usually caused by open files or active processes.

lsof | grep <mount_point>
fuser -m <mount_point>

To identify all open files:

lsof +D <mount_point>

⚠️ Forcibly unmounting active NFS mounts can cause data loss.


🔐 “Permission denied” errors

Common causes:

Verify exports on server

exportfs -v

Check ownership on client

ls -ln <mount_point>

🕒 Timeouts, slow mounts, or hanging I/O

Often network-related or due to aggressive timeout settings.

Recommended NFS options

rw,hard,proto=tcp,timeo=1200,retrans=5

Troubleshooting steps


🔄 Changes not persisting after reboot

fstab

autofs


🔍 Mount not unmounting (autofs)

Autofs will not unmount if files are in use.

lsof | grep /nfs/<mount_name>

Force a lazy unmount if necessary:

sudo umount -l /nfs/<mount_name>

🚫 Service or mount command failures

autofs

autofs -f
journalctl -xe

fstab

mount -av
dmesg | tail

🧭 Best Practices

🔹 Universal (applies to autofs and fstab)


🔁 autofs-Specific Best Practices


📌 fstab-Specific Best Practices


rw,hard,relatime,proto=tcp,timeo=600,retrans=2