查看CPU信息:cat /proc/cpuinfo
查看硬盤信息:df -lh
查看內存信息:free -mios
在LINUX環境開發驅動程序,首先要探測到新硬件,接下來就是開發驅動程序。服務器
Dmidecodeapp
dmidecode以一種可讀的方式dump出機器的DMI(Desktop Management Interface)信息。這些信息包括了硬件以及BIOS,既能夠獲得當前的配置,也能夠獲得系統支持的最大配置,好比說支持的最大內存數等。ide
DMI有人也叫SMBIOS(System Management BIOS),這兩個標準都由DMTF(Desktop Management Task Force)開發。
dmidecode的輸出格式通常以下:ui
---------------------------------------- Handle 0x0002 DMI type 2, 8 bytes Base Board Information Manufacturer:Intel Product Name: C440GX+ Version: 727281-0001 Serial Number: INCY92700942 ----------------------------------------
其中的前三行都稱爲記錄頭(recoce Header), 其中包括了:rest
# dmidecode
這樣將輸出全部的dmi信息,你可能會被一大堆的信息嚇壞,一般可使用下面的方法。code
# dmidecode -q -q(--quite) 只顯示必要的信息,這個很管用哦。
一般我只想查看某類型,好比CPU,內存或者磁盤的信息而不是所有的。這可使用-t(--type TYPE)來指定信息類型:orm
# 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
數字參數支持不少:(見附錄)ci
好比只想查看序列號,可使用:
# 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, baseboard-manu-facturer,baseboard-product-name, baseboard-version, baseboard-serial-number, baseboard-asset-tag, chassis-manufacturer, chas-sis-version, chassis-serial-number, chassis-asset-tag, processor-manufacturer, processor-version. -------------------------------------------------------------------------------------
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 這裏顯示了當前服務器的物理內存是8GB。
服務器到底能擴展到多大的內存?
#dmidecode -t 16 # dmidecode 2.7 SMBIOS 2.4 present. Handle 0x0013, 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究竟是42GB, 24GB仍是其餘?
若是是4*2GB,那麼儘管能夠擴展到64GB,可是插槽已經插滿,沒法擴展了:
#dmidecode -t 17 # dmidecode 2.7 SMBIOS 2.4 present. Handle 0x0015, DMI type 17, 27 bytes. Memory Device Array Handle: 0x0013 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 0x0017, DMI type 17, 27 bytes. Memory Device Array Handle: 0x0013 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 0x0019, DMI type 17, 27 bytes. Memory Device Array Handle: 0x0013 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: 0x0013 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的最大支持內存。
附錄:
dmidecode支持的數字參數:
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 |
dmesg | more 查看硬件信息
對於「/proc」中文件可以使用文件查看命令瀏覽其內容,文件中包含系統特定信息:
Cpuinfo 主機CPU信息 Dma 主機DMA通道信息 Filesystems 文件系統信息 Interrupts 主機中斷信息 Ioprots 主機I/O端口號信息 Meninfo 主機內存信息 Version Linux內存版本信息