A tiny FreeBSD jail doc fix
A short note on fixing relative symlinks in the FreeBSD Handbook's NullFS thin-jail recipe.
I submitted a small FreeBSD Handbook patch for the NullFS thin-jail recipe. It addresses a specific problem: after following the documented layout, some relative symlinks inside the jail point at the wrong tree.
Why the links break
The setup separates a reusable base from a per-jail skeleton. Most of the release can be shared, while local state lives in the skeleton. But files moved into that skeleton can still contain relative symlinks written for the normal FreeBSD filesystem layout.
For example, a certificate link under /etc/ssl/certs can contain the target ../../../usr/share/certs/.... The target is resolved from the link’s containing directory, not from the filesystem root.
Normal system
/etc/ssl/certs
+ ../../../usr/share/certs/...
→ /usr/share/certs/...
Thin-jail skeleton
/skeleton/etc/ssl/certs
+ ../../../usr/share/certs/...
→ /skeleton/usr/share/certs/...
The shared files are at /usr/share, not /skeleton/usr/share. A jail can therefore look mostly correct while containing broken certificate links, which can make basic operations such as package bootstrapping fail.
A bridge back to the shared base
The patch leaves the existing relative links intact. It adds two bridge symlinks inside the skeleton instead:
cd /usr/local/jails/templates/...-RELEASE-skeleton/usr
ln -s ../../usr/share share
ln -s ../../usr/sbin sbin
Here ...-RELEASE-skeleton is a placeholder for the release-specific skeleton directory from the recipe, not a literal directory name.
The resulting path is:
/skeleton/usr/share
→ ../../usr/share
→ /usr/share
With that bridge, the certificate link reaches the shared base without being rewritten. The sbin bridge covers the same class of problem for paths such as /etc/rmt.
Public patch record
- FreeBSD bug 280339 — broken symlinks inside a thin NullFS jail
- Original patch attachment
- Rebased patch attachment
I submitted this patch to FreeBSD bug 280339 on 2024-08-22. As of this writing the bug is still open and the change has not been merged upstream. FreeBSD doc PR 334 (February 2024) is a separate Handbook fix by another contributor, not this symlink bridge.
This is the kind of fix I like: small, boring, and close to the failure. Documentation commands are code too. If someone copies a Handbook recipe exactly, the result should be a working jail.