Dmesg

From Helpful
Revision as of 17:24, 27 February 2024 by Helpful (talk | contribs)
Jump to navigation Jump to search
This article/section is a stub — some half-sorted notes, not necessarily checked, not necessarily correct. Feel free to ignore, or tell me about it.

dmesg is a fixed-size ringbuffer in linux kernel memory, on the order of hundreds of KByte large.


Both writing (printk()) and reading from dmesg (/dev/kmsg) is effectively privileged thing, so it is not used for general purpose logging.

(note that your userspace logger might well choose to read out dmesg and write it to its own logs)


Primarily some lower level details from the kernel; things that write to it include

  • boot code
  • ongoing important evens like
  • changes in connected devices
  • oom-killer
  • segfaults
  • device errors


Ringbuffer means that once full, it rewrites old lines.


That fixed size is usually on the order of dozens to hundreds of kilobytes. If

grep CONFIG_LOG_BUF_SHIFT /boot/config-`uname -r`

says something like

CONFIG_LOG_BUF_SHIFT=18

that means 256KiB (1<<18)

See also: