通过DMIDECODE读取设备硬件信息
发布时间:2019-07-01 09:48:40点击次数:6639次
一、dmidecode简介
dmidecode允许你在Linux系统下获取有关硬件方面的信息。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,用户可以获取序列号、电脑厂商、串口信息以及其它系统配件信息。
二、dmidecode的作用
dmidecode的作用是将DMI数据库中的信息解码,以可读的文本方式显示。由于DMI信息可以人为修改,因此里面的信息不一定是系统准确的信息。
三、dmidecode命令用法
不带选项执行dmidecode通常会输出所有的硬件信息。dmidecode有个很有用的选项-t,可以指定类型输出相关信息。
Usage: dmidecode [OPTIONS]
Options are:
-d:(default:/dev/mem)从设备文件读取信息,输出内容与不加参数标准输出相同。
-h:显示帮助信息。
-s:只显示指定DMI字符串的信息。(string)
-t:只显示指定条目的信息。(type)
-u:显示未解码的原始条目内容。
-- dump-bin FILE: Dump the DMI data to a binary file.
-- from-dump FILE: Read the DMI data from a binary file.
1. 最简单的的显示全部dmi信息:
[root@1621 ~]# dmidecode|wc -l
506
2.显示指定类型的信息:
通常我只想查看某类型,比如CPU,内存或者磁盘的信息而不是全部的。这可以使用-t(–type TYPE)来指定信息类型:[root@1621 ~]# dmidecode -t 0,4
dmidecode到底支持哪些type?
这些可以在man dmidecode里面看到:
Type Information
--------------------------------------------
0 BIOS
1 System
2 Baseboard
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 Devices Extended Information
42 Management Controller Host Interface
4.通过关键字查看信息:
比如只想查看序列号,可以使用:
[root@1621 ~]# dmidecode -s system-serial-number
-s (–string keyword)支持的keyword包括:
bios-vendor,bios-version,bios-release-date,
system-manufacturer,system-product-name,system-version,system-serial-number,
baseboard-manu-facturer,baseboard-product-name,baseboard-version,baseboard-serial-number,baseboard-asset-tag,
chassis-manufacturer,chas-sis-version,chassis-serial-number,chassis-asset-tag,
processor-manufacturer,processor-version.
四、实例
查看当前内存和支持的最大内存,硬盘
Linux下,可以使用free或者查看meminfo来获得当前的物理内存:
[root@1621 ~]# free
total used free shared buffers cached
Mem: 16256156 302412 15953744 208 5788 71236
-/+ buffers/cache: 225388 16030768
Swap: 8126460 0 8126460
[root@1621 ~]# free -m
total used free shared buffers cached
Mem: 15875 295 15580 0 5 69
-/+ buffers/cache: 219 15655
Swap: 7935 0 7935
1、查看内存槽数、哪个槽位插了内存,大小是多少
[root@1621 ~]# dmidecode |grep -A5 'Memory Device' |grep Size
Size: No Module Installed
Size: No Module Installed
Size: 16384 MB
Size: No Module Installed
Range Size: 16 GB
2、查看最大支持内存数
[root@1621 ~]# dmidecode |grep 'Maximum Capacity'
Maximum Capacity: 64 GB
3、查看槽位上内存的速率,没插就是unknown。
[root@1621 ~]# dmidecode |grep -A16 'Memory Device' |grep 'Speed'
Speed: Unknown
Speed: Unknown
Speed: 2400 MHz
Speed: Unknown
4、查看服务器硬盘信息
[root@1621 ~]# cat /proc/scsi/scsi |grep Model
Vendor: ATA Model: Samsung SSD 750 Rev: 1B6Q
Vendor: ATA Model: ST1000DM010-2EP1 Rev: CC43
[root@1621 ~]# hdparm -i /dev/sda /dev/sdb /dev/sdc /dev/sdd |grep Model
/dev/sdc: No such file or directory
Model=Samsung SSD 750 EVO 250GB, FwRev=MAT01B6Q, SerialNo=S33RNWAH855873E
Model=ST1000DM010-2EP102, FwRev=CC43, SerialNo=Z9ACSMDE