Thursday, April 29, 2010

Suppress kernel talkativness

Kernel log levels (defined in linux/kernel.h):
#define KERN_EMERG    "<0>"  /* system is unusable               */
#define KERN_ALERT    "<1>"  /* action must be taken immediately */
#define KERN_CRIT     "<2>"  /* critical conditions              */
#define KERN_ERR      "<3>"  /* error conditions                 */
#define KERN_WARNING  "<4>"  /* warning conditions               */
#define KERN_NOTICE   "<5>"  /* normal but significant condition */
#define KERN_INFO     "<6>"  /* informational                    */
#define KERN_DEBUG    "<7>"  /* debug-level messages             */
Check the current log level:
deby:~# cat /proc/sys/kernel/printk
7 4 1 7

sysctl.conf

Ensure you have the following in /etc/sysctl.conf:
# The four values in printk denote: 
# console_loglevel, default_message_loglevel,
# minimum_console_loglevel, default_console_loglevel
#
# Uncomment the following to stop low-level messages on console
kernel.printk = 4 4 1 6
These changes become effective after reboot. But you might need changes take place immediately:
echo "4 4 1 6" > /proc/sys/kernel/printk

grub

You can pass quiet parameter during kernel boot in /boot/grub/menu.list in order to suppress logs during boot:
kernel /boot/vmlinuz-2.6.26-2-686 root=/dev/sda1 ro quiet panic=0
Please note that after kernel upgrade the above changes to grub will be lost, so take this into account or add another section to your grub loader as shown below.
# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST
title    Debian GNU/Linux, kernel 2.6.26-2-686 (quiet)
root     (hd0,0)
kernel   /boot/vmlinuz-2.6.26-2-686 root=/dev/sda1 ro quiet panic=0
initrd   /boot/initrd.img-2.6.26-2-686

### BEGIN AUTOMAGIC KERNELS LIST
## lines between the AUTOMAGIC KERNELS LIST markers will be modified
## by the debian update-grub script except for the default options 
## below

No comments :

Post a Comment