Runtime Kernel Changes Last Until Reboot Unless Written to Their Configuration Directory
modprobe, sysctl -w and swapoff change the running kernel only. At the next boot, systemd rebuilds that state from configuration files, so a node prepared by typing commands works perfectly until its first reboot. Every runtime change needs a persistent twin in the file systemd reads at boot.
Three Commands and Their Persistent Twins
| Change now | Persist in | Applied at boot by |
|---|---|---|
modprobe br_netfilter |
/etc/modules-load.d/*.conf, one module per line |
systemd-modules-load.service |
sysctl -w net.ipv4.ip_forward=1 |
/etc/sysctl.d/*.conf, key = value |
systemd-sysctl.service |
swapoff -a |
remove or comment the swap line in /etc/fstab |
systemd-fstab-generator, which turns fstab swap lines into swap units |
Kubernetes nodes need all three: the overlay and br_netfilter modules, IP forwarding and bridge filtering through sysctl, and, by default, no swap. The swap pair, as my bootstrap script had it:
swapoff -a # disable now
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab # disable on reboot
Write the File First, Then Apply It
Writing the file and then loading it from the file keeps the live state and the boot state identical:
sysctl --system # reload every /etc/sysctl.d file now
systemctl restart systemd-modules-load # load the modules listed in modules-load.d
When swap comes from somewhere other than fstab (a zram device, a hand-written .swap unit), swapon --show lists it, and masking its unit (for example systemctl mask dev-sda3.swap) stops systemd from activating it.
Configuration management does both halves in one task: Ansible's ansible.posix.sysctl module writes the value to a file and reloads it. Checking for the line before appending keeps a re-run from duplicating it (see Idempotent Scripts Check the Current State Before Changing It).
Swap has a third source besides fstab and hand-written units: systemd can activate a GPT swap partition it discovers itself. systemctl mask swap.target stops every swap unit from being pulled in at boot, whatever created it.
Test the Reboot, Not the Shell
A check run in the same session only proves the runtime state. Reboot once after preparing a node, then verify:
lsmod | grep br_netfilter
sysctl net.ipv4.ip_forward net.bridge.bridge-nf-call-iptables
swapon --show # prints nothing when swap is off
Over plain SSH as a normal user, sysctl and swapon may be "not found": they live in /usr/sbin. The same answers come from /proc: cat /proc/sys/net/ipv4/ip_forward /proc/swaps.
References
- Linux Administration MOC - hub for Linux notes.
- Kubernetes MOC - the node requirements these settings serve.
- Idempotent Scripts Check the Current State Before Changing It - writing the persistent files without duplicating lines.
- kubelet Depends on containerd Through the CRI Socket - another setting read only at startup.
- Kubernetes documentation: Container Runtimes, prerequisites - the modules and sysctl values a node needs.
- systemd: modules-load.d - the module list read at boot.
- systemd: sysctl.d - the kernel parameters applied at boot.
- systemd: systemd-fstab-generator - how fstab swap lines become swap units.
- Debian 13 release notes: /etc/sysctl.conf is no longer honored - the dropped compatibility symlink.
- Ansible: ansible.posix.sysctl - the
sysctl_fileoption and its default,/etc/sysctl.conf(last checked 2026-11).