扩大Linux内核日志缓冲区超过2M [英] Enlarge Linux Kernel Log Buffer more that 2M
问题描述
我正在收集某种Linux内核活动.我在内核源代码中放置了多个printk
语句,并希望在常规内核活动期间对其进行监视.不幸的是,我意识到内核日志缓冲区的大小(CONFIG_LOG_BUF_SHIFT
)不能大于2 ^ 21,这基本上等于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.
还有其他方法可以记录超过2M的内核消息吗?
Is there any other way to record more than 2M Kernel messages ?
推荐答案
您可以在/boot/grub/grub.conf
中将内核日志缓冲区设置为log_buf_len=4M
.这应将日志缓冲区的大小增加到4 MiB.请注意,您还可以在引导过程中编辑grub
,并将log_buf_len=4M
附加在以kernel ...
开头的行的末尾.
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
显示的是内核日志缓冲区的默认大小,而不是最大大小,您可以将其设置为更大的值,但需要重新编译内核.
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
您正在使用哪种口味或Linux内核版本,这在SuSE和RHEL上都能很好地工作.
Which flavor or kernel version of Linux are you on, this works well on SuSE and RHEL.
这篇关于扩大Linux内核日志缓冲区超过2M的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!