Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-17-2010, 05:35 PM   #1
Registered: Sep 2006
Location: Italy
Distribution: Suse 10.1
Posts: 78

Rep: Reputation: 15
save dmesg after crash or reboot

I have a gentoo distribution and need to store the information of dmesg collected until a system crash.
At present, after a reboot or a crash the information in dmesg are lost and are not available at the next reboot. How can I save all the information in dmesg until a crash and read them after the succeed reboot?
I also checked for dmesg.x files in /var/log or similar files but with no success.
Thank you in advance.

Last edited by puntino; 12-17-2010 at 05:37 PM.
Old 12-17-2010, 06:46 PM   #2
Didier Spaier
LQ Addict
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64- on Lenovo Thinkpad W520
Posts: 9,184

Rep: Reputation: Disabled
Most messages you see in dmesg are permanently stored in /var/log/messages or /var/log/syslog.
Old 12-17-2010, 06:51 PM   #3
Registered: Feb 2006
Posts: 69

Rep: Reputation: 15
If you just want to save current message from dmesg, you can redirect it to a new file from command line
root@localhost ~]# dmesg >/home/your_username/dmesg_logg
Old 12-17-2010, 06:52 PM   #4
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913
In all distros I've ever used dmesg is simply a ring-buffer in the
kernel, and the tool dmesg reads that out. You could conceivably
write a script that runs dmesg lets say every minute, compares
the output to what it stored into a file in a previous run, and
tacks new lines onto the end.

Old 12-17-2010, 07:52 PM   #5
Registered: Aug 2004
Distribution: Slack10 & curr. tried numerous
Posts: 189

Rep: Reputation: 37
I am not a gentoo user. However assuming you get to login after booting then as root
 cat /var/log/dsmeg > /var/log/dmesg.1
should save the current boot process's dmesg file prior to a crash. /var/[debug,messages,syslog][.x] files as these are commonly rotated/archived should capture events after booting and prior to a crash.

However if you never get to login then thats another kettle of fish. I started to advise modifying your startup script at the point where the file system is remounted read/write to use the above code. But what is the point if you can't login to see it. Suspect gentoo has a way to run a 'live' or abbreviated install where you would not proceed with the install rather just mount under /mnt your partitions and then you should be able to read the last dmesg file.

Just a thought. Hope it helps


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
iptable rules some to save and some not to upon reboot how to do tkmsr Linux - Server 4 04-18-2010 11:54 AM
Save bash variables after reboot ALInux Linux - Software 2 06-24-2006 02:51 PM
Save settings on reboot PipeDreams Mandriva 8 03-24-2006 08:41 AM
kaffiene save stream function causes crash ubuntu_fan007 Linux - Software 0 10-22-2005 07:33 AM
alsa settings don't save after a reboot moger Slackware 7 07-19-2004 11:56 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:39 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration