Linuxdmidecode命令
1.linux系统⾃带的dmidecode⼯具查询服务器硬件信息
dmidecode ⽤于获取服务器的硬件信息,通常是在不打开计算机机箱的情况下使⽤该命令来查找硬件详细信息
这个命令可以查看内存的⼏乎所有信息,包括频率⼤⼩等等,另外这个命令强⼤到⼏乎可以查任何硬件信息包括设备型号、bios 、cpu、主板、处理器、内存、缓存详细信息等等都例举出来
常见的⼏种⽤法
语法
dmidecode [选项]
选项
-d:(default:/dev/mem)从设备⽂件读取信息,输出内容与不加参数标准输出相同。
-h:显⽰帮助信息。
-s:只显⽰指定DMI字符串的信息。(string)
-t:只显⽰指定条⽬的信息。(type)
-u:显⽰未解码的原始条⽬内容。
--dump-bin file:将DMI数据转储到⼀个⼆进制⽂件中。
--from-dump FILE:从⼀个⼆进制⽂件读取DMI数据。
-V:显⽰版本信息。
[root@localhost ~]$ dmidecode # 打印所有硬件信息
[root@localhost ~]$ dmidecode -q # 打印所有硬件信息,⽐较简洁
[root@localhost ~]$ dmidecode | grep 'Product Name' # 以过滤的⽅式来查看指定的硬件信息(查看服务器型号)
[root@localhost ~]$ dmidecode -t bios # 查看BIOS相关的硬件信息
[root@localhost ~]$ dmidecode -t system # 查看系统相关的硬件信息
[root@localhost ~]$ dmidecode -t baboard # 查看主板相关的硬件信息
[root@localhost ~]$ dmidecode -t chassis # 查看机箱相关的硬件信息
[root@localhost ~]$ dmidecode -t processor # 查看处理器相关的硬件信息
[root@localhost ~]$ dmidecode -t memory # 查看内存相关的硬件信息
[root@localhost ~]$dmidecode |grep 'Serial Number' # 查看主板的序列号
[root@localhost ~]$dmidecode -s system-rial-number # 查看系统序列号
[root@localhost ~]$dmidecode -t 11 # 查看OEM信息
查询内存条数:
[root@tao ~]# dmidecode -t 17 | grep "Size.*MB" | wc -l
第⼀、dmidecode查看主板信息
dmidecode -t 2 = dmidecode -t baboard
[root@mysql ~]#dmidecode -t 2
# dmidecode 2.12
SMBIOS 2.5 prent.
Handle 0x0002, DMI type 2, 15 bytes
Ba Board Information
Manufacturer: ASUSTeK Computer INC.
Product Name: Z8NR-D12
Version: G
Serial Number: 120902356500037
Ast Tag: To Be Filled By O.E.M.
Features:
Board is a hosting board
Board is replaceable
Location In Chassis: To Be Filled By O.E.M.
Chassis Handle: 0x0003
Type: Motherboard
Contained Object Handles: 0
第⼆、使⽤dmidecode查询内存(RAM)信息
dmidecode -t 16
⾸先,可以通过以下命令查询机器最⼤⽀持的内存总量
[root@mysql ~]#dmidecode -t 16
# dmidecode 2.12
SMBIOS 2.5 prent.
Handle 0x0036, DMI type 16, 15 bytes
Physical Memory Array
Location: System Board Or Motherboard
U: System Memory
Error Correction Type: Multi-bit ECC
Maximum Capacity: 96 GB
Error Information Handle: Not Provided
Number Of Devices: 12
这⾥可以查看到当前服务器允许扩容的最⼤内存⼤⼩,从以上输出可知,该机器理论上⽀持的最⼤内存为96G。
然后使⽤以下命令查询机器可⽤的内存:
grep MemTotal /proc/meminfo
MemTotal: 32869848 kB
可以看到机器可⽤的内存为32G,也即我们可以再扩64G内存。
第三、查看当前内存数和插槽数
dmidecode|grep -P -A5 "Memory Device" |grep Size
[root@mysql ~]#dmidecode|grep -P -A5 "Memory Device" |grep Size
Size: 16384 MB
Range Size: 1 kB
Size: No Module Installed
Range Size: 1 kB
Size: No Module Installed
Range Size: 1 kB
Size: No Module Installed
Range Size: 1 kB
Size: No Module Installed
Range Size: 1 kB
Size: No Module Installed
Range Size: 1 kB
Size: 16384 MB
Range Size: 1 kB
Size: No Module Installed
Range Size: 1 kB
Size: No Module Installed
Range Size: 4032 GB
Size: No Module Installed
Range Size: 1 kB
Size: No Module Installed
Range Size: 1 kB
Size: No Module Installed
Range Size: 1 kB
1.查看内存槽数、那个槽位插了内存,⼤⼩是多少
[root@mysql ~]# dmidecode|grep -P -A5 "Memory\s+Device"|grep Size|grep -v Range
Size: 16384 MB
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: 16384 MB
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
第四、查看内存条数
但是在⽤的32G内存是怎么组成的?是1条32G内存?是2条16G内存?
我们可以通过以下命令进⾏查询:
dmidecode -t 17
No Module Installed 代表没有插内存条的槽
[root@mysql ~]# dmidecode -t 17
# dmidecode 2.12
SMBIOS 2.5 prent.
Handle 0x0038, DMI type 17, 27 bytes
Memory Device
Array Handle: 0x0036
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 79 bits
Size: 16384 MB
Form Factor: DIMM
Set: None
Locator: DIMM_A1
Bank Locator: BANK0
Type: DDR3
Type Detail: None
Speed: 1333 MHz
Manufacturer: Manufacturer00
Serial Number: D8CC0900
Ast Tag: AstTagNum0
Part Number: TS2GKR72V3H
Handle 0x0044, DMI type 17, 27 bytes
Memory Device
Array Handle: 0x0036
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 79 bits
Size: 16384 MB
Form Factor: DIMM
Set: None
Locator: DIMM_D1
Bank Locator: BANK2
Type: DDR3
Type Detail: None
Speed: 1333 MHz
Manufacturer: Manufacturer02
Serial Number: D8CC0900
Ast Tag: AstTagNum6
Part Number: TS2GKR72V3H
Handle 0x004E, DMI type 17, 27 bytes
Memory Device
Array Handle: 0x0036
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: Unknown
Size: No Module Installed
Form Factor: DIMM
Set: None
Locator: DIMM_F2
Bank Locator: BANK3
Type: DDR3
Type Detail: None
Speed: Unknown
Manufacturer: Manufacturer03
Serial Number: SerNum11
Ast Tag: AstTagNum11
Part Number: ModulePartNumber11
从红⾊部分,我们可以看到当前服务器是32GB内存,然后看到上⾯数据,可以知道该机器插了2根16G内存条第五、查看物理CPU信息
dmidecode -t 4
[root@mysql ~]# dmidecode -t 4
# dmidecode 2.12
SMBIOS 2.5 prent.
Handle 0x0004, DMI type 4, 40 bytes
Processor Information
Socket Designation: CPU 1
Type: Central Processor
Family: Xeon
Manufacturer: Intel
ID: C2 06 02 00 FF FB EB BF
Signature: Type 0, Family 6, Model 44, Stepping 2
Flags:
FPU (Floating-point unit on-chip)
VME (Virtual mode extension)
DE (Debugging extension)
PSE (Page size extension)
TSC (Time stamp counter)
MSR (Model specific registers)
PAE (Physical address extension)
MCE (Machine check exception)
CX8 (CMPXCHG8 instruction supported)
APIC (On-chip APIC hardware supported)
SEP (Fast system call)
MTRR (Memory type range registers)
PGE (Page global enable)
MCA (Machine check architecture)
CMOV (Conditional move instruction supported)
PAT (Page attribute table)
PSE-36 (36-bit page size extension)
CLFSH (CLFLUSH instruction supported)
DS (Debug store)
ACPI (ACPI supported)
MMX (MMX technology supported)
FXSR (FXSAVE and FXSTOR instructions supported)
SSE (Streaming SIMD extensions)
SSE2 (Streaming SIMD extensions 2)
SS (Self-snoop)
HTT (Multi-threading)
TM (Thermal monitor supported)
PBE (Pending break enabled)
Version: Intel(R) Xeon(R) CPU E5620 @ 2.40GHz Voltage: 1.2 V
External Clock: 133 MHz
Max Speed: 3600 MHz
Current Speed: 2400 MHz
Status: Populated, Enabled
Upgrade: Socket LGA1366
L1 Cache Handle: 0x0005
L2 Cache Handle: 0x0006
L3 Cache Handle: 0x0007
Serial Number: To Be Filled By O.E.M.
Ast Tag: To Be Filled By O.E.M.
Part Number: To Be Filled By O.E.M.
Core Count: 4
Core Enabled: 4
Thread Count: 8
Characteristics:
64-bit capable
Handle 0x0008, DMI type 4, 40 bytes
Processor Information
Socket Designation: CPU 2
Type: Central Processor
Family: Xeon
Manufacturer: Intel
ID: C2 06 02 00 FF FB EB BF
Signature: Type 0, Family 6, Model 44, Stepping 2
Flags:
FPU (Floating-point unit on-chip)
VME (Virtual mode extension)
DE (Debugging extension)
PSE (Page size extension)
TSC (Time stamp counter)
MSR (Model specific registers)
PAE (Physical address extension)
MCE (Machine check exception)
CX8 (CMPXCHG8 instruction supported)
APIC (On-chip APIC hardware supported)
SEP (Fast system call)
MTRR (Memory type range registers)
PGE (Page global enable)
MCA (Machine check architecture)
CMOV (Conditional move instruction supported)
PAT (Page attribute table)
PSE-36 (36-bit page size extension)
CLFSH (CLFLUSH instruction supported)
DS (Debug store)
ACPI (ACPI supported)
MMX (MMX technology supported)
FXSR (FXSAVE and FXSTOR instructions supported)
SSE (Streaming SIMD extensions)
SSE2 (Streaming SIMD extensions 2)
SS (Self-snoop)
HTT (Multi-threading)
TM (Thermal monitor supported)
PBE (Pending break enabled)
Version: Intel(R) Xeon(R) CPU E5620 @ 2.40GHz Voltage: 1.2 V
External Clock: 133 MHz
Max Speed: 3600 MHz
Current Speed: 2400 MHz
Status: Populated, Enabled
Upgrade: Socket LGA1366
L1 Cache Handle: 0x0009
L2 Cache Handle: 0x000A
L3 Cache Handle: 0x000B
Serial Number: To Be Filled By O.E.M.
Ast Tag: To Be Filled By O.E.M.
Part Number: To Be Filled By O.E.M.
Core Count: 4
Core Enabled: 4
Thread Count: 8
Characteristics:
64-bit capable
也可以⽤cat /proc/cpuinfo命令查看CPU信息。
第六、查看服务器硬盘信息
cat /proc/scsi/scsi
[root@mysql ~]# cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 01 Id: 00 Lun: 00
Vendor: LSI Model: Logical Volume Rev: 3000
Type: Direct-Access ANSI SCSI revision: 06 Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: SEAGATE Model: ST3300657SS Rev: 0008
Type: Direct-Access ANSI SCSI revision: 05 Host: scsi0 Channel: 00 Id: 01 Lun: 00
Vendor: SEAGATE Model: ST3300657SS Rev: 0008
Type: Direct-Access ANSI SCSI revision: 05 Host: scsi4 Channel: 00 Id: 00 Lun: 00
Vendor: TSSTcorp Model: CDDVDW SN-208BB Rev: AS01
Type: CD-ROM ANSI SCSI revision: 05
第七、dmidecode查看内存速率
dmidecode|grep -A16 "Memory Device"|grep 'Speed'
没插就是unknown。
[root@mysql ~]# dmidecode|grep -A16 "Memory Device"|grep 'Speed' Speed: 1333 MHz
Speed: Unknown
Speed: Unknown
Speed: Unknown
Speed: Unknown
Speed: Unknown
Speed: 1333 MHz
Speed: Unknown
Speed: Unknown
Speed: Unknown
Speed: Unknown
Speed: Unknown
第⼋、查看系统相关的硬件信息
dmidecode -t 1 = dmidecode -t system
dmidecode -t 1
# dmidecode 2.12
SMBIOS 2.5 prent.
Handle 0x0001, DMI type 1, 27 bytes
System Information
Manufacturer: System manufacturer
Product Name: System Product Name
Version: System Version
Serial Number: System Serial Number
UUID: 00797DF5-8DFE-D511-A89C-3085A9A895F8
Wake-up Type: Power Switch
SKU Number: To Be Filled By O.E.M.
Family: To Be Filled By O.E.M.
另外也可通过/proc查询CPU相关信息。
查询物理CPU个数:
[root@mysql ~]#cat /proc/cpuinfo |grep 'physical id'|sort|uniq|wc -l
2
查询CPU核数:
[root@mysql ~]#cat /proc/cpuinfo |grep 'core id'|wc -l