10

We normally do cat /proc/kmsg or dmesg to see the kernel logs from user space.

I understand the dmesg is a circular buffer which copies from kmsg. But is kmsg also not a circular buffer?

What is the difference and relation between them?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Saurabh Sengar
  • 878
  • 2
  • 12
  • 20
  • Have a look at [How to read ring buffer within linux kernel space?](http://stackoverflow.com/questions/9533708/how-to-read-ring-buffer-within-linux-kernel-space) for a great answer with nice references. – Mike Satteson Jan 30 '15 at 13:32

2 Answers2

6

Loosely speaking dmesg is a program that dumps /proc/kmsg. In addition, it provides some filtering capabilities to weed out logs that the user isn't interested in.

R.D.
  • 2,471
  • 2
  • 15
  • 21
3

The output of /proc/kmsg can be directed to a file when collecting large amount of logs so that no logs are lost.

dmesg is circular buffer and previous logs get overwritten once the buffer is full.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Tarun Gupta
  • 132
  • 1
  • 7