1.7 KiB
name, description, metadata
| name | description | metadata | ||
|---|---|---|---|---|
| nfs-root-squash-loses-mtimes | sudo cp -a onto the NAS docs/video/etc exports silently loses mtimes because only /nas has no_root_squash; copy as connor instead |
|
Copying with sudo cp -a onto any of the per-directory NAS exports
(/nas/docs, /nas/video, …) silently discards the original mtimes and stamps
every file with the copy time. cp reports success and the file contents are
correct, so it is easy to miss.
Cause. /etc/exports on the NAS gives no_root_squash to /nas ONLY:
/nas 10.0.0.0/28(rw,fsid=root,no_root_squash)
/nas/docs 10.0.0.0/28(rw,async)
So on /nas/docs the client's root is squashed to anonymous. POSIX allows
setting an arbitrary mtime only to the file's owner or CAP_FOWNER; setting it
to now needs only write permission. Squashed root has the latter and not the
former, so nfsd downgrades the SETATTR and writes the current time. A root-owned
file on that export cannot have its mtime set from the client at all.
The tell: the client reads back the correct mtime from its attribute cache while
the server has the wrong one. Always confirm with
ssh nas stat -c %y /nas/docs/... — the client's view will lie to you.
Fix, in order of preference:
- Copy as
connor, not with sudo. The new files are connor-owned, and connor can then set arbitrary mtimes on them. - If the files are already root-owned,
sudo chown -R connor:connorON THE NAS over ssh (the client cannot chown there either), then set mtimes as connor.
Observed 2026-10-02 archiving 20,116 viseron files; the first pass "fixed 19,924 mtimes" and persisted none of them. Related: nas-dual-homed-wifi-path.