4

I am trying to understand the SATA Host-Device Communication and for that I have put a lot of debug messages in the kernel driver code. Now messages are in such a huge amount that I am not able to see the initial messages of the device enumeration in the dmesg log. For the same I have modified CONFIG_LOG_BUF_SHIFT(=21) config variable to increase the ring buffer size from where dmesg takes the message but still I am facing the same issue.

So, Is there any method available by which I can log all the dmesg from the kernel boot in to a specific file?

Thanks for the Help in advance.

1
  • 1
    Do you have journalctl? sudo journalctl -b 0 shows all logs since boot. Commented Jan 1, 2022 at 0:07

2 Answers 2

1

There is a command called dmesg which will print the logs to stdout. You can just redirect stdout to a text file.

dmesg > /path/to/dmesg.txt 

You could extend this. A really useful option would be to add a line to your ~/.profile file (in your home directory) which appends the output of dmesg on login. Simply add a line which says:

dmesg >> /path/to/dmesg.txt 

If you just want the first few lines (0.000000 messages) you can pipe it into head like so.

With stdout:

dmesg | head 

or with head on an already saved .txt file.

head /path/to/dmesg.txt 

That's pretty much it, hope this helps!

EDIT: BTW, this does contain the 0.000000 messages

0

You can use:

cat /var/log/dmesg > file.txt 

and use:

head /var/log/dmesg 

if you want to see the first lines of dmesg.

See too 'man head' for more specifications. The '>' symbol redirect the ouput of 'cat' to the 'file.txt'

1
  • 1
    Thanks for the reply this method I know and tried but it didn't help I want all the messages from start of dmesg. e.g. from "[ 0.000000] Initializing cgroup subsys cpuset" Commented Feb 12, 2016 at 4:36

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.