dmesg
print or control the kernel ring buffer
Synopsis
dmesg
[options]
dmesg
--clear
dmesg
--read-clear [options]
dmesg
--console-level level
dmesg
--console-on
dmesg
--console-off
add an example, a script, a trick and tips
examples
source
adb shell "dmesg >
/data/dmesg.txt"
adb pull /data/dmesg.txt ./dmesg.txt
source
dmesg |grep wlan0| tail -n 1
source
No mounting a USB pendrive on Debian wheezy
A normal output should also include something like:
[26789.560701] Initializing USB Mass Storage driver...
[26789.560878] scsi6 : SCSI emulation for USB Mass Storage devices
[26789.561162] usb-storage: device found at 3
[26789.561164] usb-storage: waiting for device to settle before scanning
[26789.561171] usbcore: registered new interface driver usb-storage
[26789.561174] USB Mass Storage support registered.
[26794.561205] usb-storage: device scan complete
[26794.561792] scsi 6:0:0:0: Direct-Access Ut165 USB2FlashStorage 0.00 PQ: 0 ANSI: 2
[26794.562205] sd 6:0:0:0: Attached scsi generic sg3 type 0
[26794.562912] sd 6:0:0:0: [sdc] 3948544 512-byte logical blocks: (2.02 GB/1.88 GiB)
[26794.563404] sd 6:0:0:0: [sdc] Write Protect is off
[26794.563407] sd 6:0:0:0: [sdc] Mode Sense: 00 00 00 00
[26794.563409] sd 6:0:0:0: [sdc] Assuming drive cache: write through
[26794.566665] sd 6:0:0:0: [sdc] Assuming drive cache: write through
[26794.566669] sdc: sdc1
[26794.690926] sd 6:0:0:0: [sdc] Assuming drive cache: write through
[26794.690930] sd 6:0:0:0: [sdc] Attached SCSI removable disk
[26795.736708] ISO 9660 Extensions: Microsoft Joliet Level 3
[26795.759838] ISO 9660 Extensions: RRIP_1991A
This happens if the usb_storage
is not loaded, you
can check it out with:
lsmod | grep -i usb_storage
if it shows no output then it means that the module is not
loaded; load it with:
sudo modprobe usb_storage
If everything then works you can make things persistent with:
sudo sh -c 'echo usb_storage >> /etc/modules'
But I don't know why such things happen.
source
Why will dmesg have message from user space?
A root process can write to /dev/kmsg
. This is used
for logging that occurs very early, before regular logging
systems are ready to do any logging.
source
How to force a USB disk to format?
It looks like reading from the NVRAM chip in the flash drive has
failed, or the controller on the flash drive failed. Time to buy
a new drive.
description
dmesg is
used to examine or control the kernel ring buffer.
The default
action is to read all messages from kernel ring buffer.
options
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,
--console-on
Enable printing messages to the
console.
-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,
--help
Print a help text and exit.
-k,
--kernel
Print kernel messages.
-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.
-r,
--raw
Print the raw message buffer,
i.e., don’t strip the log level prefixes.
-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
Don’t print
kernel’s timestampts.
-u,
--userspace
Print userspace messages.
-V,
--version
Output version information and
exit.
-x,
--decode
Decode facility and level
(priority) number to human readable prefixes.
availability
The dmesg command is part of the util-linux package and is
available from ftp://ftp.kernel.org/pub/linux/utils/util-linux/.
see also
syslogd
authors
Karel Zak
<kzak[:at:]redhat[:dot:]com>
Theodore Ts’o <tytso[:at:]athena.mit[:dot:]edu>