« Back to What is ...?

What is a kernel ring buffer?

This article has last been updated at .

What is a kernel ring buffer?

The kernel ring buffer on Linux stores information about important kernel events that can be used by the system administrator to troubleshoot.

The kernel ring buffer on Linux holds important system events and makes it available to the system administrator. It is maintained by the kernel itself and is stored in memory. The contents of the ring buffer is available to user space, so it can easily be viewed with a tool like dmesg. The kernel will log events to the buffer that are usually related to the boot process, kernel modules being loaded or unloaded, hardware support, systemd activation, firewall events, memory, and serious issues with processes.

Buffer size

The size of the kernel ring buffer is defined during compilation of the kernel itself, so typically your Linux distribution decides an acceptable size. To find this, we need to extract the value of CONFIG_LOG_BUF_SHIFT from the kernel configuration file. This file is typically stored in /boot or /proc.

# grep ^CONFIG_LOG_BUF_SHIFT /boot/config-$(uname -r)
CONFIG_LOG_BUF_SHIFT=17

If the configuration is not available in the /boot, then it might be stored in /proc.

zgrep CONFIG_LOG_BUF_SHIFT /proc/config.gz

This will return a value, like the value 17 above. To turn this into a size, we need to calculate this by using 2 to the power of 17 (2^17), resulting in the number 131072, which means 128 kilobytes.

ValueSize of buffer
18256 KB
17128 KB
1664 KB
1532 KB
1416 KB
138 KB
124 KB

Learn more about dmesg

This article uses the dmesg command to achieve its tasks. Want to learn how to use it or additional options that may be available?

» Mastering the tool

Installation and usage of dmesg

Feedback

Small picture of Michael Boelen

This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution!

Mastodon icon

Related articles

Like to learn more? Here is a list of articles within the same category or having similar tags.