Synopsis #
FreeBSD settings are applied at different stages of startup. A runtime kernel parameter normally belongs in /etc/sysctl.conf; a loader tunable or kernel module belongs in /boot/loader.conf; and service or system startup configuration belongs in /etc/rc.conf. The same-looking assignment is not interchangeable between these files.
Identify the setting type #
Use the narrowest applicable mechanism:
| Setting | Temporary check or change | Persistent file or tool |
|---|---|---|
| Runtime kernel state exposed by sysctl | sysctl name or sysctl name=value |
/etc/sysctl.conf |
| Loader tunable needed before the kernel completes startup | Inspect loader documentation | /boot/loader.conf |
| Service enablement and rc variables | service name status |
sysrc and /etc/rc.conf |
A tunable documented only for the loader should not be placed in sysctl.conf. A writable sysctl should not be moved to loader.conf merely because both files use name=value syntax.
Test a writable sysctl #
Read the current value and its description:
$ sysctl kern.ipc.soacceptqueue
$ sysctl -d kern.ipc.soacceptqueue
If the setting is documented as writable, test the proposed value as root:
# sysctl kern.ipc.soacceptqueue=256
Measure the result before making it persistent. To apply the tested value during normal system startup, add an assignment to /etc/sysctl.conf:
kern.ipc.soacceptqueue=256
This value is only an example of file syntax, not a general tuning recommendation. Keep the system default unless a measured workload and primary documentation justify a change.
Configure an rc service #
Use sysrc instead of editing routine service assignments by hand. For example, enabling the SSH daemon writes the appropriate value to rc.conf:
# sysrc sshd_enable=YES
# service sshd start
Enabling a service controls future startup; it does not necessarily start the service immediately. Starting a service does not necessarily enable it for the next boot.
Configure a loader tunable #
Confirm in the relevant manual page that a value is a loader tunable or that a module must load before startup completes. Add only that documented assignment to /boot/loader.conf, then reboot during a maintenance window.
An invalid loader setting can affect boot. Keep access to the boot loader menu or system console so the assignment can be bypassed or corrected.
When the proposed change is described as a kernel option, first use Choose a custom kernel, module, or loader setting to determine whether GENERIC plus a loadable module or documented tunable preserves a simpler update and recovery path.
Verify after reboot #
After the next reboot, repeat the read-only command used before the change. For services, check both the saved configuration and current state:
$ sysrc sshd_enable
# service sshd status