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

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信息:
[[email protected] ~]# dmidecode
# dmidecode 2.12
SMBIOS 2.7 present.
......
......
Handle 0x0020, DMI type 127, 4 bytes
End Of Table

更精简的信息显示:
[[email protected] ~]# dmidecode -q
显示指定类型的信息:
通常我只想查看某类型,比如CPU,内存或者磁盘的信息而不是全部的。这可以使用-t(--type TYPE)来指定信息类型:
[[email protected] ~]# dmidecode -t bios
[[email protected] ~]# 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
   
通过关键字查看信息:
比如只想查看序列号,可以使用:
[[email protected] ~]# 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来获得当前的物理内存:
[[email protected] ~]# free -m
             total       used       free     shared    buffers     cached
Mem:         32053        436      31617          0          8         55
-/+ buffers/cache:        371      31681
Swap:         7999          0       7999
这里显示了当前服务器的物理内存是32GB。
服务器到底能扩展到多大的内存?,可以使用下面的命令来查看:
[[email protected] ~]# 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,但是插槽已经插满,无法扩展了:
[[email protected] ~]# 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

根据上面输出可以发现,如果要扩展,只有将上面的内存条换成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

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

时间: 2024-10-06 17:12:17

使用dmidecode在Linux下获取硬件信息的相关文章

[转]Linux下显示硬件信息--lshw

Linux下显示硬件信息--lshw lshw lshw(Hardware Lister)是另外一个可以查看硬件信息的工具,不仅如此,它还可以用来做一些硬件的benchmark. 这个工具其实就是用/proc里面读取一些文件来显示相关的信息,它用到了如下文件和目录(下的文件): /proc/cpuinfo  显示CPU信息 /proc/bus/pci  显示pci信息 /proc/scsi   显示scsi信息 /proc/net/dev  显示网络设备信息 /proc/kcore   从内存映

Linux下获取网络接口信息

Linux下的网络接口信息在shell下可以很方便地使用ifconfig查看.同样,使用C/C++也可以很方便地获取接口信息. netdevice是一个低级别的访问Linux网络设备的方法.此方法通过ioctl来获取网络接口的相关信息. 这里需要借助<net/if.h>头文件中定义的ifreq结构体.此结构体包含了网络接口的名称.IP地址.广播地址.网络地址. 掩码等相关信息.在获取上述相关信息的时候需要指明网络接口的名称. 1 struct ifreq { 2 char ifr_name[I

dmidecode命令详解(获取硬件信息)

一.dmidecode简介 dmidecode允许你在Linux系统下获取有关硬件方面的信息.dmidecode遵循SMBIOS/DMI标准,其输出的信息包括BIOS.系统.主板.处理器.内存.缓存等等. DMI(Desktop Management Interface,DMI)就是帮助收集电脑系统信息的管理系统,DMI信息的收集必须在严格遵照SMBIOS规范的前提下进行.SMBIOS(System Management BIOS)是主板或系统制造者以标准格式显示产品管理信息所需遵循的统一规范.

linux下获取主机信息

程序源于linux程序设计这本书,个人利用这本书学习,本文作为一个知识点来学习. 这里首先介绍几个结构体: 1 2 3 4 5 6 7 struct hostent{ char* h_name;//主机名称 char* h_aliases;//主机别名 short h_addrtype;//主机地址类型 short h_length;//主机地址长度 char **h_addr_list;//主机地址列表 }   其中,主机地址类型h_addrtype为AF_INET;地址列表为字符串,长度不定

LINUX下相关硬件信息的查询

1.查看内核版本 #uname -a Linux mailserver2 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux #uname -r 2.6.32-279.el6.x86_64 2.查看LINUX发行软件版本 #cat  /etc/issue CentOS release 6.3 (Final)Kernel \r on an \m # cat /etc/red

linux 下查看硬件信息(mac,IP地址,硬盘型号,序列号等)

一.查看网卡mac地址 #安装lshw [[email protected] ~]# yum install lshw #使用方法 [[email protected] ~]# lshw -c network *-network:0 description: Ethernet interface product: NetXtreme II BCM5709 Gigabit Ethernet vendor: Broadcom Limited physical id: 0 bus info: [ema

Window下获取硬件信息(CPU, 硬盘,网卡等)

一.头文件如下: #include <Windows.h> #include <string> #include <iostream> #include <winnt.h> #include <tchar.h> #include <IPHlpApi.h> #pragma comment(lib,"ws2_32.lib") #pragma comment(lib,"Advapi32.lib") #

Linux 系统下查看硬件信息命令大全

有许多命令可以用来查看 Linux 系统上的硬件信息.有些命令只能够打印出像 CPU 和内存这一特定的硬件组件信息,另外一些命令可以查看多种硬件组件的信息. 这个教程可以带大家快速了解一下查看各种硬件设备的信息和配置详情的最常用的命令. lscpu lscpu命令能够查看 CPU 和处理单元的信息.该命令没有任何其他选项或者别的功能. lscpu 运行该命令会看到下面输出: lspci lspci是另一个命令行工具,可以用来列出所有的 PCI 总线,还有与 PCI 总线相连的设备的详细信息,比如

如何在windows下和linux下获取文件(如exe文件)的详细信息和属性

程序员都很懒,你懂的! 最近在项目开发中,由cs开发的exe的程序,需要自动升级,该exe程序放在linux下,自动升级时检测不到该exe程序的版本号信息,但是我们客户端的exe程序需要获取服务器上新程序的版本号信息.最后由我用java实现linux上exe文件的版本号读取功能.下面是详细代码: package com.herman.utils; import java.io.File; import java.io.FileNotFoundException; import java.io.I