Previous Section  < Day Day Up >  Next Section

Recipe 5.3. Using dmesg to Collect Hardware Information

5.3.1 Problem

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.

5.3.2 Solution

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

   <Adaptec aic7892 Ultra160 SCSI adapter>

   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(tm) 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.

5.3.3 Discussion

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

5.3.4 See Also

  • dmesg(8)

    Previous Section  < Day Day Up >  Next Section