Sunteți pe pagina 1din 5

Linux Hardware Diagnosis Commands

rev 1.0

Detecting hardware with lspci

To show a summary of all devices connected to the PCI bus, use:

# lscpi
or
# /sbin/lspci

# lspci v

# lspci -vv

$ lspci
pcilib: Resource 5 in /sys/bus/pci/devices/0000:00:1f.1/resource has a 64-bit address, ignoring
00:00.0 Host bridge: Intel Corporation E8500 Hub Interface 1.5 (rev 10)
00:01.0 PCI bridge: Intel Corporation E8500 PCI Express x4 Port D (rev 10)
00:02.0 PCI bridge: Intel Corporation E8500 PCI Express x4 Port C0 (rev 10)
00:03.0 PCI bridge: Intel Corporation E8500 PCI Express x4 Port C1 (rev 10)
00:04.0 PCI bridge: Intel Corporation E8500 PCI Express x4 Port B0 (rev 10)
00:05.0 PCI bridge: Intel Corporation E8500 PCI Express x4 Port B1 (rev 10)...

Use the -v or -vv flags to display more information:

# lspci -v
02:00.0 PCI bridge: Intel Corporation 6700PXH PCI Express-to-PCI Bridge A (rev 09) (prog-if 00
[Normal decode])
Flags: bus master, fast devsel, latency 0
Bus: primary=02, secondary=03, subordinate=06, sec-latency=64
Memory behind bridge: fd300000-fd3fffff
Capabilities: [44] Express PCI/PCI-X Bridge IRQ 0
Capabilities: [5c] Message Signalled Interrupts: 64bit+ Queue=0/0 Enable-
Capabilities: [6c] Power Management version 2
Capabilities: [d8] PCI-X bridge device.
Capabilities: [100] Advanced Error Reporting
Capabilities: [300] Power Budgeting

lspcireads some information from the PCI bus, then displays additional
information from its own database of hardware IDs -- vendors, devices, classes
and subclasses -- at /usr/share/misc/pci.ids.

Command to update this file:

# update-pciids

Using dmesg to collect hardware information

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)

$ 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 >

$ 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.

dmesg always provides up-to-date information, even if you're changing hardware


frequently (for example, plugging in and detaching hotplug USB devices).

Getting live hardware snapshots with /proc

You want to monitor a running system in real time, and view things like physical
memory and CPU information, or identify drives.

Solution: Read the /proc virtual filesystem. Use only cat to read /proc, or utilities
designed expressly for it, such as sysctl, lspci, ps, and top. The syntax is the same
as for reading any file:

$ cat /proc/filename

You can explore /proc just like any filesystem and easily find the information you
want. Look to the named folders for hardware information:

$ ls /proc
bus cmdline cpuinfo devices dma driver filesystems ide kcore kmsg ksyms loadavg
meminfo misc modules mounts mtrr partitions pci scsi swaps sys tty

For example, to show CPU information, use:

$ cat /proc/cpuinfo
processor :0
vendor_id : GenuineIntel
cpu family : 15
model :4
model name : Intel(R) Xeon(TM) MP CPU 3.66GHz
stepping :9
cpu MHz : 2333.450
cache size : 1024 KB
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush
dts acpi mmx fxsr sse sse2 ss ht tm syscall lm pni monitor ds_cpl est tm2 cid cx16 xtpr ts
bogomips : 7225.34
clflush size : 64
cache_alignment : 128
address sizes : 40 bits physical, 48 bits virtual
power management:
...

To show physical memory and swap usage, use:

$ cat /proc/meminfo
MemTotal: 16417964 kB
MemFree: 11121728 kB
Buffers: 209176 kB
Cached: 4172608 kB
SwapCached: 0 kB
Active: 2275904 kB
Inactive: 2843592 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 16417964 kB
LowFree: 11121728 kB
SwapTotal: 1020116 kB
SwapFree: 1020116 kB

...

To see info about anIDE device, use:


$ cat /proc/ide/ide0/hda/model
DV-28E-N
$ cat /proc/ide/ide0/hda/media
cdrom

To see disk geometry, both real and logical, use:

$ cat /proc/ide/ide0/hda/geometry
physical 39870/16/63
logical 2501/255/63

To show driver versions for all IDE drivers, use:


$ cat /proc/ide/drivers
ide-floppy version 0.99.newide
ide-cdrom version 4.61
ide-disk version 1.18

To show capabilities of CD drives, use:


$ cat /proc/sys/dev/cdrom/info
CD-ROM information, Id: cdrom.c 3.20 2003/12/17
drive name: had
drive speed: 24
drive # of slots: 1
Can close tray: 1
Can open tray: 1
Can lock tray: 1
Can change speed: 1
Can select disk: 0

To show SCSI devices, using the following command. Note that it does not
differentiate between devices attached to the SCSI bus and IDE devices using
the SCSI-emulation subsystem. These are IDE CD drives:

$ cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 03 Lun: 00
Vendor: HP Model: Ultrium 2-SCSI Rev: S53D
Type: Sequential-Access ANSI SCSI revision: 03

As mentioned earlier, to read /proc use only cat or utilities designed expressly for
it, such as sysctl, lspci, ps, and top. Pagers like less and more give a different picture,
because they re-read /proc with each page. And you don't want to use a text
editor, or any utility with write powers, because you can mess up a system in a
heartbeat.

S-ar putea să vă placă și