7

Is it possible to set Linux kernel sysctl settings (those usually set in /etc/sysctl.d) using kernel command line (those visible in /proc/cmdline)?

(Using grub config file /etc/default/grub variable GRUB_CMDLINE_LINUX="...".)

4
  • Your question makes no sense to me. What exactly are you trying to achieve?
    – fpmurphy
    Commented Dec 25, 2019 at 3:39
  • Quiet boot. Setting kernel.printk=3 3 3 3 using kernel command line parameter to avoid having to set it in initramfs to avoid kernel information leaks. phabricator.whonix.org/T950
    – adrelanos
    Commented Dec 25, 2019 at 9:40
  • As far as I know, it is not possible to do this from the kernel command line.
    – fpmurphy
    Commented Dec 26, 2019 at 1:01
  • @adrelanos I assume by information leaks you're talking about symbol addresses, in which case who are you trying to avoid giving the information to? Assuming you've restricted access to dmesg, there's no reason to stop it from being printed at very early boot.
    – forest
    Commented Feb 14, 2021 at 0:15

1 Answer 1

13

Sysctl parameters can be set via the kernel command-line starting with kernel version 5.8, thanks to Vlastimil Babka from SUSE.

sysctl.*=       [KNL]
                Set a sysctl parameter, right before loading the init
                process, as if the value was written to the respective
                /proc/sys/... file. Both '.' and '/' are recognized as
                separators. Unrecognized parameters and invalid values
                are reported in the kernel log. Sysctls registered
                later by a loaded module cannot be set this way.
                Example: sysctl.vm.swappiness=40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .