服务器硬件信息查看之dmidecode:
参考资料:http://www.ttlsa.com/linux/the-linux-dmidecode-command-to-get-the-hardware-information
http://www.laozuo.org/6682.html
dmidecode在 Linux 系统下获取有关硬件方面的信息。dmidecode 遵循 SMBIOS/DMI 标准,以一种可读的方式dump出机器的DMI(Desktop Management Interface)信息, 其输出的信息包括 BIOS、系统、主板、处理器、内存、缓存等等, 既可以得到当前的配置,也可以得到系统支持的最大配置,比如说支持的最大内存数等。
不同系统安装dmidecode方式:
aptitude install dmidecode # Debian/Ubuntu
yum install dmidecode # Fedora,redhat
pacman -S dmidecode # Arch Linux
emerge -av dmidecode # Gentoo
系统centos6.8
yum -y install dmidecode
1.查看内存槽数、那个槽位插了内存,大小是多少:
[root@localhost ~]# dmidecode|grep -P -A5 "Memory\s+Device"|grep Size|grep -v Range
Size: 16384 MB
Size: No Module Installed
Size: 16384 MB
Size: 16384 MB
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: 16384 MB
Size: 16384 MB
Size: 16384 MB
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
2、查看最大支持内存数
[root@localhost ~]# dmidecode|grep -P 'Maximum\s+Capacity'
Maximum Capacity: 3 TB
[root@localhost ~]#
3、查看槽位上内存的速率,没插就是unknown。
[root@localhost ~]# dmidecode|grep -A16 "Memory Device"|grep 'Speed'
Speed: 2133 MHz
Speed: Unknown
Speed: 2133 MHz
Speed: 2133 MHz
Speed: Unknown
Speed: Unknown
Speed: Unknown
Speed: Unknown
Speed: Unknown
Speed: Unknown
Speed: Unknown
Speed: Unknown
Speed: 2133 MHz
Speed: 2133 MHz
Speed: 2133 MHz
Speed: Unknown
Speed: Unknown
Speed: Unknown
Speed: Unknown
Speed: Unknown
Speed: Unknown
Speed: Unknown
Speed: Unknown
Speed: Unknown
4.查看CPU信息
dmidecode -t 4
dmidecode的输出格式一般如下:
Handle 0×0002
DMI type 2, 8 bytes
Base Board Information
Manufacturer:Intel
Product Name: C440GX+
Version: 727281-0001
Serial Number: INCY92700942
其中的前三行都称为记录头(recoce Header), 其中包括了:
1、recode id(handle): DMI表中的记录标识符,这是唯一的,比如上例中的Handle 0×0002。
2、dmi type id: 记录的类型,譬如说:BIOS,Memory,上例是type 2,即”Base Board Information”
3、recode size: DMI表中对应记录的大小,上例为8 bytes.(不包括文本信息,所有实际输出的内容比这个size要更大。)
记录头之后就是记录的值:
4、decoded values: 记录值可以是多行的,比如上例显示了主板的制造商(manufacturer)、model、version以及serial Number。
dmidecode的使用方法
1. 最简单的的显示全部dmi信息:
# dmidecode
1
# dmidecode
这样将输出所有的dmi信息,你可能会被一大堆的信息吓坏,通常可以使用下面的方法。
2.更精简的信息显示:
# dmidecode -q
1
# dmidecode -q
-q(–quite) 只显示必要的信息,这个很管用哦。
3.显示指定类型的信息:
通常我只想查看某类型,比如CPU,内存或者磁盘的信息而不是全部的。这可以使用-t(–type TYPE)来指定信息类型:
# dmidecode -t bios
# dmidecode -t bios, processor (这种方式好像不可以用,必须用下面的数字的方式)
# dmidecode -t 0,4 (显示bios和processor)
# dmidecode -t bios
# dmidecode -t bios, processor (这种方式好像不可以用,必须用下面的数字的方式)
# dmidecode -t 0,4 (显示bios和processor)
dmidecode到底支持哪些type?
这些可以在man dmidecode里面看到:
文本参数支持:
bios, system, baseboard, chassis, processor, memory, cache, connector, slot
数字参数支持很多:(见附录)
4.通过关键字查看信息:
比如只想查看序列号,可以使用:
[root@localhost ~]# dmidecode -s system-serial-number
JVJBRH2
5.示例
5.1 查看当前内存和支持的最大内存
Linux下,可以使用free或者查看meminfo来获得当前的物理内存:
# free
total used free shared buffers cached
Mem: 8182532 8010792 171740 0 148472 4737896
-/+ buffers/cache: 3124424 5058108
Swap: 4192956 3304 4189652
# grep MemTotal /proc/meminfo
MemTotal: 8182532 kB
# free
total used free shared buffers cached
Mem: 8182532 8010792 171740 0 148472 4737896
-/+ buffers/cache: 3124424 5058108
Swap: 4192956 3304 4189652
# grep MemTotal /proc/meminfo
MemTotal: 8182532 kB
这里显示了当前服务器的物理内存是8GB。
服务器到底能扩展到多大的内存?
#dmidecode -t 16
# dmidecode 2.7
SMBIOS 2.4 present.
Handle 0×0013, DMI type 16, 15 bytes.
Physical Memory Array
Location: System Board Or Motherboard
Use: System Memory
Error Correction Type: Multi-bit ECC
Maximum Capacity: 64 GB (可扩展到64GB)
Error Information Handle: Not Provided
Number Of Devices: 4
#dmidecode -t 16
# dmidecode 2.7
SMBIOS 2.4 present.
Handle 0×0013, DMI type 16, 15 bytes.
Physical Memory Array
Location: System Board Or Motherboard
Use: System Memory
Error Correction Type: Multi-bit ECC
Maximum Capacity: 64 GB (可扩展到64GB)
Error Information Handle: Not Provided
Number Of Devices: 4
但是,事实不一定如此,因此插槽可能已经插满了。也就是我们还必须查清这里的8G到底是4*2GB, 2*4GB还是其他?
如果是4*2GB,那么尽管可以扩展到64GB,但是插槽已经插满,无法扩展了:
查看内存条数:
#dmidecode -t 17
# dmidecode 2.7
SMBIOS 2.4 present.
Handle 0×0015, DMI type 17, 27 bytes.
Memory Device
Array Handle: 0×0013
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: 2048 MB 【插槽1有1条2GB内存】
Form Factor: DIMM
Set: None
Locator: DIMM00
Bank Locator: BANK
Type: Other
Type Detail: Other
Speed: 667 MHz (1.5 ns)
Manufacturer:
Serial Number: BZACSKZ001
Asset Tag: RAM82
Part Number: MT9HTF6472FY-53EA2
Handle 0×0017, DMI type 17, 27 bytes.
Memory Device
Array Handle: 0×0013
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: 2048 MB 【插槽2有1条2GB内存】
Form Factor: DIMM
Set: None
Locator: DIMM10
Bank Locator: BANK
Type: Other
Type Detail: Other
Speed: 667 MHz (1.5 ns)
Manufacturer:
Serial Number: BZACSKZ001
Asset Tag: RAM83
Part Number: MT9HTF6472FY-53EA2
Handle 0×0019, DMI type 17, 27 bytes.
Memory Device
Array Handle: 0×0013
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: 2048 MB 【插槽3有1条2GB内存】
Form Factor: DIMM
Set: None
Locator: DIMM20
Bank Locator: BANK
Type: Other
Type Detail: Other
Speed: 667 MHz (1.5 ns)
Manufacturer:
Serial Number: BZACSKZ001
Asset Tag: RAM84
Part Number: MT9HTF6472FY-53EA2
Handle 0x001B, DMI type 17, 27 bytes.
Memory Device
Array Handle: 0×0013
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: 2048 MB 【插槽4有1条2GB内存】
Form Factor: DIMM
Set: None
Locator: DIMM30
Bank Locator: BANK
Type: Other
Type Detail: Other
Speed: 667 MHz (1.5 ns)
Manufacturer:
Serial Number: BZACSKZ001
Asset Tag: RAM85
Part Number: MT9HTF6472FY-53EA2
#dmidecode -t 17
# dmidecode 2.7
SMBIOS 2.4 present.
Handle 0×0015, DMI type 17, 27 bytes.
Memory Device
Array Handle: 0×0013
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: 2048 MB 【插槽1有1条2GB内存】
Form Factor: DIMM
Set: None
Locator: DIMM00
Bank Locator: BANK
Type: Other
Type Detail: Other
Speed: 667 MHz (1.5 ns)
Manufacturer:
Serial Number: BZACSKZ001
Asset Tag: RAM82
Part Number: MT9HTF6472FY-53EA2
Handle 0×0017, DMI type 17, 27 bytes.
Memory Device
Array Handle: 0×0013
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: 2048 MB 【插槽2有1条2GB内存】
Form Factor: DIMM
Set: None
Locator: DIMM10
Bank Locator: BANK
Type: Other
Type Detail: Other
Speed: 667 MHz (1.5 ns)
Manufacturer:
Serial Number: BZACSKZ001
Asset Tag: RAM83
Part Number: MT9HTF6472FY-53EA2
Handle 0×0019, DMI type 17, 27 bytes.
Memory Device
Array Handle: 0×0013
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: 2048 MB 【插槽3有1条2GB内存】
Form Factor: DIMM
Set: None
Locator: DIMM20
Bank Locator: BANK
Type: Other
Type Detail: Other
Speed: 667 MHz (1.5 ns)
Manufacturer:
Serial Number: BZACSKZ001
Asset Tag: RAM84
Part Number: MT9HTF6472FY-53EA2
Handle 0x001B, DMI type 17, 27 bytes.
Memory Device
Array Handle: 0×0013
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: 2048 MB 【插槽4有1条2GB内存】
Form Factor: DIMM
Set: None
Locator: DIMM30
Bank Locator: BANK
Type: Other
Type Detail: Other
Speed: 667 MHz (1.5 ns)
Manufacturer:
Serial Number: BZACSKZ001
Asset Tag: RAM85
Part Number: MT9HTF6472FY-53EA2
根据上面输出可以发现,如果要扩展,只有将上面的内存条换成16GB的,才能达到4*16GB=64GB的最大支持内存。
本文转自 wjw555 51CTO博客,原文链接:http://blog.51cto.com/wujianwei/1973178