Wednesday, 2 November 2016

'dmesg’ Command for Troubleshooting Kernel level issues


What is Dmesg:

     Dmesg is the command in linux which allows us to debug the kernel level errors.This will print or control the kernel ring buffer.

Kernel Ring Buffer:

     Kernel Ring Buffer is the data structure that records the data related to kernel.Ring Buffer is the special buffer that stores the data temporary and removes the old messages when new message arrives.

These dmesg will very helpful for debug the system issues in kernel level ( device drivers ).

1. List the sample results in dmesg:

     we can load the dmesg results with the help of text manipulation tools like more,less,tail etc.

Command:  # sudo dmesg | more
                     # sudo dmesg | less

Sample Output:


2. Check all detected drives:

                   # sudo dmesg | grep sda

Sample output:


3. Search for the particular string:

                       # sudo dmesg | grep -i "memory" 
                       # sudo dmesg | grep -i "dma"
                       # sudo dmesg | grep -i "usb"

Sample output:


4. To clear the dmesg logs:

                      # sudo dmesg -c 

This will clear the dmesg ring buffer.log which stored will get flushed.

5. To print the raw message:

                      # sudo dmesg -r 

6.Difference Between Dmesg and /var/log/messages

dmesg : dmesg is an (display or driver) message. It is used to examine or control the kernel ring buffer.
messages : It contains global system messages, including the messages that are logged during system startup. There are several things that are logged in /var/log/messages including mail, cron, daemon, kern, auth, etc.

Alternatively you can even troubleshoot the kernel level using multipath command.

No comments:

Post a Comment