Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change default console loglevel during boot up [closed]

I setup a CentOS 6.3 setup, on which the console loglevel is set to 4, and default log level is set to 4. I know I can change the default console log level using the following steps:

cat /proc/sys/kernel/printk  4   4   1   7  echo 5 > /proc/sys/kernel/printk cat /proc/sys/kernel/printk  5   4   1   7 

However, upon reboot, the console log level reverts back to the original value. Do I need to recompile the kernel, or is there a way I can get the changed value to be persistent across reboot.

like image 254
Ahmed A Avatar asked May 05 '13 23:05

Ahmed A


People also ask

How do I change the logging level in Linux?

You can change the logging level or trace level (also called the debug level) of a running process by sending a USR1 or USR2 signal to the process. Sending a USR1 signal changes the logging level and sending a USR2 signal changes the trace level.

Which log level is considered the most critical in Linux?

There are basically eight log levels which a message sent by the linux kernel can adopt, starting from level 0 and decreasing in severity 'till level 7 : the lowest log level identifier, the most critical context.


1 Answers

Do I need to recompile the kernel,

No.

or is there a way I can get the changed value to be persistent across reboot.

Yes.
Use the kernel command line parameter 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 

The entire list of parameters possible on the kernel command line are in the Linux/Documentation/kernel-parameters.txt file in the source tree.

Depending on your bootloader (e.g. Grub or U-Boot), you will have to edit text to add this new parameter to the command line. Use cat /proc/cmdline to view the kernel command line used for the previous boot.


Addendum

To display everything, the number supplied for the loglevel parameter would have be be greater than KERN_DEBUG.
That is, you would have to specify loglevel=8.
Or simply use the ignore_loglevel parameter to display all kernel messages.

like image 119
sawdust Avatar answered Sep 22 '22 06:09

sawdust