是否可以使用内核命令行(在 中可见)来设置 Linux 内核sysctl
设置(通常在 中设置)?/etc/sysctl.d
/proc/cmdline
(使用grub
配置文件/etc/default/grub
变量GRUB_CMDLINE_LINUX="..."
。)
答案1
Sysctl 参数可以通过以下方式设置内核命令行从内核版本开始5.8,感谢弗拉斯蒂米尔·巴布卡来自苏塞。
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