Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enlarge Linux Kernel Log Buffer more that 2M

I am in the process of collecting some sort of Linux Kernel activities. I have placed multiple printk statements with in the kernel source code and would like to monitor those during regular kernel activities. Unfortunately, I have realized that the Kernel Log Buffer size (CONFIG_LOG_BUF_SHIFT) cannot be more that 2^21 which is essentially equal to 2M entries.

Is there any other way to record more than 2M Kernel messages ?

like image 658
ARH Avatar asked Dec 24 '14 17:12

ARH


People also ask

How do you increase the log buffer size?

Via the UI As of Android 5.0, there's also way to change the buffer size via Developer options on the device. First enable Developer options in Settings. Then navigate to the newly visible Developer options entry, scroll down, and click on logger buffer size . This will display options ranging from off to 16Mb .

How big is the kernel ring buffer?

Use a buffer of size bufsize to query the kernel ring buffer. This is 16392 by default. (The default kernel syslog buffer size was 4096 at first, 8192 since 1.3.


1 Answers

You can set the kernel log buffer to log_buf_len=4M in your /boot/grub/grub.conf. This should increase the log buffer size to 4 MiB. Note you can also edit the grub during boot, and append the log_buf_len=4M at the end of the line starting with the kernel ....

CONFIG_LOG_BUF_SHIFT shows the default size of the kernel log buffer not the maximum size, you can set this to larger value but would require to recompile the kernel.

ex:
2 ^ 19 = 512 KiB
2 ^ 20 = 1 MiB
2 ^ 21 = 2 MiB
2 ^ 22 = 4 MiB

Which flavor or kernel version of Linux are you on, this works well on SuSE and RHEL.

like image 149
askb Avatar answered Sep 28 '22 05:09

askb