天天看点

Linux下获取详细硬件信息的工具:Dmidecode命令详解

dmidecode 这款软件允许你在 linux 系统下获取有关硬件方面的信息。dmidecode 遵循 smbios/dmi 标准,其输出的信息包括 bios、系统、主板、处理器、内存、缓存等等。偶发现这个工具很有用,就总结一下。

dmi简介

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的作用是将dmi数据库中的信息解码,以可读的文本方式显示。由于dmi信息可以人为修改,因此里面的信息不一定是系统准确的信息。

安装dmidecode

dmidecode 在主流的 linux 发行版中都可以找到,只需通过所用发行版的包管理器安装即可,如:

apt-get install dmidecode

# debian/ubuntu

yum install dmidecode

# rhel/centos/fedora

pacman -s dmidecode

# arch linux

emerge -av dmidecode

# gentoo

或者使用官方源码包安装:

dmidecode命令用法详解

不带选项执行 dmidecode 通常会输出所有的硬件信息。

dmidecode 有个很有用的选项 -t,可以按指定类型输出相关信息,假如要获得处理器方面的信息,则可以执行

dmidecode -t processor

输出:

# dmidecode 2.10

smbios 2.6 present.

handle 0x0004, dmi type 4, 40 bytes

processor information

socket designation: cpu 1

type: central processor

family: xeon

manufacturer: intel

id: a5 06 01 00 ff fb eb bf

signature: type 0, family 6, model 26, stepping 5

flags:

fpu (floating-point unit on-chip)

vme (virtual mode extension)

de (debugging extension)

------

usage: dmidecode [options]

options are:

-d, --dev-mem file read memory from device file (default: /dev/mem)

#从设备文件读信息,输出内容与不加参数标准输出相同

-h, --help display this help text and exit

#显示帮助信息

-q, --quiet less verbose output

#显示更少的简化信息

-s, --string keyword only display the value of the given dmi string

#只显示指定dmi字符串的信息

-t, --type type only display the entries of given type

#只显示指定条目的信息

-u, --dump do not decode the entries

#显示未解码的原始条目内容

--dump-bin file dump the dmi data to a binary file

--from-dump file read the dmi data from a binary file

-v, --version display the version and exit

#显示版本信息

命令用法示例:

1、查看服务器型号:dmidecode | grep 'product name'

2、查看主板的序列号:dmidecode |grep 'serial number'

3、查看系统序列号:dmidecode -s system-serial-number

4、查看内存信息:dmidecode -t memory

5、查看oem信息:dmidecode -t 11

关于 dmidecode 的更多用法,你可以通过指定 -h 选项查询。

dmidecode参数string及type列表

valid string keywords are:

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

valid type keywords are:

bios

system

baseboard

chassis

processor

memory

cache

connector

slot

type全部编码列表

type information

0 bios

1 system

2 base board

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 device

如有错误,欢迎指正

邮箱:[email protected]

作者:czmmiao  文章出处:http://czmmiao.iteye.com/blog/1933543