LINFO
http://www.linfo.org/dmesg.html
http://linux.about.com/library/cmd/blcmdl8_dmesg.htm
http://unix.stackexchange.com/questions/35851/whats-the-difference-of-dmesg-output-and-var-log-messages
http://en.wikipedia.org/wiki/Dmesg
During system bootup process, kernel gets loaded into the memory and it controls the entire system.
When the system boots up, it prints number of messages on the screen that displays information about the hardware devices that the kernel detects during boot process.
These messages are available in kernel ring buffer and whenever the new message comes the old message gets overwritten. You could see all those messages after the system bootup using the dmesg command.
The below value is in the power of 2. So, the buffer size in this example would be 262144 bytes. You can modify the buffer size based on your need (SUSE / REDHAT).
klogd service should be enabled and configured properly to log the messages in /var/log/kern.log file.
http://man7.org/linux/man-pages/man1/dmesg.1.html
The dmesg Command
The dmesg command is used to write the kernel messages in Linux and other Unix-like operating systems to standard output (which by default is the display screen). A kernel is the core of an operating system. It is the first part of the operating system that is loaded into memory when a computer boots up (i.e., starts up), and it controls virtually everything on a system. The numerous messages generated by the kernel that appear on the display screen as a computer boots up show the hardware devices that the kernel detects and indicate whether it is able to configure them. dmesg obtains its data by reading the kernel ring buffer. A buffer is a portion of a computer's memory that is set aside as a temporary holding place for data that is being sent to or received from an external device, such as a hard disk drive (HDD), printer or keyboard. A ring buffer is a buffer of fixed size for which any new data added to it overwrites the oldest data in it. dmesg can be very useful when troubleshooting or just trying to obtain information about the hardware on a system. Its basic syntax is Invoking dmesg without any of its options (which are rarely used) causes it to write all the kernel messages to standard output. This usually produces far too many lines to fit into the display screen all at once, and thus only the final messages are visible. However, the output can be redirected to the less command through the use of a pipe (designated by the vertical bar character), thereby allowing the startup messages to be viewed one screenful at a time: less allows the output to be moved forward one screenful at a time by pressing the SPACE bar, backward by pressing the b key and removed by pressing the q key. (The more command could have been used here instead of the less command; however, less is newer than more and has additional functions, including the ability to return to previous pages of the output.) When a user encounters a problem with the system, it can be convenient to write the output of dmesg to a file and then send that file by e-mail to a system administrator or other knowledgeable person for assistance. For example, the output could be redirected to a file named boot_messages using the output redirection operator (designated by a rightward facing angle bracket) as follows: Because of the length of the output of dmesg, it can be convenient to pipe its output to grep, a filter which searches for any lines that contain the string (i.e., sequence of characters) following it. The -i option can be used to tell grep to ignore the case (i.e., lower case or upper case) of the letters in the string. For example, the following command lists all references to USB (universal serial bus) devices in the kernel messages: And the following tells dmesg to show all serial ports (which are represented by the string tty): The dmesg and grep combination can also be used to show how much physical memory (i.e., RAM) is available on the system: The following command checks to confirm that the HDD(s) is running in DMA (direct memory access) mode: The output of dmesg is maintained in the log file /var/log/dmesg, and it can thus also be easily viewed by reading that file with a text editor, such as vi or gedit, or with a command such as cat, e.g.,
Created May 13, 2005. Updated January 12, 2007. |
http://www.linfo.org/dmesg.html
http://linux.about.com/library/cmd/blcmdl8_dmesg.htm
http://unix.stackexchange.com/questions/35851/whats-the-difference-of-dmesg-output-and-var-log-messages
http://en.wikipedia.org/wiki/Dmesg
How to use dmesg to collect hardware information
http://answers.oreilly.com/topic/251-how-to-use-dmesg-to-collect-hardware-information/Troubleshooting Using dmesg Command in Unix and Linux
When the system boots up, it prints number of messages on the screen that displays information about the hardware devices that the kernel detects during boot process.
These messages are available in kernel ring buffer and whenever the new message comes the old message gets overwritten. You could see all those messages after the system bootup using the dmesg command.
1. View the Boot Messages
By executing the dmesg command, you can view the hardwares that are detected during bootup process and it’s configuration details. There are lot of useful information displayed in dmesg. Just browse through them line by line and try to understand what it means. Once you have an idea of the kind of messages it displays, you might find it helpful for troubleshooting, when you encounter an issue.# dmesg | more Bluetooth: L2CAP ver 2.8 eth0: no IPv6 routers present bnx2: eth0 NIC Copper Link is Down usb 1-5.2: USB disconnect, address 5 bnx2: eth0 NIC Copper Link is Up, 100 Mbps full duplexAs we discussed earlier, you can also view hardware information using dmidecode.
2. View Available System Memory
You can also view the available memory from the dmesg messages as shown below.# dmesg | grep Memory Memory: 57703772k/60817408k available (2011k kernel code, 1004928k reserved, 915k data, 208k init)
3. View Ethernet Link Status (UP/DOWN)
In the example below, dmesg indicates that the eth0 link is in active state during the boot itself.# dmesg | grep eth eth0: Broadcom NetXtreme II BCM5709 1000Base-T (C0) PCI Express found at mem 96000000, IRQ 169, node addr e4:1f:13:62:ff:58 eth1: Broadcom NetXtreme II BCM5709 1000Base-T (C0) PCI Express found at mem 98000000, IRQ 114, node addr e4:1f:13:62:ff:5a eth0: Link up
4. Change the dmesg Buffer Size in /boot/config- file
Linux allows to you change the default size of the dmesg buffer. The CONFIG_LOG_BUF_SHIFT parameter in the /boot/config-2.6.18-194.el5 file (or similar file on your system) can be changed to modify the dmesg buffer.The below value is in the power of 2. So, the buffer size in this example would be 262144 bytes. You can modify the buffer size based on your need (SUSE / REDHAT).
# grep CONFIG_LOG_BUF_SHIFT /boot/config-`uname -r` CONFIG_LOG_BUF_SHIFT=18
5. Clear Messages in dmesg Buffer
Sometimes you might want to clear the dmesg messages before your next reboot. You can clear the dmesg buffer as shown below.# dmesg -c # dmesg
6. dmesg timestamp: Date and Time of Each Boot Message in dmesg
By default the dmesg don’t have the timestamp associated with them. However Linux provides a way to see the date and time for each boot messages in dmesg in the /var/log/kern.log file as shown below.klogd service should be enabled and configured properly to log the messages in /var/log/kern.log file.
# dmesg | grep "L2 cache" [ 0.014681] CPU: L2 cache: 2048K # grep "L2 cache" kern.log.1 Oct 18 23:55:40 ubuntu kernel: [ 0.014681] CPU: L2 cache: 2048Khttp://www.thegeekstuff.com/2010/10/dmesg-command-examples/
DMESG(1) User Commands DMESG(1)
dmesg - print or control the kernel ring buffer
SYNOPSIS top
dmesg [options]
dmesg --clear
dmesg --read-clear [options]
dmesg --console-level level
dmesg --console-on
dmesg --console-off
DESCRIPTION top
dmesg is used to examine or control the kernel ring buffer.
The default action is to read all messages from kernel ring buffer.
OPTIONS top
The --clear, --read-clear, --console-on, --console-off and --console-
level options are mutually exclusive.
-C, --clear
Clear the ring buffer.
-c, --read-clear
Clear the ring buffer contents after printing.
-D, --console-off
Disable printing messages to the console.
-d, --show-delta
Display the timestamp and time delta spent between messages.
If used together with --notime then only the time delta
without the timestamp is printed.
-e, --reltime
Display the local time and delta in human readable format.
-E, --console-on
Enable printing messages to the console.
-F, --file file
Read log from file.
-f, --facility list
Restrict output to defined (comma separated) list of
facilities. For example
dmesg --facility=daemon
will print messages from system daemons only. For all
supported facilities see dmesg --help output.
-H, --human
Enable human readable output. See also --color, --reltime and
--nopager.
-h, --help
Print a help text and exit.
-k, --kernel
Print kernel messages.
-L, --color [=when]
Colorize important messages, the optional argumet when is
'auto', 'never' or 'always'. If the when argument is omitted
then the default is 'auto'.
-l, --level list
Restrict output to defined (comma separated) list of levels.
For example
dmesg --level=err,warn
will print error and warning messages only. For all supported
levels see dmesg --help output.
-n, --console-level level
Set the level at which logging of messages is done to the
console. The level is a level number or abbreviation of the
level name. For all supported levels see dmesg --help output.
For example, -n 1 or -n alert prevents all messages, except
emergency (panic) messages, from appearing on the console.
All levels of messages are still written to /proc/kmsg, so
syslogd(8) can still be used to control exactly where kernel
messages appear. When the -n option is used, dmesg will not
print or clear the kernel ring buffer.
-P, --nopager
Do not pipe output into a pager, the pager is enabled for
--human output.
-r, --raw
Print the raw message buffer, i.e., do not strip the log level
prefixes.
Note that the real raw format depends on method how dmesg(1)
reads kernel messages. The /dev/kmsg uses different format
than syslog(2). For backward compatibility dmesg(1) returns
data always in syslog(2) format. The real raw data from
/dev/kmsg is possible to read for example by command 'dd
if=/dev/kmsg iflag=nonblock'.
-S, --syslog
Force to use syslog(2) kernel interface to read kernel
messages. The default is to use /dev/kmsg rather than
syslog(2) since kernel 3.5.0.
-s, --buffer-size size
Use a buffer of size to query the kernel ring buffer. This is
16392 by default. (The default kernel syslog buffer size was
4096 at first, 8192 since 1.3.54, 16384 since 2.1.113.) If
you have set the kernel buffer to be larger than the default
then this option can be used to view the entire buffer.
-T, --ctime
Print human readable timestamps. The timestamp could be
inaccurate!
The time source used for the logs is not updated after system
SUSPEND/RESUME.
-t, --notime
Do not print kernel's timestamps.
-u, --userspace
Print userspace messages.
-V, --version
Output version information and exit.
-w, --follow
Wait for new messages. This feature is supported on systems
with readable /dev/kmsg only (since kernel 3.5.0).
-x, --decode
Decode facility and level (priority) number to human readable
prefixes.
SEE ALSO top
syslogd(8)
AUTHORS top
Karel Zak <kzak@redhat.com>
Theodore Ts'o <tytso@athena.mit.edu>
AVAILABILITY top
The dmesg command is part of the util-linux package and is available
from Linux Kernel Archive <ftp://ftp.kernel.org/pub/linux/utils/util-
linux/>.
COLOPHON top
This page is part of the util-linux (a random collection of Linux
utilities) project. Information about the project can be found at
[unknown--email man-pages@man7.org if you know]. It is not known how
to report bugs for this man page; if you know, please send a mail to
man-pages@man7.org. This page was obtained from the project's
upstream Git repository
(git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git) on
2013-05-17. If you discover any rendering problems in this HTML ver-
sion of the page, or you believe there is a better or more up-to-date
source for the page, or you have corrections or improvements to the
information in this COLOPHON (which is <em>not</em> part of the orig-
inal manual page), send a mail to man-pages@man7.org
util-linux July 2012 DMESG(1)
http://man7.org/linux/man-pages/man1/dmesg.1.html