Kahibaro
Discord Login Register

4.3.3 Kernel parameters

Understanding Kernel Parameters

Kernel parameters are settings that influence how the Linux kernel behaves at boot time and, in many cases, at runtime. They are typically used to:

You usually encounter kernel parameters in:

Categories of Kernel Parameters

Kernel parameters are not all the same type. You’ll typically see:

Boot-time Command-Line Parameters

These are passed in by the bootloader via a linux / kernel line. For example, a GRUB linux line might contain:

linux /boot/vmlinuz-6.8.0 root=/dev/sda2 ro quiet splash mitigations=auto

Common examples:

Module Parameters on the Command Line

Parameters can also be passed to specific built-in or early-loaded drivers. Syntax:

Examples:

For built-in drivers, these go on the kernel command line. For loadable modules, they can also be set via files in /etc/modprobe.d/ (covered in the Kernel modules chapter).

Viewing Active Kernel Parameters

What Was Passed at Boot: `/proc/cmdline`

The kernel’s boot arguments are visible in /proc/cmdline:

cat /proc/cmdline

You’ll see a single line, for example:

BOOT_IMAGE=/boot/vmlinuz-6.8.0 root=UUID=... ro quiet splash mitigations=auto

This is read-only and shows what the kernel actually received from the bootloader.

Sysctl Parameters: `/proc/sys` and `sysctl`

Many kernel tunables are exposed as sysctl parameters. They live as files under /proc/sys, and you work with them via:

Examples:

# Show current value
cat /proc/sys/net/ipv4/ip_forward
sysctl net.ipv4.ip_forward
# Change at runtime (not persistent)
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
sudo sysctl net.ipv4.ip_forward=1

sysctl supports:

Configuring Boot-Time Kernel Parameters (GRUB)

Details of the bootloader itself are covered elsewhere; here we focus on where to place parameters.

On most GRUB-based distributions (Debian/Ubuntu/RHEL/Fedora-style):

  1. Edit /etc/default/grub as root.
  2. Look for the line:
   GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

or

   GRUB_CMDLINE_LINUX="..."
  1. Append your parameters inside the quotes, e.g.:
   GRUB_CMDLINE_LINUX_DEFAULT="quiet splash mitigations=off"
  1. Update the GRUB configuration:
    • Debian/Ubuntu/etc.:
     sudo update-grub
     sudo grub2-mkconfig -o /boot/grub2/grub.cfg
  1. Reboot.

To test temporarily, many bootloaders allow you to edit the boot entry at boot time (e.g., press e in GRUB, edit the linux line, then boot). That change is not persistent.

Persisting Sysctl Parameters

Runtime sysctl changes are lost on reboot unless you store them in config files.

Typical approach:

Example file /etc/sysctl.d/99-custom.conf:

net.ipv4.ip_forward = 1
vm.swappiness = 10

Apply immediately without reboot:

sudo sysctl -p /etc/sysctl.d/99-custom.conf

Or:

sudo sysctl --system

This loads all standard sysctl configuration paths.

Common Kernel Parameters (Practical Examples)

These examples focus on parameters people often need in real-world scenarios. Always review your distribution’s documentation before using them in production.

Boot and Init-Related

Debugging and Logging

Debug-heavy parameters can flood the console; use cautiously and usually only temporarily.

Hardware / Boot Workarounds

These are highly hardware-specific. Examples:

Always treat such options as diagnostic unless recommended by a vendor or distro.

CPU and Security Mitigations

Use security-impacting parameters only with a clear understanding of the tradeoffs.

Memory and VM-Related Tunables (sysctl)

These are set via sysctl, not generally via the bootline.

Examples:

Networking Sysctls

Examples:

These are typically placed in /etc/sysctl.d for servers with specific networking roles.

Discovering Available Parameters

Documentation

Much official documentation resides under /usr/share/doc/ and the kernel documentation tree (on systems with kernel-doc installed). Relevant places:

Search within that file for parameter names you see in /proc/cmdline or distribution guides.

Listing Sysctl Parameters

To explore what is tunable via sysctl:

sysctl -a | less

Use grep to narrow down:

sysctl -a | grep net.ipv4
sysctl -a | grep vm.

Safety and Best Practices

Taken together, these practices let you use kernel parameters as a powerful tuning and troubleshooting tool without making your system unbootable or insecure.

Views: 143

Comments

Please login to add a comment.

Don't have an account? Register now!