lspci: 了解Linux服务器硬件信息

作者: lesca 分类: Tutorials,Ubuntu 发布时间: 2012-06-04 10:20

聪明的系统管理员总会确保所用的驱动程序与芯片组匹配。因此,对于高级系统管理员而言,了解更多硬件细节就显得尤为重要了。Linux中有个命令叫做lspci,大家知道ls表示”list”的意思,因此lspci就是要列出(list)所有PCI设备。

我们先来试一把:

# lspci
00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (rev 01)
00:01.0 PCI bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge (rev 01)
00:07.0 ISA bridge: Intel Corporation 82371AB/EB/MB PIIX4 ISA (rev 08)
00:07.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
00:07.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)
00:07.7 System peripheral: VMware Virtual Machine Communication Interface (rev 10)
00:0f.0 VGA compatible controller: VMware SVGA II Adapter
00:10.0 SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)
00:11.0 PCI bridge: VMware PCI bridge (rev 02)
00:15.0 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.1 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.2 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.3 PCI bridge: VMware PCI Express Root Port (rev 01)
...
02:00.0 USB Controller: VMware Device 0774
02:01.0 Ethernet controller: Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE] (rev 10)
02:02.0 Multimedia audio controller: Ensoniq ES1371 [AudioPCI-97] (rev 02)
02:03.0 USB Controller: VMware USB2 EHCI Controller

上面列出了计算机上所有PCI硬件设备。通过lspci我们可以知道计算机上有多少PCI设备,例如,有多少个Ethernet controller就能表示计算机上有多少个网卡(NCI)。我们还能找到VGA compatible controller是VMware设备,这意味着该服务器是个运行在VMware平台上的虚拟机。

通过lspci -vvv命令,可以获得更详细的设备数据:

# lspci -vvv
00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (rev 01)
        Subsystem: VMware Device 1976
        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
        Status: Cap- 66MHz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 0
        Kernel driver in use: agpgart-intel
        Kernel modules: intel-agp

00:01.0 PCI bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge (rev 01)
        Control: I/O+ Mem+ BusMaster+ SpecCycle+ MemWINV+ VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx-
        Status: Cap- 66MHz+ UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 0
        Bus: primary=00, secondary=01, subordinate=01, sec-latency=64
        I/O behind bridge: 0000f000-00000fff
        Memory behind bridge: fff00000-000fffff
        Prefetchable memory behind bridge: fff00000-000fffff
        Secondary status: 66MHz+ FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- <SERR- <PERR-
        BridgeCtl: Parity- SERR- NoISA+ VGA- MAbort- >Reset- FastB2B+
                PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
        Kernel modules: shpchp
...
02:00.0 USB Controller: VMware Device 0774
        Subsystem: VMware Device 1976
        Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
        Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 64
        Interrupt: pin A routed to IRQ 18
        Region 4: I/O ports at 20c0 [size=32]
        Kernel driver in use: uhci_hcd

02:01.0 Ethernet controller: Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE] (rev 10)
        Subsystem: Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
        Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 64 (1500ns min, 63750ns max)
        Interrupt: pin A routed to IRQ 19
        Region 0: I/O ports at 2000 [size=128]
        [virtual] Expansion ROM at d8400000 [disabled] [size=64K]
        Kernel driver in use: pcnet32
        Kernel modules: pcnet32
...

现在你可以找到一些IRQ和Latency的信息,尽管通常我们并不关心它们,但是当计算机出现硬件问题时我们就需要知道它们。因此我们最好对此有所了解,并让它们和驱动程序匹配。那么该如何判断是否匹配了呢?Linux提供了另外一个ls命令:lsmod。现在我们以检查网卡驱动程序是否正确安装为例进行介绍:

# lsmod
Module                  Size  Used by
...
pcnet32                29402  0
mii                     4381  1 pcnet32
...

我们找到了pcnet32,这和Ethernet controller的lspci输出是一致的。我们可以通过modinfo命令,查看pcnet32模块的详细信息:

# modinfo pcnet32
filename:       /lib/modules/2.6.32-38-generic-pae/kernel/drivers/net/pcnet32.ko
license:        GPL
description:    Driver for PCnet32 and PCnetPCI based ethercards
author:         Thomas Bogendoerfer
srcversion:     E10734EFA65F9BAD2B8082A
alias:          pci:v00001023d00002000sv*sd*bc02sc00i*
alias:          pci:v00001022d00002000sv*sd*bc*sc*i*
alias:          pci:v00001022d00002001sv*sd*bc*sc*i*
depends:        mii
vermagic:       2.6.32-38-generic-pae SMP mod_unload modversions 586TSC
parm:           debug:pcnet32 debug level (int)
parm:           max_interrupt_work:pcnet32 maximum events handled per interrupt (int)
parm:           rx_copybreak:pcnet32 copy breakpoint for copy-only-tiny-frames (int)
parm:           tx_start_pt:pcnet32 transmit start point (0-3) (int)
parm:           pcnet32vlb:pcnet32 Vesa local bus (VLB) support (0/1) (int)
parm:           options:pcnet32 initial option setting(s) (0-15) (array of int)
parm:           full_duplex:pcnet32 full duplex setting(s) (1) (array of int)
parm:           homepna:pcnet32 mode for 79C978 cards (1 for HomePNA, 0 for Ethernet, default Ethernet (array of int)

Reference:

本文译自iSystemAdmin的《lspci: know your linux server hardware》,并由lesca作适当修改。

版权声明

本文出自 Lesca 技术宅,转载时请注明出处及相应链接。

本文永久链接: https://www.lesca.cn/archives/lspci-know-your-linux-server-hardware.html

如果觉得我的文章对您有用,请随意赞赏。您的支持将鼓励我继续创作!