How to Set Kernel Options in Ubuntu 18.04 (Bionic)

by ebsf   Last Updated July 12, 2019 22:02 PM

I'm currently building a router using Ubuntu Server 18.04 (bionic) and am stepping through various configuration tasks. The advent of Systemd and Netplan mean I'm breaking some new ground and having to synthesize multiple sources, and discerning deprecation is nontrivial.

I'm currently roughing out my kernel and other configuration via /etc/sysctl.conf. A distinction seems to exist between (a) kernel parameters or variables, which are read from /etc/sysctl.conf and /etc/sysctl.d/*.conf at runtime; and (b) kernel options.

Specifically, the documentation for several kernel variables make reference to various CONFIG_* settings/options but with no guidance about how or where to enable them. E.g., the documentation for kernel.hung_task_panic at https://sysctl-explorer.net/kernel/hung_task_panic/ states:

Controls the kernel’s behavior when a hung task is detected. This file shows up if CONFIG_DETECT_HUNG_TASK is enabled.

[Note: This particular file happens to appear in 18.04.2 but I'm using it as an example because it's handy.]

THE QUESTION is how and where to enable kernel options like the CONFIG_DETECT_HUNG_TASK option from above, on modern Linux systems and Ubuntu 18.04 in particular. No definitive guidance seems to exist and the few references I've found are years old and with a nontrivial risk of deprecation given intervening years and releases.

The current hypotheses are:

  1. Add a line with the option in /etc/sysctl.conf, similar to how one might add TCP_NODELAY to /etc/smb.conf.

  2. Add a line with the option to the bootloader configuration file /etc/default/grub.

  3. Add a line with the option to whichever other configuration file (which?) is read at runtime to write /boot/config-*-generic.

  4. Build and recompile the kernel from scratch using

make menuconfig

and related steps, which themselves are poorly and anciently, or at least inconspicuously, documented besides seeming unnecessarily complex.

Thanks in advance for any thoughts.



Related Questions


Preventing the system running out of memory

Updated August 01, 2017 12:02 PM

How can I completely prevent core dumps?

Updated June 23, 2018 14:02 PM

How can I enable core dump?

Updated June 23, 2018 18:02 PM

How to remove kernel?

Updated July 03, 2015 19:00 PM

Scripted changing kernel config with dependency?

Updated October 14, 2015 05:01 AM