lspci
lspci
显示Linux系统的pci设备最简单的方法就是使用lspci
命令,前提是要安装pciutils
包(centos在最小化安装时不会自带该包,需要自己下载安装)
pciutils
包的源码github地址为: https://github.com/pciutils/pciutils
从该项目的README文件可以知道,其主要提供三个命令:lspci
、setpci
和update-pciids
。
- lspci: displays detailed information about all PCI buses and devices. - setpci: allows to read from and write to PCI device configuration registers. For example, you can adjust the latency timers with it. CAUTION: There is a couple of dangerous points and caveats, please read the manual page first! - update-pciids: download the current version of the pci.ids file.
update-pciids
命令会从网上更新pci.ids
文件,该文件包含着pci设备的vendor id和device id 与厂商名称、型号名称的对应关系,一旦更改该文件那么lspci
show出来的东西就会发生变化。
不同Linux发行版本的pci.ids
文件的位置有所不同,比如centos一般在/usr/share/hwdata/pci.ids
,而Debian一般在/usr/share/misc/pci.ids
,lspci
命令的路径一般在centos下的/usr/sbin/lspci
,而在Debian下一般为/use/bin/lspci
,update-pciids
一般在/usr/sbin/update-pciids
,这些路径如果是手动编译安装pciutils
则可以自行定制,关于如何编译安装可参考pciutils-3.6.2。
同样,不同发行版本的pciutils
也有差异,比如centos的update-pciids
和Debian的 update-pciids
是有区别的,最重要的区别在于其pci.ids
更新的源不同
在Debian中:
#!/bin/sh #URL="http://pci-ids.ucw.cz/pci.ids" URL="http://pciids.sourceforge.net/v2.2/pci.ids" FILE=/usr/share/misc/pci.ids
在centos中:
#!/bin/sh [ "$1" = "-q" ] && quiet=true || quiet=false set -e SRC="http://pci-ids.ucw.cz/v2.2/pci.ids" DEST=/usr/share/hwdata/pci.ids
在Linux的源码中也有一个名为
include/linux/pci_ids.h
的头文件,该文件的内容定义了各个pci设备vendor_id和device_id.同样在qemu中也存在这么一个头文件,里面也是定义了各个pci设备vendor_id和device_id.
Reference
Is there any substitute for lspci
?
How to Display Hardware Info in Linux
In Linux, is there a way to find out which PCI card is plugged into which PCI slot?
7 Linux lspci Command Examples to Get PCI Bus Hardware Device Info
How to Update pci.ids PCI ID Device File using update-pciids on Linux
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix