2016年2月9日 星期二

Linux用lshw和ls*看硬體資訊

除了上一篇提到用dmesg與dmidecode看硬體資訊,後來又出現了ls系列的指令
  • lshw:列出硬體資訊
  • lshw-gtk:視窗介面列出硬體資訊
  • lsusb:列出所有USB設備
  • lscpu:列出處理器相關資訊
  • lspci:列出所有PCI設備
使用時直接用輸入指令就可以了,比起dmesg與dmidecode要容易使用,不過dmesg上面可以看到錯誤訊息,而ls系列的沒有辦法看到。這邊我們還是用2009年中13吋的MacBookPro,上面運行了Ubuntu 14.04來做測試


lshw – list hardware

# lshw -short
H/W path      Device      Class       Description
=================================================
                          system      MacBookPro5,5 (System SKU#)
/0                        bus         Mac-F2268AC8
/0/0                      processor   Intel(R) Core(TM)2 Duo CPU     P8700  @ 2.
/0/0/2                    memory      32KiB L1 cache
/0/1                      memory      32KiB L1 cache
/0/3                      processor   CPU
/0/3/5                    memory      32KiB L1 cache
/0/4                      memory      32KiB L1 cache
/0/6                      memory      8GiB System Memory
/0/6/0                    memory      4GiB SODIMM DDR3 Synchronous 1333 MHz (0.8
/0/6/1                    memory      4GiB SODIMM DDR3 Synchronous 1333 MHz (0.8
/0/e                      memory      1MiB BIOS
/0/100                    bridge      MCP79 Host Bridge
/0/100/0.1                memory      RAM memory
/0/100/3                  bridge      MCP79 LPC Bridge
/0/100/3.1                memory      RAM memory
/0/100/3.2                bus         MCP79 SMBus
/0/100/3.3                memory      RAM memory
/0/100/3.4                memory      RAM memory
/0/100/3.5                processor   MCP79 Co-processor
/0/100/4                  bus         MCP79 OHCI USB 1.1 Controller
/0/100/4.1                bus         MCP79 EHCI USB 2.0 Controller
/0/100/6                  bus         MCP79 OHCI USB 1.1 Controller
/0/100/6.1                bus         MCP79 EHCI USB 2.0 Controller
/0/100/8                  multimedia  MCP79 High Definition Audio
/0/100/9                  bridge      MCP79 PCI Bridge
/0/100/a      eth0        network     MCP79 Ethernet
/0/100/b                  storage     MCP79 SATA Controller
/0/100/10                 bridge      MCP79 PCI Express Bridge
/0/100/10/0               display     C79 [GeForce 9400M]
/0/100/15                 bridge      MCP79 PCI Express Bridge
/0/100/15/0               network     BCM4322 802.11a/b/g/n Wireless LAN Control
/0/100/16                 bridge      MCP79 PCI Express Bridge
/0/100/16/0               bus         FW643 [TrueFire] PCIe 1394b Controller
/0/2          scsi0       storage     
/0/2/0.0.0    /dev/sda    disk        256GB PLEXTOR PX-256M5
/0/2/0.0.0/1              volume      2047KiB EFI GPT partition
/0/2/0.0.0/2  /dev/sda2   volume      230GiB EXT4 volume
/0/2/0.0.0/3  /dev/sda3   volume      7910MiB Linux swap volume
/0/5          scsi1       storage     
/0/5/0.0.0    /dev/cdrom  disk        DVD-R   UJ-868
/0/7          scsi6       storage     
/0/7/0.0.0    /dev/sdb    disk        SD Card Reader
/0/7/0.0.0/0  /dev/sdb    disk        
/1                        power       Unknown
/2            wlan0       network     Wireless interface

# lshw -C class
class從上面的lshw -short或是lshw -businfo可以知道有:

  • bridge:主機板上面PCI, ISA 插槽的資訊
  • bus:主機板、USB, firewire等外接裝置
  • disk:硬碟、光碟機、讀卡機
  • memory:記憶體相關資訊
  • network:有線網卡、無線網卡、IP與MAC位址
  • power:電源供應器、電池相關訊息
  • processor:CPU與GPU的資訊
  • storage:連接儲存裝置的設備像是SATA, SCSI等等
  • system:機器的基本資訊
  • volume:磁碟上面各個空間的詳細資訊,像是filesystem format, UUID等等

如果想要把相關資料輸出成為json格式,可以用下面的指令
# lshw -json
# lshw -C processor -json




lsusb – list USB devices

$ lsusb
Bus 002 Device 004: ID 05ac:8403 Apple, Inc. Internal Memory Card Reader
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 003: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 004 Device 004: ID 05ac:8213 Apple, Inc. Bluetooth Host Controller
Bus 004 Device 002: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth)
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 05ac:8507 Apple, Inc. Built-in iSight
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 003: ID 05ac:0236 Apple, Inc. Internal Keyboard/Trackpad (ANSI)
Bus 003 Device 002: ID 05ac:8242 Apple, Inc. Built-in IR Receiver
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
可以看到Keyboard, Trackpad, IR receiver, Memory card reader等東西都放在USB上面




lscpu – display information on CPU architecture

$ lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                2
On-line CPU(s) list:   0,1
Thread(s) per core:    1
Core(s) per socket:    2
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 23
Stepping:              10
CPU MHz:               798.000
BogoMIPS:              5041.23
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              3072K
NUMA node0 CPU(s):     0,1
雙核心,family 6, model 23, stepping 10, 目前處理器速度是798 MHz



lspci – list all PCI devices

$ lspci
00:00.0 Host bridge: NVIDIA Corporation MCP79 Host Bridge (rev b1)
00:00.1 RAM memory: NVIDIA Corporation MCP79 Memory Controller (rev b1)
00:03.0 ISA bridge: NVIDIA Corporation MCP79 LPC Bridge (rev b3)
00:03.1 RAM memory: NVIDIA Corporation MCP79 Memory Controller (rev b1)
00:03.2 SMBus: NVIDIA Corporation MCP79 SMBus (rev b1)
00:03.3 RAM memory: NVIDIA Corporation MCP79 Memory Controller (rev b1)
00:03.4 RAM memory: NVIDIA Corporation MCP79 Memory Controller (rev b1)
00:03.5 Co-processor: NVIDIA Corporation MCP79 Co-processor (rev b1)
00:04.0 USB controller: NVIDIA Corporation MCP79 OHCI USB 1.1 Controller (rev b1)
00:04.1 USB controller: NVIDIA Corporation MCP79 EHCI USB 2.0 Controller (rev b1)
00:06.0 USB controller: NVIDIA Corporation MCP79 OHCI USB 1.1 Controller (rev b1)
00:06.1 USB controller: NVIDIA Corporation MCP79 EHCI USB 2.0 Controller (rev b1)
00:08.0 Audio device: NVIDIA Corporation MCP79 High Definition Audio (rev b1)
00:09.0 PCI bridge: NVIDIA Corporation MCP79 PCI Bridge (rev b1)
00:0a.0 Ethernet controller: NVIDIA Corporation MCP79 Ethernet (rev b1)
00:0b.0 IDE interface: NVIDIA Corporation MCP79 SATA Controller (rev b1)
00:10.0 PCI bridge: NVIDIA Corporation MCP79 PCI Express Bridge (rev b1)
00:15.0 PCI bridge: NVIDIA Corporation MCP79 PCI Express Bridge (rev b1)
00:16.0 PCI bridge: NVIDIA Corporation MCP79 PCI Express Bridge (rev b1)
02:00.0 VGA compatible controller: NVIDIA Corporation C79 [GeForce 9400M] (rev b1)
03:00.0 Network controller: Broadcom Corporation BCM4322 802.11a/b/g/n Wireless LAN Controller (rev 01)
04:00.0 FireWire (IEEE 1394): LSI Corporation FW643 [TrueFire] PCIe 1394b Controller (rev 07)

前面的數字,像是Broadcom的網卡編號就是03:00.0,可以用下面指令單獨看
$ lspci -v -s 03:00.0
03:00.0 Network controller: Broadcom Corporation BCM4322 802.11a/b/g/n Wireless LAN Controller (rev 01)
Subsystem: Apple Inc. AirPort Extreme
Flags: bus master, fast devsel, latency 0, IRQ 19
Memory at d3200000 (64-bit, non-prefetchable) [size=16K]
Capabilities: <access denied>
Kernel driver in use: b43-pci-bridge

如果想要看更精細的資料,可以把參數-v改成-vv或是-vvv
$ lspci -vv -s 03:00.0
03:00.0 Network controller: Broadcom Corporation BCM4322 802.11a/b/g/n Wireless LAN Controller (rev 01)
Subsystem: Apple Inc. AirPort Extreme
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 256 bytes
Interrupt: pin A routed to IRQ 19
Region 0: Memory at d3200000 (64-bit, non-prefetchable) [size=16K]
Capabilities: <access denied>
Kernel driver in use: b43-pci-bridge

沒有留言:

張貼留言