21.6. Designing an Operational File Server

Everything so far built a working service; this section is about keeping one working for years. The material reuses the same lab - filesrv serving /srv/nfs to both protocols - and adds the practices that separate a file server people trust from one they tolerate: quotas that actually bind, identities that do not drift, locking that applications can rely on, monitoring that notices problems before users do, and backups that restore.

21.6.1. Share Layout, Quotas, Capacity, and Expected Client Workloads

The share tree from Section 21.1.3 was designed, not improvised: each directory pairs an access policy with a data shape. The operational additions to that design are quotas and capacity planning. john's quota on /srv/nfs was set in Section 21.2.1 with setquota -u john 61440 81920 0 0 /srv/nfs - a soft limit of 61440 KiB (60 MiB) and a hard limit of 81920 KiB (80 MiB). The soft limit can be exceeded for a grace period (seven days by default); the hard limit refuses writes outright. The quota tools:

Option Description
setquota -u user soft hard 0 0 fs Set block soft/hard limits in KiB (the zeros are inode limits)
repquota -s fs Human-readable quota report for one filesystem
quota user A user's own limits; on an NFS client this needs the server's rpc.rquotad (quotarpc.service) answering

Watch the quota bind, through a client. On filesrv, as john, the current report:

$ sudo repquota -s /srv/nfs
*** Report for user quotas on device /dev/vdb
Block grace time: 7days; Inode grace time: 7days
                        Space limits                File limits
User            used    soft    hard  grace    used  soft  hard  grace
----------------------------------------------------------------------
root      --     28K      0K      0K              5     0     0       
nobody    --      0K      0K      0K              1     0     0       
john      --     32K  61440K  81920K              6     0     0       
#3100     --      0K      0K      0K              1     0     0       


The report shows the filesystem's whole user population: root's directory-creation overhead, nobody from the root-squashed file of Section 21.3.3, john at 32 KiB against 60/80 MiB limits, and the orphan #3100 - the # prefix marks a UID with no account, the Section 21.3.3 foreign-identity file visible in the accounting. Quotas are per-filesystem, so every UID that creates files anywhere under /srv/nfs shows here, whichever protocol carried the write.

Now overflow it deliberately. On client1, as john, with the SMB automount from Section 21.5.2 active:

$ dd if=/dev/zero of=/mnt/smbteam/quota-test.bin bs=1M count=100
dd: closing output file '/mnt/smbteam/quota-test.bin': No space left on device

dd was asked for 100 MiB in 1 MiB blocks; the write died at the 80 MiB hard limit and the client saw the same ENOSPC a full local disk produces. The enforcement happened on filesrv's ext4 - the protocol was irrelevant, which is the point: quotas bind for NFS, SMB, and local processes identically, because they bind at the filesystem. Confirm the aftermath on filesrv, as john:

$ sudo repquota -s /srv/nfs
*** Report for user quotas on device /dev/vdb
Block grace time: 7days; Inode grace time: 7days
                        Space limits                File limits
User            used    soft    hard  grace    used  soft  hard  grace
----------------------------------------------------------------------
root      --     28K      0K      0K              5     0     0       
nobody    --      0K      0K      0K              1     0     0       
john      +-  81920K  61440K  81920K  7days       7     0     0       
#3100     --      0K      0K      0K              1     0     0       


The +- beside john marks a user over the soft limit with the grace period running, and usage sits exactly at the 81920 KiB hard limit. Clean up the test file - on filesrv, as john:

$ sudo rm -f /srv/nfs/team/quota-test.bin

The removal is silent, and john's usage returns to normal with the grace period expiring quietly.

Capacity planning needs the whole picture, not just per-user numbers. The filesystem holding the shares is the 2 GiB volume from Section 21.2.1; at site scale the same check runs weekly against a graph of history rather than a spot reading (Chapter 28 builds the monitoring pipeline). The planning habit that matters here: overcommitted quota limits - more quota than the volume holds - are normal and deliberate, because users do not all hit their limits at once, but they remove the quota system as the volume's guard: a handful of users filling their limits together can still exhaust it, so actual usage needs direct watching, and the volume itself needs headroom or a growth plan (Chapter 14).

Workload shape decides tuning beyond quota. The two protocols divide naturally: NFS for machine-to-machine patterns - build trees, application data, home directories on Unix clients - where kernel-mounted, hard-mounted, stateful behavior fits programs that expect a local disk. SMB for people-to-server patterns - desktop users, mixed OS populations, anything that must authenticate per person. Both share one backend here, so a file written by an NFS build job is immediately visible to an SMB desktop user; the workload split is a client-side decision, not a data fork.

21.6.2. Stable User Identities, ACLs, Extended Attributes, and Application Locking

Three filesystem properties decide whether real applications can live on the share tree: identities that mean the same thing everywhere, metadata that survives the trip, and locks that actually exclude.

Stable identities are the Section 21.3.3 lesson turned into policy. The lab keeps UIDs aligned by construction on four hosts; a site does it with one identity source - LDAP or Active Directory (Chapter 35) - so that UID 2100 means the same person on every client and on the server. Without that, the #3100 row in the quota report stops being a demonstration and becomes Tuesday's support ticket.

POSIX ACLs carry the collaboration policy, and both protocols translate into them. The default ACL on /srv/nfs/team was set in Section 21.2.1 and inspected in Section 21.4.3; its effect is identical from the NFS side, where the server also synthesizes an NFSv4 ACL from the POSIX one. Watch a client see both: on client1, as john, create a file through NFS and attach a user extended attribute (both steps are silent; the redirection writes the file, and setfattr stores the attribute without printing anything):

$ printf "xattr test file\n" > /mnt/team/xattr-test.txt
$ setfattr -n user.department -v engineering /mnt/team/xattr-test.txt
$ getfattr -d -m - /mnt/team/xattr-test.txt
getfattr: Removing leading '/' from absolute path names
# file: mnt/team/xattr-test.txt
system.nfs4_acl=0sAAAABAAAAAAAAAAAABYBhwAAAAZPV05FUkAAAAAAAAAAAAAAABIAhwAAAAQyMTAxAAAAAAAAAAAAEgCHAAAABkdST1VQQAAAAAAAAAAAAAAAEgCAAAAACUVWRVJZT09FQAAAAA==
user.department="engineering"

(The first line is the same slash-stripping bookkeeping note as in Section 21.4.3.) Two attributes crossed the NFS mount: user.department, written by the client, and system.nfs4_acl - the server's NFSv4 rendering of the file's POSIX ACL, presented to capable clients. The same file through the CIFS mount keeps both and accepts more - on client1, as john (setfattr is silent again):

$ setfattr -n user.client -v yes /mnt/smbteam/xattr-test.txt
$ getfattr -d -m - /mnt/smbteam/xattr-test.txt
getfattr: Removing leading '/' from absolute path names
# file: mnt/smbteam/xattr-test.txt
user.client="yes"
user.department="engineering"
Option Description
setfattr -n name -v value file Set one extended attribute
getfattr -d file Display the file's user extended attributes with values
getfattr -d -m - file Match all namespaces, including system.

The DOS attributes from Section 21.4.3 are just one more extended attribute in this picture - user.DOSATTRIB - which is why a file's Windows-side "hidden" flag and its Unix-side ACL coexist on ext4 without collision. Metadata portability across both protocols is a property of the backend filesystem; it is one more reason the share tree lives on ext4 rather than some thinner layer.

Locking is what makes shared data usable rather than merely visible. Both protocols run stateful lock managers: NFSv4 folds locking into the protocol itself (its state and lease machinery), SMB uses oplocks and byte-range locks. The user-space check is flock, whose -n flag makes one non-blocking attempt and fails immediately if the lock is held. On client1, open two terminals as john. In the first, create the lock file and hold a lock on it through NFS for thirty seconds:

$ touch /mnt/team/flock.lock
$ flock -n /mnt/team/flock.lock -c "sleep 30"

The touch and the flock produce no output; the second command holds the lock while it sleeps. In the second terminal, while the first is sleeping:

$ flock -n /mnt/team/flock.lock -c "echo acquired"; echo "status=$?"
status=1

The second attempt did not print acquired; it exited with status 1, flock's report that the lock was already held - the echo after the semicolon makes that status visible. The same experiment on the CIFS mount behaves the same way - lock file first, then the holder, both silent:

$ touch /mnt/smbteam/flock.lock
$ flock -n /mnt/smbteam/flock.lock -c "sleep 30"
$ flock -n /mnt/smbteam/flock.lock -c "echo acquired"; echo "status=$?"
status=1

(First terminal for the holder, then the second for the attempt, exactly as before.) The lock exclusion crossed the network in both protocols - the second client process was refused while the first held the lock. Applications that coordinate through flock or fcntl byte-range locks on a share are coordinating against every client of that share, not just their own host, which is what allows things like build systems and mail stores to live on network storage. The operational corollary: locking depends on the state machinery staying healthy, so smbstatus -L on the server and NFS's state directories are part of the diagnostic path when applications report "stuck" concurrent access.

21.6.3. SMB Signing and Encryption and NFS Authentication Choices

The two protocols protect traffic with different architectures, and a coherent file service needs a stated position on both.

For SMB, this chapter's server requires protection outright: server signing = mandatory and smb encrypt = required. Signing (authenticated message integrity, AES-128-CMAC here) defeats tampering and replay; encryption (AES-128-GCM here) makes the traffic unreadable on the wire. Both are negotiated inside the protocol - no extra ports, no tunnel, no client configuration beyond asking for it (seal for kernel mounts; smbclient and GVfs request encryption automatically when the server offers or requires it). The cost is CPU, modest on modern hardware, and the benefit is that the "network you trust" question disappears from SMB design: a switched office LAN and a routed path get the same protection. The live proof is operational rather than static: every smbstatus line in Section 21.4.4 showed AES-128-GCM/AES-128-CMAC, and every unencrypted dialect attempt in Section 21.5.4 was refused.

For NFS, the same guarantees exist but ride different machinery. sec=sys provides neither integrity nor privacy - it is a trusted networks assumption. The in-protocol answer is the Kerberos family: krb5i for integrity, krb5p for privacy, per-user authentication as the bonus. The cost is the identity infrastructure - KDC, keytabs, gssd on every participant, and the NFSv4 domain aligned everywhere. This chapter documents that path and does not exercise it; the lab instead makes the trust assumption true by construction: direct NFS exists only on the server LAN behind the firewall, and the off-LAN client rides an encrypted WireGuard tunnel (Section 21.7), so every NFS byte in the chapter travels on a controlled path. Sites scaling past what hand-built tunnels manage should treat krb5p or tunnel-everything as the two acceptable answers, pick one, and document the decision the way this paragraph just did - because in two years, the person auditing the file service will need to know which one they are living in.

21.6.4. Monitoring Capacity, Sessions, Errors, and Backup Freshness

A file server that is quietly failing looks exactly like a healthy one from the outside, so the operational habit is a short inspection loop run on a schedule. The pieces all run on filesrv; each example notes the shell it uses.

Capacity, per the volume and per user - df -h /srv/nfs for the first (its output closed Section 21.2.1's setup) and repquota -s for the second (Section 21.6.1). A volume that fills takes every client down at once, so this is the check that becomes a monitored metric first; the quota report doubles as an early-warning system when individual users trend toward their limits.

Sessions, from the server's point of view - smbstatus -b and -S (Section 21.4.4) for SMB, showmount -a for NFS's client list, and the automount's idle behavior means a quiet server should show a short connection table, not an accumulating one. On the NFS side, nfsstat -s summarizes the server's RPC experience:

$ sudo nfsstat -s
Server rpc stats:
calls      badcalls   badfmt     badauth    badclnt
1506       58         0          58         0       

Selected output; the command continues with per-operation counters for NFSv3 and NFSv4. The header row is the health summary: calls grows with use, badfmt and badclnt should stay zero, and badcalls/badauth count requests rejected before service - nonzero values on a quiet server deserve a look at who is being refused, which is exactly the Section 21.7.3 story of a server doing its job against an unauthorized client.

Errors, from the journal - both services' recent history in one query:

$ sudo journalctl -u smbd -u nfs-server --since "20 min ago" --no-pager | tail -n 8
Nov 22 03:59:26 filesrv smbd[29753]: pam_unix(samba:session): session closed for user alice
Nov 22 03:59:34 filesrv smbd[29775]: pam_unix(samba:session): session opened for user john(uid=2100) by (uid=0)
Nov 22 03:59:34 filesrv smbd[29775]: pam_unix(samba:session): session closed for user john
Nov 22 03:59:35 filesrv smbd[29778]: pam_unix(samba:session): session opened for user alice(uid=2101) by (uid=0)
Nov 22 03:59:36 filesrv smbd[29778]: pam_unix(samba:session): session closed for user alice
Nov 22 03:59:48 filesrv smbd[29840]: pam_unix(samba:session): session opened for user john(uid=2100) by (uid=0)
Nov 22 04:00:07 filesrv smbd[29840]: pam_unix(samba:session): session closed for user john
Nov 22 04:00:13 filesrv smbd[29945]: pam_unix(samba:session): session opened for user john(uid=2100) by (uid=0)

The pipeline selects both units' logs since a time bound and keeps the last eight lines; the excerpt shows the healthy rhythm of authenticated sessions opening and closing, which is what "normal" looks like - worth reading once precisely so that abnormal stands out. Chapter 8 and Chapter 28 turn these spot checks into scheduled collection and alerting.

Backup freshness is the check most often skipped, because backups that run are easy to trust and restores that fail are expensive to discover. The lab's backup is a local second copy - realistic enough to demonstrate the verification discipline; Chapter 15 designs the production version with rotation, off-site copies, and protected retention. The copy tool is rsync, from the Debian package of the same name; it is not part of every minimal install, so make sure it is present - on filesrv, as john:

$ sudo apt install rsync

On a system that already has it, apt reports that the newest version is installed and changes nothing; otherwise it prints its plan and asks for confirmation, exactly like the Section 21.2.1 install. The copy itself is sustained administrative work - on filesrv, open a root shell again ($ sudo -i from john's shell) and keep it for the rest of this subsection. Make the copy:

# mkdir -p /srv/backup/team
# rsync -a --delete /srv/nfs/team/ /srv/backup/team/

rsync -a preserves ownership, modes, and timestamps; --delete makes the copy mirror the source, removing files that vanished. Both commands are silent. Create a fresh file worth protecting, copy again, and verify with a checksum (the write, the ownership fix, and the copy are all silent too):

# printf "important data\n" > /srv/nfs/team/backup-test.txt
# chown john:team /srv/nfs/team/backup-test.txt
# rsync -a --delete /srv/nfs/team/ /srv/backup/team/
# sha256sum /srv/nfs/team/backup-test.txt /srv/backup/team/backup-test.txt
d0eac8f61f9c7085dbb626bf1aef1d3c42afedbbd636b1487745ca7a4ce7d71e  /srv/nfs/team/backup-test.txt
d0eac8f61f9c7085dbb626bf1aef1d3c42afedbbd636b1487745ca7a4ce7d71e  /srv/backup/team/backup-test.txt

Identical digests: the copy is byte-faithful. Now the part that makes it a backup rather than an archive - lose the original and get it back:

# rm /srv/nfs/team/backup-test.txt
# rsync -a /srv/backup/team/backup-test.txt /srv/nfs/team/backup-test.txt
# chown john:team /srv/nfs/team/backup-test.txt

The rm, the restore rsync -a, and the chown are all silent - the deliberate damage and the recovery both leave the terminal quiet. Check the result and the backup's own freshness:

# sha256sum /srv/nfs/team/backup-test.txt
d0eac8f61f9c7085dbb626bf1aef1d3c42afedbbd636b1487745ca7a4ce7d71e  /srv/nfs/team/backup-test.txt
# stat -c "%y %n" /srv/backup/team/backup-test.txt
2026-11-22 04:00:43.349989658 +0000 /srv/backup/team/backup-test.txt

The restored file's digest matches the original's - the round trip is proven, not assumed - and the stat timestamp answers the freshness question a monitoring check should ask: when was this backup last written? A scheduled job that compares the newest timestamp in the backup tree against an expected interval, plus periodic test restores like this one, is the difference between a backup system and a hope. One detail of the restore deserves its own note: rsync -a running as root preserves ownership from the backup copy, so the explicit chown is a belt-and-braces step that documents the intended owner - a habit worth keeping in any restore procedure, which should be tested with the same skepticism applied to permissions, ACLs, and application-level state.

21.6.5. Standalone Restore and the Transition to Clustered File Services

Everything in this chapter is a standalone file server: one machine, one name, one copy of the data. Its failure story is correspondingly simple - the service is down until the machine is back, and the restore story is the one just demonstrated: rebuild or repair the host, remount or restore the data volume, restart nfs-server and smbd, and the clients' hard mounts reconnect on their own. The two design facts that make that story tolerable are the ones this chapter worked hardest to establish: the data lives on its own volume (restorable independently of the OS disk, per Chapter 15 and Chapter 16), and the share namespace is served from stable names (files.lab.example) whose addresses can be repointed after a rebuild.

When downtime tolerance tightens, the same service moves to shared or clustered infrastructure, and the transition changes specific things this chapter set up by hand:

  • Identity moves off individual hosts first. A cluster presenting one server identity needs one account and UID source - the LDAP or Active Directory backend of Chapter 35 - because per-host /etc/passwd files cannot stay aligned across nodes that fail independently.
  • Samba clusters through CTDB, which manages a floating address and a replicated trivial database so several smbd nodes present one server; the shares and passdb stay conceptually as built here, with the cluster providing the single-name illusion. Chapter 32 builds a clustered Samba walkthrough.
  • NFS on a shared disk pairs with DRBD replication or a SAN and a cluster resource manager that mounts the volume, starts nfs-server, and moves a virtual IP - the same export tree, now with fencing to guarantee exactly one server at a time; Chapter 32's active-passive NFS walkthrough does exactly this.
  • Distributed filesystems (CephFS, GFS2-style shared cluster filesystems) remove the single-server bottleneck entirely by making the storage itself the cluster; the export and share configuration then moves to the cluster's gateway nodes, and Chapter 33 covers the architecture.

None of those transitions is a configuration tweak on this chapter's server - they are different infrastructure, with the cluster's membership, quorum, and fencing machinery as the price of continuous service. What carries over unchanged is everything this chapter established at the layers above the storage: the export policy and share definitions, the identity discipline, the firewall layering, the client mount patterns, and the monitoring and restore habits. A site that has those habits on a standalone server arrives at its first cluster already knowing how to run a file service; it only has to learn how to run the cluster underneath.