Every few months someone pastes a line into /etc/sysctl.conf, reboots, and the value never changes. Then they blame FreeBSD. The knob was a boot-time tunable, it belonged in /boot/loader.conf, and the system told them exactly that if they had asked it the right way.
Two files, two moments
/boot/loader.conf is read by the loader before the kernel starts. Values land in the kernel environment, and tunables pick them up while the kernel initializes. /etc/sysctl.conf is applied by rc after the system is up, through sysctl(8), which means it can only change things that are writable at runtime.
Some knobs are both: a tunable that is also writable later. Some are only one. A few are neither, because they are facts about the hardware. The man page is sysctl(8) for the tool and loader.conf(5) for the boot side.
Ask the kernel instead of guessing
sysctl -d vfs.zfs.arc.max # one-line description
sysctl -aT # everything the loader can set
sysctl -aW # everything writable at runtime
sysctl -t kern.maxfiles # type of the variable
-T lists variables that can be set from the loader. -W lists the ones you can write on a running system. Run both and compare: a name in -T but not -W is boot-only, a name in -W but not -T is runtime-only, and a name in both is flexible. That is the whole decision procedure. I do not know why people keep a folder of forum bookmarks instead.
To check a single variable, grep the lists:
sysctl -aT | grep ^kern.ipc.nmbclusters
sysctl -aW | grep ^kern.ipc.nmbclusters
Flag semantics have shifted across releases for some variables, so run this on the box you are tuning, not the one you remember.
kenv shows what the loader handed over
When a loader.conf value seems ignored, check whether it even reached the kernel:
kenv | grep vfs.zfs
kenv -q vfs.zfs.arc.max
kenv(1) prints the kernel environment. If your setting is missing here, the problem is in loader.conf (typo, wrong file, quoting) and not in the kernel. If it is present but sysctl reports something different, the kernel clamped or overrode it, and the variable’s own documentation is where to look next. Two files, one question each, and it splits the debugging in half.
Quoting that bites
Values in loader.conf are quoted strings, sysctl.conf takes bare name=value:
# /boot/loader.conf
vfs.zfs.arc.max="4294967296"
# /etc/sysctl.conf
net.inet.tcp.msl=15000
Both examples are illustrations of syntax, not recommendations. Do not copy a number you do not understand. If you do tune ARC, read why the ARC is not a leak first.
Applying without a reboot
sysctl net.inet.tcp.msl=15000 # now, until reboot
service sysctl reload # reapply /etc/sysctl.conf
Test a value live, watch it, and only then commit it to the file. The same discipline applies on the other OS, where you would do it with the ephemeral port range and a pile of sysctl -w.
Where it bites
- Silent no-op in the wrong file. A tunable in
sysctl.confthat is boot-only produces a complaint at boot that nobody reads. Checkdmesgand the console messages. - Copying tuning from old blog posts. Many defaults were reworked over the years and some of those knobs now autotune. A stale tuning guide can make a box worse than stock.
- Names change. The OpenZFS import renamed ARC variables, so an old
vfs.zfs.arc_maxline from a ten-year-old config is not the same animal.sysctl -don your release tells you what exists. - Read-only means read-only. Hardware facts such as
hw.physmemare reports, not settings.
I came to this after years of treating sysctl.conf as a magic drawer, and the day I ran sysctl -aT for the first time I was annoyed at how much of my folklore had been one flag away from being checkable. Fine. Consider it checked.
More like this in the FreeBSD and OpenBSD hub.
