Jump to content

How to use dmesg to collect hardware information

0
  carlaschroder's Photo
Posted Sep 22 2009 09:50 AM

PCI is fine, but it's yesterday's news; you need an inventory of all the devices on the system, not just PCI devices. You're interested in USB devices, SCSI devices, memory configuration, even the CPU.

Use dmesg. dmesg is a record of everything detected by the kernel.

To view all dmesg output, use:

$ dmesg | less

You can also filter the output of dmesg to find specific devices. For example, to list all USB devices, use:

$ dmesg | grep -i usb

To list ISA devices, use:

$ dmesg | grep -i isa

isapnp: Scanning for PnP cards...

isapnp: SB audio device quirk - increasing port range

isapnp: Card 'SupraExpress 56i Voice'

To see how much physical memory is on the system, use:

$ dmesg | grep -i memory

Memory: 256492k/262080k available (1467k kernel code, 5204k reserved, 516k data, 96k init,

 0k highmem)

This shows IDE devices using the SCSI emulation subsystem, which is used on 2.4 and older kernels:

$ dmesg | grep -i scsi

Kernel command line: root=/dev/hda6 ro hdb=scsi hdc=scsi

ide_setup: hdb=scsi

ide_setup: hdc=scsi

SCSI subsystem driver Revision: 1.00

hdb: attached ide-scsi driver.

hdc: attached ide-scsi driver.

scsi0 : SCSI host adapter emulation for IDE ATAPI devices

...

Here are what "real," not emulated, SCSI devices look like:

$ dmesg | grep -i scsi

SCSI subsystem driver Revision: 1.00

scsi0 : Adaptec AIC7XXX EISA/VLB/PCI SCSI HBA DRIVER, Rev 6.2.8

   

   aic7892: Ultra160 Wide Channel A, SCSI Id=7, 32/253 SCBs

...Vendor: IBM-PSG   Model: DPSS-336950M  M   Rev: S9HA

Attached scsi disk sda at scsi0, channel 0, id 0, lun 0

(scsi0:A:0): 160.000MB/s transfers (80.000MHz DT, offset 63, 16bit)

SCSI device sda: 71096640 512-byte hdwr sectors (36401 MB)

Partition check:

 sda: sda1 sda2 sda3 sda4 < sda5 sda6 >

Shown here is information about a USB camera that is connected to the system, including its location in the filesystem. Typically, USB output runs to a dozen lines or more:

$ dmesg | grep -i usb

...

usb.c: registered new driver ibmcam

ibmcam.c: IBM PC Camera USB camera found (model 2, rev. 0x030a)

usbvideo.c: ibmcam on /dev/video0: canvas=352x240 videosize=352x240

To show serial ports, use:

$ dmesg | grep -i tty

ttyS00 at 0x03f8 (irq = 4) is a 16550A

To show CPU or CPUs, use:

$ dmesg | grep -i cpu

Initializing CPU#0

CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)

CPU: L2 Cache: 64K (64 bytes/line)

Intel machine check reporting enabled on CPU#0.

CPU:    After generic, caps: 0183f9ff c1c7f9ff 00000000 00000000

CPU:    Common caps: 0183f9ff c1c7f9ff 00000000 00000000

CPU: AMD Duron™ Processor stepping 01

Note that these searches only return lines containing your search string. There is often more information adjacent to these lines, which you'll find by eyeballing the whole file:

Initializing CPU#0

Detected 801.446 MHz processor.

dmesg always provides up-to-date information, even if you're changing hardware frequently (for example, plugging in and detaching hotplug USB devices).

Cover of Linux Cookbook
Learn more about this topic from Linux Cookbook. 

Linux information can be found scattered in man pages, texinfo files, and source code comments, but the best source is the experts who have built up a working knowledge of managing Linux systems. The Linux Cookbook's tested techniques distill years of hard-won experience into practical cut-and-paste solutions to everyday Linux dilemmas. Use just one recipe from this collection of real-world solutions, and the hours of tedious trial-and-error saved will more than pay for the cost of the book. It's more than a time-saver; it's a sanity saver.

Learn More Read Now on Safari


Tags:
0 Subscribe


0 Replies