参考:https://blog.csdn.net/carefree2005/article/details/112446558

一、dmidecode命令简介

  • dmidecode命令可以让你在Linux系统下获取有关硬件方面的信息。dmidecode的作用是将DMI数据库中的信息解码,以可读的文本方式显示。由于DMI信息可以人为修改,因此里面的信息不一定是系统准确的信息。dmidecode遵循SMBIOS/DMI标准,其输出的信息包括BIOS、系统、主板、处理器、内存、缓存等等。
  • DMI(Desktop Management Interface,DMI)就是帮助收集电脑系统信息的管理系统,DMI信息的收集必须在严格遵照SMBIOS规范的前提下进行。SMBIOS(System Management BIOS)是主板或系统制造者以标准格式显示产品管理信息所需遵循的统一规范。SMBIOS和DMI是由行业指导机构Desktop Management Task Force(DMTF)起草的开放性的技术标准,其中DMI设计适用于任何的平台和操作系统
  • DMI充当了管理工具和系统层之间接口的角色。它建立了标准的可管理系统更加方便了电脑厂商和用户对系统的了解。DMI的主要组成部分是Management Information Format(MIF)数据库。这个数据库包括了所有有关电脑系统和配件的信息。通过DMI,用户可以获取序列号、电脑厂商、串口信息以及其它系统配件信息。

二、命令语法及参数选项说明

1、语法

$ dmidecode [OPTIONS]

命令:

dmidecode --help

输出:

Usage: dmidecode [OPTIONS]
Options are:
 -d, --dev-mem FILE     Read memory from device FILE (default: /dev/mem)
 -h, --help             Display this help text and exit
 -q, --quiet            Less verbose output
 -s, --string KEYWORD   Only display the value of the given DMI string
 -t, --type TYPE        Only display the entries of given type
 -H, --handle HANDLE    Only display the entry of given handle
 -u, --dump             Do not decode the entries
     --dump-bin FILE    Dump the DMI data to a binary file
     --from-dump FILE   Read the DMI data from a binary file
     --no-sysfs         Do not attempt to read DMI data from sysfs files
     --oem-string N     Only display the value of the given OEM string
 -V, --version          Display the version and exit

2、参数选项说明

-d:(default:/dev/mem)从设备文件读取信息,输出内容与不加参数标准输出相同。
-h:显示帮助信息。
-q:概要输出
-s:只显示指定DMI字符串的信息。(string)
-t:只显示指定条目的信息。(type)
-H:仅显示给定句柄的条目
-u:显示未解码的原始条目内容。 –dump-bin file:将DMI数据转储到一个二进制文件中。 –from-dump FILE:从一个二进制文件读取DMI数据。 –no sysfs:不尝试从sysfs文件读取DMI数据 –oem-string
N:仅显示给定oem字符串的值
-V:显示版本信息。

三、使用示例

1、查看主板信息

命令:

dmidecode -t 2

输出:

# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 3.3.0 present.
# SMBIOS implementations newer than version 3.2.0 are not
# fully supported by this version of dmidecode.

Handle 0x0002, DMI type 2, 15 bytes
Base Board Information
        Manufacturer: H3C               #厂号
        Product Name: TC1-TRMB-A        #产品型号
        Version: MBD3N43200D00001       #版本
        Serial Number: MBDHC2231711201A #主板序列
        Asset Tag: Not Specified
        Features:
                Board is a hosting board
                Board is replaceable
        Location In Chassis: Part Component
        Chassis Handle: 0x0003
        Type: Motherboard
        Contained Object Handles: 0

2、查看内存信息

可以看到内存条的数量为32条,支持的最大内存为12TB。

命令:

dmidecode -t 16

输出:

# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 3.3.0 present.
# SMBIOS implementations newer than version 3.2.0 are not
# fully supported by this version of dmidecode.

Handle 0x0054, DMI type 16, 23 bytes
Physical Memory Array
        Location: System Board Or Motherboard
        Use: System Memory
        Error Correction Type: Single-bit ECC
        Maximum Capacity: 12 TB
        Error Information Handle: Not Provided
        Number Of Devices: 32

3、查看当前内存数、大小和插槽数

输出结果可以看到,这里只显示插了一半的32GB的内存条。一共32内存插条。(服务器)
命令:

dmidecode|grep -P -A5 "Memory Device" |grep Size

输出:

        Size: 32 GB
        Size: No Module Installed
        Size: 32 GB
        Size: No Module Installed
        Size: 32 GB
        Size: No Module Installed
        Size: 32 GB
        Size: No Module Installed
        Size: 32 GB
        Size: No Module Installed
        Size: 32 GB
        Size: No Module Installed
        Size: 32 GB
        Size: No Module Installed
        Size: 32 GB
        Size: No Module Installed
        Size: 32 GB
        Size: No Module Installed
        Size: 32 GB
        Size: No Module Installed
        Size: 32 GB
        Size: No Module Installed
        Size: 32 GB
        Size: No Module Installed
        Size: 32 GB
        Size: No Module Installed
        Size: 32 GB
        Size: No Module Installed
        Size: 32 GB
        Size: No Module Installed
        Size: 32 GB
        Size: No Module Installed

4、查看详细信息

输出结果可以看到两个插槽一组,只有其中一个插了内存条的插槽可以读取到信息。
命令:

dmidecode -t 17

输出:

# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 3.3.0 present.
# SMBIOS implementations newer than version 3.2.0 are not
# fully supported by this version of dmidecode.

Handle 0x0055, DMI type 17, 92 bytes
Memory Device
        Array Handle: 0x0054
        Error Information Handle: Not Provided
        Total Width: 72 bits
        Data Width: 64 bits
        Size: 32 GB
        Form Factor: DIMM
        Set: None
        Locator: DIMM000
        Bank Locator: NODE 0
        Type: DDR4
        Type Detail: Synchronous Registered (Buffered)
        Speed: 3200 MT/s
        Manufacturer: Micron
        Serial Number: S802C0F2139317D513E
        Asset Tag: 0F2139
        Part Number: 18ASF4G72PDZ-3G2E1
        Rank: 2
        Configured Memory Speed: 3200 MT/s
        Minimum Voltage: 1.2 V
        Maximum Voltage: 1.2 V
        Configured Voltage: 1.2 V
        Memory Technology: DRAM
        Memory Operating Mode Capability: Volatile memory
        Firmware Version: 0000
        Module Manufacturer ID: Bank 1, Hex 0x2C
        Module Product ID: Unknown
        Memory Subsystem Controller Manufacturer ID: Unknown
        Memory Subsystem Controller Product ID: Unknown
        Non-Volatile Size: None
        Volatile Size: 32 GB
        Cache Size: None
        Logical Size: None

Handle 0x0056, DMI type 17, 92 bytes
Memory Device
        Array Handle: 0x0054
        Error Information Handle: Not Provided
        Total Width: Unknown
        Data Width: Unknown
        Size: No Module Installed
        Form Factor: DIMM
        Set: None
        Locator: DIMM001
        Bank Locator: NODE 0
        Type: Unknown
        Type Detail: Unknown
        Speed: Unknown
        Manufacturer: NO DIMM
        Serial Number: NO DIMM
        Asset Tag: NO DIMM
        Part Number: NO DIMM
        Rank: Unknown
        Configured Memory Speed: Unknown
        Minimum Voltage: Unknown
        Maximum Voltage: Unknown
        Configured Voltage: Unknown
        Memory Technology: Unknown
        Memory Operating Mode Capability: None
        Firmware Version: NO DIMM
        Module Manufacturer ID: Unknown
        Module Product ID: Unknown
        Memory Subsystem Controller Manufacturer ID: Unknown
        Memory Subsystem Controller Product ID: Unknown
        Non-Volatile Size: None
        Volatile Size: None
        Cache Size: None
        Logical Size: None
        
        ...
        ...
        ...
        

5、查看CPU信息

命令:

dmidecode -t 4

输出:

# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 3.3.0 present.
# SMBIOS implementations newer than version 3.2.0 are not
# fully supported by this version of dmidecode.

Handle 0x008A, DMI type 4, 48 bytes
Processor Information
        Socket Designation: CPU0
        Type: Central Processor
        Family: Xeon
        Manufacturer: Intel(R) Corporation
        ID: A6 06 06 00 FF FB EB BF
        Signature: Type 0, Family 6, Model 106, Stepping 6
        Flags:
                FPU (Floating-point unit on-chip)
                VME (Virtual mode extension)
                DE (Debugging extension)
                PSE (Page size extension)
                TSC (Time stamp counter)
                MSR (Model specific registers)
                PAE (Physical address extension)
                MCE (Machine check exception)
                CX8 (CMPXCHG8 instruction supported)
                APIC (On-chip APIC hardware supported)
                SEP (Fast system call)
                MTRR (Memory type range registers)
                PGE (Page global enable)
                MCA (Machine check architecture)
                CMOV (Conditional move instruction supported)
                PAT (Page attribute table)
                PSE-36 (36-bit page size extension)
                CLFSH (CLFLUSH instruction supported)
                DS (Debug store)
                ACPI (ACPI supported)
                MMX (MMX technology supported)
                FXSR (FXSAVE and FXSTOR instructions supported)
                SSE (Streaming SIMD extensions)
                SSE2 (Streaming SIMD extensions 2)
                SS (Self-snoop)
                HTT (Multi-threading)
                TM (Thermal monitor supported)
                PBE (Pending break enabled)
        Version: Intel(R) Xeon(R) Platinum 8372C CPU @ 3.20GHz
        Voltage: 1.6 V
        External Clock: 100 MHz
        Max Speed: 3500 MHz
        Current Speed: 3200 MHz
        Status: Populated, Enabled
        Upgrade: <OUT OF SPEC>
        L1 Cache Handle: 0x0087
        L2 Cache Handle: 0x0088
        L3 Cache Handle: 0x0089
        Serial Number: 49076C02C93610EF
        Asset Tag: UNKNOWN
        Part Number: Not Specified
        Core Count: 28
        Core Enabled: 28
        Thread Count: 56
        Characteristics:
                64-bit capable
                Multi-Core
                Hardware Thread
                Execute Protection
                Enhanced Virtualization
                Power/Performance Control

Handle 0x008E, DMI type 4, 48 bytes
Processor Information
        Socket Designation: CPU1
        Type: Central Processor
        Family: Xeon
        Manufacturer: Intel(R) Corporation
        ID: A6 06 06 00 FF FB EB BF
        Signature: Type 0, Family 6, Model 106, Stepping 6
        Flags:
                FPU (Floating-point unit on-chip)
                VME (Virtual mode extension)
                DE (Debugging extension)
                PSE (Page size extension)
                TSC (Time stamp counter)
                MSR (Model specific registers)
                PAE (Physical address extension)
                MCE (Machine check exception)
                CX8 (CMPXCHG8 instruction supported)
                APIC (On-chip APIC hardware supported)
                SEP (Fast system call)
                MTRR (Memory type range registers)
                PGE (Page global enable)
                MCA (Machine check architecture)
                CMOV (Conditional move instruction supported)
                PAT (Page attribute table)
                PSE-36 (36-bit page size extension)
                CLFSH (CLFLUSH instruction supported)
                DS (Debug store)
                ACPI (ACPI supported)
                MMX (MMX technology supported)
                FXSR (FXSAVE and FXSTOR instructions supported)
                SSE (Streaming SIMD extensions)
                SSE2 (Streaming SIMD extensions 2)
                SS (Self-snoop)
                HTT (Multi-threading)
                TM (Thermal monitor supported)
                PBE (Pending break enabled)
        Version: Intel(R) Xeon(R) Platinum 8372C CPU @ 3.20GHz
        Voltage: 1.6 V
        External Clock: 100 MHz
        Max Speed: 3500 MHz
        Current Speed: 3200 MHz
        Status: Populated, Enabled
        Upgrade: <OUT OF SPEC>
        L1 Cache Handle: 0x008B
        L2 Cache Handle: 0x008C
        L3 Cache Handle: 0x008D
        Serial Number: 499F7302D55B8BBE
        Asset Tag: UNKNOWN
        Part Number: Not Specified
        Core Count: 28
        Core Enabled: 28
        Thread Count: 56
        Characteristics:
                64-bit capable
                Multi-Core
                Hardware Thread
                Execute Protection
                Enhanced Virtualization
                Power/Performance Control

6、查看内存速率

命令:

dmidecode|grep -A16 "Memory Device"|grep 'Speed'

输出:

        Speed: 3200 MT/s
        Speed: Unknown
        Speed: 3200 MT/s
        Speed: Unknown
        Speed: 3200 MT/s
        Speed: Unknown
        Speed: 3200 MT/s
        Speed: Unknown
        Speed: 3200 MT/s
        Speed: Unknown
        Speed: 3200 MT/s
        Speed: Unknown
        Speed: 3200 MT/s
        Speed: Unknown
        Speed: 3200 MT/s
        Speed: Unknown
        Speed: 3200 MT/s
        Speed: Unknown
        Speed: 3200 MT/s
        Speed: Unknown
        Speed: 3200 MT/s
        Speed: Unknown
        Speed: 3200 MT/s
        Speed: Unknown
        Speed: 3200 MT/s
        Speed: Unknown
        Speed: 3200 MT/s
        Speed: Unknown
        Speed: 3200 MT/s
        Speed: Unknown
        Speed: 3200 MT/s
        Speed: Unknown

7、查看支持的最大内存

命令:

dmidecode|grep -P ‘Maximum\s+Capacity’

输出:

        Maximum Capacity: 12 TB

8、查看bios信息

命令:

dmidecode -t bios

输出:

# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 3.3.0 present.
# SMBIOS implementations newer than version 3.2.0 are not
# fully supported by this version of dmidecode.

Handle 0x0000, DMI type 0, 26 bytes
BIOS Information
        Vendor: American Megatrends Inc.
        Version: 1.05.00
        Release Date: 01/10/2022
        Address: 0xF0000
        Runtime Size: 64 kB
        ROM Size: 32 MB
        Characteristics:
                PCI is supported
                BIOS is upgradeable
                BIOS shadowing is allowed
                Boot from CD is supported
                Selectable boot is supported
                BIOS ROM is socketed
                EDD is supported
                Japanese floppy for NEC 9800 1.2 MB is supported (int 13h)
                Japanese floppy for Toshiba 1.2 MB is supported (int 13h)
                5.25"/360 kB floppy services are supported (int 13h)
                5.25"/1.2 MB floppy services are supported (int 13h)
                3.5"/720 kB floppy services are supported (int 13h)
                3.5"/2.88 MB floppy services are supported (int 13h)
                Print screen service is supported (int 5h)
                Serial services are supported (int 14h)
                Printer services are supported (int 17h)
                CGA/mono video services are supported (int 10h)
                USB legacy is supported
                BIOS boot specification is supported
                Targeted content distribution is supported
                UEFI is supported
        BIOS Revision: 5.22

Handle 0x010E, DMI type 13, 22 bytes
BIOS Language Information
        Language Description Format: Long
        Installable Languages: 2
                en|US|iso8859-1
                zh|CN|unicode
        Currently Installed Language: en|US|iso8859-1


9、查看bios版本

命令:

dmidecode -s bios-version

输出:

1.05.00

四、dmidecode参数string及type列表

1、Valid string关键字

0、bios-vendor
1、bios-version
2、bios-release-date
3、system-manufacturer
4、system-product-name
5、 system-version
6、 system-serial-number
7、 system-uuid
8、baseboard-manufacturer
9、baseboard-product-name
10、baseboard-version
11 、baseboard-serial-number
12 、baseboard-asset-tag
13 、chassis-manufacturer
14、chassis-type
15、chassis-version
16、chassis-serial-number
17、chassis-asset-tag
18、processor-family
19、processor-manufacturer
20、processor-version
21、 processor-frequency

2、Valid type关键字

0、 bios

1、 system

2、baseboard

3、chassis

4、processor

5、 memory

6、 Cache

7、connector

8、 slot

3、type全部编码列表

查询命令可简化为:

$ dmidecode -t [num]

num的取值代表的含义如下表所示:

0、 BIOS

1、System

2、 Base Board

3、Chassis

4、 Processor

5、 Memory Controller

6、Memory Module

7、Cache

8、Port Connector

9、System Slots

10、On Board Devices

11、 OEM Strings

12、System Configuration Options

13 、BIOS Language

14、 Group Associations

15 、System Event Log

16、Physical Memory Array

17、 Memory Device

18 、32-bit Memory Error

19、 Memory Array Mapped Address

20、 Memory Device Mapped Address

21 、Built-in Pointing Device

22 、Portable Battery

23、 System Reset

24、 Hardware Security

25 、System Power Controls

26 、Voltage Probe

27 、Cooling Device

28、 Temperature Probe

29、Electrical Current Probe

30、 Out-of-band Remote Access

31、 Boot Integrity Services

32、 System Boot

33、64-bit Memory Error

34、 Management Device

35、Management Device Component

36、 Management Device Threshold Data

37、 Memory Channel

38、 IPMI Device

39、Power Supply

40、 Additional Information

41、Onboard Device

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐