【问题标题】:Change default console loglevel during boot up [closed]在启动期间更改默认控制台日志级别[关闭]
【发布时间】:2013-05-05 23:02:13
【问题描述】:

我设置了一个 CentOS 6.3 设置,其中控制台日志级别设置为 4,默认日志级别设置为 4。我知道我可以使用以下步骤更改默认控制台日志级别:

cat /proc/sys/kernel/printk

4   4   1   7

echo 5 > /proc/sys/kernel/printk
cat /proc/sys/kernel/printk

5   4   1   7

但是,重新启动后,控制台日志级别会恢复为原始值。我是否需要重新编译内核,或者有什么方法可以让更改的值在重新启动后保持不变。

【问题讨论】:

    标签: linux linux-kernel


    【解决方案1】:

    是否需要重新编译内核,

    没有。

    或者有没有办法让更改的值在重新启动后保持不变。

    是的。
    使用内核命令行参数loglevel

    loglevel=       All Kernel Messages with a loglevel smaller than the
                        console loglevel will be printed to the console. It can
                        also be changed with klogd or other programs. The
                        loglevels are defined as follows:
    
                        0 (KERN_EMERG)          system is unusable
                        1 (KERN_ALERT)          action must be taken immediately
                        2 (KERN_CRIT)           critical conditions
                        3 (KERN_ERR)            error conditions
                        4 (KERN_WARNING)        warning conditions
                        5 (KERN_NOTICE)         normal but significant condition
                        6 (KERN_INFO)           informational
                        7 (KERN_DEBUG)          debug-level messages
    

    内核命令行上可能的完整参数列表位于源代码树的Linux/Documentation/kernel-parameters.txt 文件中。

    根据您的引导加载程序(例如 Grub 或 U-Boot),您必须编辑文本才能将此新参数添加到命令行。使用cat /proc/cmdline查看上次启动时使用的内核命令行。


    附录

    要显示所有内容,为 loglevel 参数提供的数字将大于 KERN_DEBUG。
    也就是说,您必须指定 loglevel=8
    或者简单地使用ignore_loglevel 参数来显示所有内核消息。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-14
    • 1970-01-01
    相关资源
    最近更新 更多