linux怎么看是pcie
linux怎么看是pcie详细介绍
在 Linux 系统中,可以通过以下命令和方法查看 PCIe(PCI Express)相关信息,包括设备是否通过 PCIe 连接、PCIe 版本、速率及通道数等。
1. 使用 lspci 命令(最常用)
lspci 是 Linux 下专门用于查看 PCI/PCIe 设备信息的工具,可显示设备的详细属性。
基础用法
bash
lspci
输出示例:
plaintext
00:00:00.0 Host bridge: Intel Corporation 8th Gen Core Processor Host Bridge/DRAM Registers (rev 07)00:01:00.0 PCI bridge: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (x16) (rev 07)
01:00:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1070] (rev a1)
...
- 每行开头的
00:01:00.0是设备的 PCI 地址(总线:设备:功能号)。 - 若设备类型包含
PCI bridge(PCI 桥)或PCIe关键词,则说明是 PCIe 设备。
查看详细信息(含 PCIe 速率和通道数)
bash
lspci
输出示例(部分关键信息):
plaintext
01:00:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1070] (rev a1)Subsystem: ASUSTeK Computer Inc. GP104 [GeForce GTX 1070]
Flags: bus master, fast devsel, latency 0, IRQ 161
Memory at de000000 (32-bit, non-prefetchable) [size=16M]
Memory at c0000000 (64-bit, prefetchable) [size=256M]
Memory at d0000000 (64-bit, prefetchable) [size=32M]
I/O ports at e000 [size=128]
Expansion ROM at df000000 [virtual] [size=512K]
Capabilities: <access denied>
Kernel driver in use: nvidia
Kernel modules: nvidiafb, nouveau, nvidia_drm, nvidia
- 若设备支持 PCIe,在
Capabilities字段中会显示PCI Express相关信息(需以lspci -vv显示完整权限)。
查看 PCIe 拓扑结构
bash
lspci
输出示例:
plaintext
-+- bridge [0604] 00:01.0| `- pci0000:01
| +- display [0300] 01:00.0
| `- display [0300] 01:00.1
...
- 树状结构中的
bridge(桥)通常代表 PCIe 控制器,用于连接其他 PCIe 设备。
2. 查看 /sys 文件系统(底层信息)
Linux 的 /sys/bus/pci/devices 目录存储了 PCIe 设备的底层信息,可直接读取文件获取细节。
查看 PCIe 速率和通道数
以具体设备的 PCI 地址(如 0000:01:00.0)为例:
bash
/sys/bus/pci/devices/0000:01:00.0
speed
width
查看 PCIe 版本
bash
lspci 01:00.0
输出示例:
plaintext
LnkSta: Speed 16GT/s (ok), Width x16 (ok)
Speed 16GT/s表示 PCIe 3.0(16GT/s);Speed 8GT/s为 PCIe 2.0;Speed 5GT/s为 PCIe 2.0 或 1.1。
3. 使用 lshw 命令(硬件信息汇总)
lshw(Linux System Hardware)可显示更全面的硬件信息,包括 PCIe 总线和设备。
bash
lshw bus
输出示例(部分):
plaintext
*-pci:0description: PCI bridge
product: Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (x16)
vendor: Intel Corporation
physical id: 1
bus info: pci@0000:00:01.0
version: 07
width: 32 bits
clock: 33MHz
capabilities: pci pciexpress msi pm normal_decode bus_master cap_list
configuration: driver=pcieport
...
9912345678910111213*-pci:0 description: PCI bridge product: Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (x16) vendor: Intel Corporation physical id: 1 bus info: pci@0000:00:01.0 version: 07 width: 32 bits clock: 33MHz capabilities: pci pciexpress msi pm normal_decode bus_master cap_list configuration: driver=pcieport...
总结
- 最常用的工具是
lspci,通过-v或-t选项可快速定位 PCIe 设备及拓扑。 - 若需底层细节(如速率、通道数),可直接查看
/sys/bus/pci/devices下的文件。 - 对于更全面的硬件信息,可用
lshw命令辅助分析。