码迷,mamicode.com
首页 > 系统相关 > 详细

使用dmidecode在Linux下获取硬件信息

时间:2018-08-07 10:57:36      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:devices   获得   ext   有关   type   语法   att   min   extend   

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,用户可以获取序列号、电脑厂商、串口信息以及其它系统配件信息。

语法
dmidecode [选项]
选项
-d,-DEV MEM文件从设备文件读取内存(默认值:/DEV/MEM)
-h,帮助显示此帮助文本并退出
-Q,安静较少的冗长输出
-s,-string关键字只显示给定的DMI字符串的值
-t,-Type类型只显示给定类型的条目
-U,-转储不解码条目
——转储文件将DMI数据转储到二进制文件中。
——从转储文件读取二进制文件中的DMI数据
-V,-版本显示版本和退出
其实以上数值就是通过dmidecode命令来实现的,具体方法如下:
dmidecode以一种可读的方式dump出机器的DMI(Desktop Management Interface)信息。这些信息包括了硬件以及BIOS,既可以得到当前的配置,也可以得到系统支持的最大配置,比如说支持的最大内存数等。
 

DMI有人也叫SMBIOS(System Management BIOS),这两个标准都由DMTF(Desktop Management Task Force)开发。

实例:

显示全部dmi信息:
[root@localhost ~]# dmidecode
# dmidecode 2.12
SMBIOS 2.7 present.
......
......
Handle 0x0020, DMI type 127, 4 bytes
End Of Table

更精简的信息显示:
[root@localhost ~]# dmidecode -q
显示指定类型的信息:
通常我只想查看某类型,比如CPU,内存或者磁盘的信息而不是全部的。这可以使用-t(--type TYPE)来指定信息类型:
[root@localhost ~]# dmidecode -t bios
[root@localhost ~]# dmidecode -t 0,4
dmidecode支持的类型:
       Type   Information
       --------------------------------------------
          0   BIOS
          1   System
          2   Baseboard
          3   Chassis
          4   Processor
          5   Memory Controller
          6   Memory Module
          7   Cache
          8   Port Connector
   
通过关键字查看信息:
比如只想查看序列号,可以使用:
[root@localhost ~]# 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,  system-uuid,  baseboard-manufacturer,baseboard-product-name,   baseboard-version,   baseboard-serial-number,baseboard-asset-tag,  chassis-manufacturer,  chassis-type, chassis-ver-sion, chassis-serial-number, chassis-asset-tag, processor-family,  pro-cessor-manufacturer, processor-version, processor-frequency.

查看当前内存和支持的最大内存:
Linux下,可以使用free或者查看meminfo来获得当前的物理内存:
[root@localhost ~]# free -m
             total       used       free     shared    buffers     cached
Mem:         32053        436      31617          0          8         55
-/+ buffers/cache:        371      31681
Swap:         7999          0       7999
这里显示了当前服务器的物理内存是32GB。
服务器到底能扩展到多大的内存?,可以使用下面的命令来查看:
[root@localhost ~]# dmidecode -t 16
# dmidecode 2.12
SMBIOS 2.7 present.

Handle 0x0007, DMI type 16, 23 bytes
Physical Memory Array
    Location: System Board Or Motherboard
    Use: System Memory
    Error Correction Type: Single-bit ECC
    Maximum Capacity: 768 GB    (可扩展768G)
    Error Information Handle: Not Provided
    Number Of Devices: 12

但是,事实不一定如此,因此插槽可能已经插满了。也就是我们还必须查清这里的32G到底是4*8GB, 2*16GB还是其他?
如果是4*8GB,那么尽管可以扩展到768GB,但是插槽已经插满,无法扩展了:
[root@localhost ~]# dmidecode -t 17

技术分享图片
  1 # dmidecode 2.12
  2 SMBIOS 2.7 present.
  3 
  4 Handle 0x0008, DMI type 17, 34 bytes
  5 Memory Device
  6     Array Handle: 0x0007
  7     Error Information Handle: Not Provided
  8     Total Width: 72 bits
  9     Data Width: 64 bits
 10     Size: 16384 MB
 11     Form Factor: DIMM
 12     Set: None
 13     Locator: DIMM010
 14     Bank Locator: BRANCH 0 CHANNEL 1 DIMM 0
 15     Type: DDR3
 16     Type Detail: Synchronous Registered (Buffered)
 17     Speed: 1067 MHz
 18     Manufacturer: Hynix
 19     Serial Number: 0x37161DC3
 20     Asset Tag: Unknown
 21     Part Number: HMT42GR7CMR4A-G7
 22     Rank: 4
 23     Configured Clock Speed: 800 MHz
 24 
 25 Handle 0x0009, DMI type 17, 34 bytes
 26 Memory Device
 27     Array Handle: 0x0007
 28     Error Information Handle: Not Provided
 29     Total Width: Unknown
 30     Data Width: Unknown
 31     Size: No Module Installed
 32     Form Factor: DIMM
 33     Set: None
 34     Locator: DIMM011
 35     Bank Locator: BRANCH 0 CHANNEL 1 DIMM 1
 36     Type: DDR3
 37     Type Detail: Synchronous
 38     Speed: Unknown
 39     Manufacturer: NO DIMM
 40     Serial Number: NO DIMM
 41     Asset Tag: NO DIMM
 42     Part Number: NO DIMM
 43     Rank: Unknown
 44     Configured Clock Speed: Unknown
 45 
 46 Handle 0x000A, DMI type 17, 34 bytes
 47 Memory Device
 48     Array Handle: 0x0007
 49     Error Information Handle: Not Provided
 50     Total Width: Unknown
 51     Data Width: Unknown
 52     Size: No Module Installed
 53     Form Factor: DIMM
 54     Set: None
 55     Locator: DIMM020
 56     Bank Locator: BRANCH 0 CHANNEL 2 DIMM 0
 57     Type: DDR3
 58     Type Detail: Synchronous
 59     Speed: Unknown
 60     Manufacturer: NO DIMM
 61     Serial Number: NO DIMM
 62     Asset Tag: NO DIMM
 63     Part Number: NO DIMM
 64     Rank: Unknown
 65     Configured Clock Speed: Unknown
 66 
 67 Handle 0x000B, DMI type 17, 34 bytes
 68 Memory Device
 69     Array Handle: 0x0007
 70     Error Information Handle: Not Provided
 71     Total Width: Unknown
 72     Data Width: Unknown
 73     Size: No Module Installed
 74     Form Factor: DIMM
 75     Set: None
 76     Locator: DIMM021
 77     Bank Locator: BRANCH 0 CHANNEL 2 DIMM 1
 78     Type: DDR3
 79     Type Detail: Synchronous
 80     Speed: Unknown
 81     Manufacturer: NO DIMM
 82     Serial Number: NO DIMM
 83     Asset Tag: NO DIMM
 84     Part Number: NO DIMM
 85     Rank: Unknown
 86     Configured Clock Speed: Unknown
 87 
 88 Handle 0x000C, DMI type 17, 34 bytes
 89 Memory Device
 90     Array Handle: 0x0007
 91     Error Information Handle: Not Provided
 92     Total Width: Unknown
 93     Data Width: Unknown
 94     Size: No Module Installed
 95     Form Factor: DIMM
 96     Set: None
 97     Locator: DIMM030
 98     Bank Locator: BRANCH 0 CHANNEL 3 DIMM 0
 99     Type: DDR3
100     Type Detail: Synchronous
101     Speed: Unknown
102     Manufacturer: NO DIMM
103     Serial Number: NO DIMM
104     Asset Tag: NO DIMM
105     Part Number: NO DIMM
106     Rank: Unknown
107     Configured Clock Speed: Unknown
108 
109 Handle 0x000D, DMI type 17, 34 bytes
110 Memory Device
111     Array Handle: 0x0007
112     Error Information Handle: Not Provided
113     Total Width: Unknown
114     Data Width: Unknown
115     Size: No Module Installed
116     Form Factor: DIMM
117     Set: None
118     Locator: DIMM031
119     Bank Locator: BRANCH 0 CHANNEL 3 DIMM 1
120     Type: DDR3
121     Type Detail: Synchronous
122     Speed: Unknown
123     Manufacturer: NO DIMM
124     Serial Number: NO DIMM
125     Asset Tag: NO DIMM
126     Part Number: NO DIMM
127     Rank: Unknown
128     Configured Clock Speed: Unknown
129 
130 Handle 0x000E, DMI type 17, 34 bytes
131 Memory Device
132     Array Handle: 0x0007
133     Error Information Handle: Not Provided
134     Total Width: 72 bits
135     Data Width: 64 bits
136     Size: 16384 MB
137     Form Factor: DIMM
138     Set: None
139     Locator: DIMM110
140     Bank Locator: BRANCH 1 CHANNEL 1 DIMM 0
141     Type: DDR3
142     Type Detail: Synchronous Registered (Buffered)
143     Speed: 1067 MHz
144     Manufacturer: Hynix
145     Serial Number: 0x37A61E5F
146     Asset Tag: Unknown
147     Part Number: HMT42GR7CMR4A-G7
148     Rank: 4
149     Configured Clock Speed: 800 MHz
150 
151 Handle 0x000F, DMI type 17, 34 bytes
152 Memory Device
153     Array Handle: 0x0007
154     Error Information Handle: Not Provided
155     Total Width: Unknown
156     Data Width: Unknown
157     Size: No Module Installed
158     Form Factor: DIMM
159     Set: None
160     Locator: DIMM111
161     Bank Locator: BRANCH 1 CHANNEL 1 DIMM 1
162     Type: DDR3
163     Type Detail: Synchronous
164     Speed: Unknown
165     Manufacturer: NO DIMM
166     Serial Number: NO DIMM
167     Asset Tag: NO DIMM
168     Part Number: NO DIMM
169     Rank: Unknown
170     Configured Clock Speed: Unknown
171 
172 Handle 0x0010, DMI type 17, 34 bytes
173 Memory Device
174     Array Handle: 0x0007
175     Error Information Handle: Not Provided
176     Total Width: Unknown
177     Data Width: Unknown
178     Size: No Module Installed
179     Form Factor: DIMM
180     Set: None
181     Locator: DIMM120
182     Bank Locator: BRANCH 1 CHANNEL 2 DIMM 0
183     Type: DDR3
184     Type Detail: Synchronous
185     Speed: Unknown
186     Manufacturer: NO DIMM
187     Serial Number: NO DIMM
188     Asset Tag: NO DIMM
189     Part Number: NO DIMM
190     Rank: Unknown
191     Configured Clock Speed: Unknown
192 
193 Handle 0x0011, DMI type 17, 34 bytes
194 Memory Device
195     Array Handle: 0x0007
196     Error Information Handle: Not Provided
197     Total Width: Unknown
198     Data Width: Unknown
199     Size: No Module Installed
200     Form Factor: DIMM
201     Set: None
202     Locator: DIMM121
203     Bank Locator: BRANCH 1 CHANNEL 2 DIMM 1
204     Type: DDR3
205     Type Detail: Synchronous
206     Speed: Unknown
207     Manufacturer: NO DIMM
208     Serial Number: NO DIMM
209     Asset Tag: NO DIMM
210     Part Number: NO DIMM
211     Rank: Unknown
212     Configured Clock Speed: Unknown
213 
214 Handle 0x0012, DMI type 17, 34 bytes
215 Memory Device
216     Array Handle: 0x0007
217     Error Information Handle: Not Provided
218     Total Width: Unknown
219     Data Width: Unknown
220     Size: No Module Installed
221     Form Factor: DIMM
222     Set: None
223     Locator: DIMM130
224     Bank Locator: BRANCH 1 CHANNEL 3 DIMM 0
225     Type: DDR3
226     Type Detail: Synchronous
227     Speed: Unknown
228     Manufacturer: NO DIMM
229     Serial Number: NO DIMM
230     Asset Tag: NO DIMM
231     Part Number: NO DIMM
232     Rank: Unknown
233     Configured Clock Speed: Unknown
234 
235 Handle 0x0013, DMI type 17, 34 bytes
236 Memory Device
237     Array Handle: 0x0007
238     Error Information Handle: Not Provided
239     Total Width: Unknown
240     Data Width: Unknown
241     Size: No Module Installed
242     Form Factor: DIMM
243     Set: None
244     Locator: DIMM131
245     Bank Locator: BRANCH 1 CHANNEL 3 DIMM 1
246     Type: DDR3
247     Type Detail: Synchronous
248     Speed: Unknown
249     Manufacturer: NO DIMM
250     Serial Number: NO DIMM
251     Asset Tag: NO DIMM
252     Part Number: NO DIMM
253     Rank: Unknown
254     Configured Clock Speed: Unknown
View Code


根据上面输出可以发现,如果要扩展,只有将上面的内存条换成64GB的,才能达到12*64GB=768GB的最大支持内存。

附录:
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

使用dmidecode在Linux下获取硬件信息

标签:devices   获得   ext   有关   type   语法   att   min   extend   

原文地址:https://www.cnblogs.com/Mr-Ding/p/9435551.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!