Linux 下 dmidecode 命令获取硬件信息
作者:互联网
dmidecode 在 Linux 系统下获取有关硬件方面的信息。dmidecode 遵循 SMBIOS/DMI 标准,以一种可读的方式 dump 出机器的DMI(Desktop Management Interface)信息, 其输出的信息包括 BIOS、系统、主板、处理器、内存、缓存等等, 既可以得到当前的配置,也可以得到系统支持的最大配置,比如说支持的最大内存数等。
以下测试因在虚拟机上测试,所以看起来会比较怪
1、查看内存槽数、那个槽位插了内存,大小是多少
# dmidecode | grep -P -A5 "Memory\s+Device" | grep Size | grep -v Range | grep -v No
Size: 4096 MB
2、查看最大支持内存数
# dmidecode | grep -P 'Maximum\s+Capacity'
Maximum Capacity: 65 GB
3、查看槽位上内存的速率,没插就是 unknown。
# dmidecode | grep -A16 'Memory Device' | grep Speed
Speed: Unknown
Speed: Unknown
Speed: Unknown
Speed: Unknown
1.最简单的的显示全部dmi信息:
# dmidecode
这样将输出所有的dmi信息,你可能会被一大堆的信息吓坏,通常可以使用下面的方法。
2.更精简的信息显示:
# dmidecode -q
-q(–quite) 只显示必要的信息。
3.显示指定类型的信息:
通常我只想查看某类型,比如 CPU,内存 或者 磁盘的信息而不是全部的。这可以使用 -t(–type TYPE) 来指定信息类型:
# dmidecode -t bios
# dmidecode 2.11
SMBIOS 2.7 present.
Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
Vendor: Phoenix Technologies LTD
Version: 6.00
Release Date: 07/29/2019
Address: 0xEA480
Runtime Size: 88960 bytes
ROM Size: 64 kB
Characteristics:
ISA is supported
PCI is supported
PC Card (PCMCIA) is supported
PNP is supported
APM is supported
BIOS is upgradeable
BIOS shadowing is allowed
ESCD support is available
Boot from CD is supported
Selectable boot is supported
EDD is supported
Print screen service is supported (int 5h)
8042 keyboard services are supported (int 9h)
Serial services are supported (int 14h)
Printer services are supported (int 17h)
CGA/mono video services are supported (int 10h)
ACPI is supported
Smart battery is supported
BIOS boot specification is supported
Function key-initiated network boot is supported
Targeted content distribution is supported
BIOS Revision: 4.6
Firmware Revision: 0.0
dmidecode到底支持哪些type?
这些可以在man dmidecode里面看到:
文本参数支持:
bios, system, baseboard, chassis, processor, memory, cache, connector, slot
数字参数支持很多:(见附录)
4.通过关键字查看信息:
比如只想查看序列号,可以使用:
# dmidecode -s system-serial-number
VMware-56 4d fa b6 c0 ae c7 64-56 ab b0 6f 58 b2 2f b2
-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-version
chassis-serial-number
chassis-asset-tag
processor-family
processor-manufacturer
processor-version
processor-frequency
5.示例
5.1 查看当前内存和支持的最大内存
Linux下,可以使用 free或者查看 meminfo 来获得当前的物理内存:
# free
total used free shared buffers cached
Mem: 3908800 859280 3049520 0 95788 369472
-/+ buffers/cache: 394020 3514780
Swap: 2097144 0 2097144
# grep MemTotal /proc/meminfo
MemTotal: 3908800 kB
这里显示了当前服务器的物理内存是 8GB。
虚拟机到底能扩展到多大的内存?
# dmidecode -t 16
# dmidecode 2.11
SMBIOS 2.7 present.
Handle 0x01A2, DMI type 16, 23 bytes
Physical Memory Array
Location: System Board Or Motherboard
Use: System Memory
Error Correction Type: None
Maximum Capacity: 65 GB
Error Information Handle: Not Provided
Number Of Devices: 64
附录:
dmidecode支持的数字参数:
Type Information
![](https://g.csdnimg.cn/static/user-reg-year/1x/5.png)
标签:grep,supported,system,硬件,dmidecode,chassis,内存,Linux 来源: https://blog.csdn.net/KgdYsg/article/details/104412742