尝试禁用控制台输出,console=null 不起作用

use*_*931 7 command-line boot console linux-kernel

如上所述,我想完全关闭控制台输出,但将console=console=null放入内核命令行并不会改变任何事情。当我进入quiet内核命令行时,它近似于这项工作,但我想完全关闭输出。

那么为什么console=null不起作用,甚至没有错误消息?

slm*_*slm 9

1. 使用 dmesg

一种方法是使用dmesg

   -n, --console-level level
          Set the level at which logging of messages is done to the console.  
          The level is a level number or abbreviation of the  level  name.
          For all supported levels see dmesg --help output.
Run Code Online (Sandbox Code Playgroud)

例如:

$ sudo dmesg -n0
Run Code Online (Sandbox Code Playgroud)

2. 使用 rsyslog

另一种方法是通过rsyslog. 配置文件/etc/rsyslog.conf

#kern.*                                                 /dev/console
Run Code Online (Sandbox Code Playgroud)

将此行更改为:

kern.*                                                 /dev/null
Run Code Online (Sandbox Code Playgroud)

注意:需要重新启动rsyslogsudo service rsyslog restart

3. 使用 sysctl

最后,您可以通过sysctl.

我建议你改变你的/etc/sysctl.conf. 具体来说,您想调整kernel.printk行。

# Uncomment the following to stop low-level messages on console
kernel.printk = 3 4 1 3
Run Code Online (Sandbox Code Playgroud)

您可以查看当前设置:

$ sudo sysctl -a|grep "kernel.printk\b"
kernel.printk = 4   4   1   7
Run Code Online (Sandbox Code Playgroud)

4.使用静默

如果你真的想禁用所有记录,即使在开机,则字符串更改quietsilent在引导参数在GRUB内核中,/boot/grub2/grub.cfg

linux   /vmlinuz-3.12.11-201.fc19.x86_64 ... rhgb silent ....
Run Code Online (Sandbox Code Playgroud)


use*_*931 0

U-Boot 使用以下命令完全执行其应该执行的操作(静默输出):

#定义CONFIG_EXTRA_ENV_SETTINGS \

        "silent=1\0" \
Run Code Online (Sandbox Code Playgroud)

似乎这种情况只发生在我的系统上。