在一个 Oracle Linux 系统的 VPS 上面, 用 free 指令或检查 /proc/meminfo 系统内存都不正确, 在其他内存较多的主机没多大留意, 但在 1GB Ram 的 VPS 上发现这个问题。
用 free 指令得出以下结果:
$ free -m
|
1 2 |
total used free shared buff/cache available Mem: 687 214 139 6 333 363 |
可以看到只有 687 MB 内存, 于是用 dmidecode 指令查看硬件资讯:
$ sudo dmidecode -t memory
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# dmidecode 3.2 Getting SMBIOS data from sysfs. SMBIOS 2.8 present. Handle 0x1000, DMI type 16, 23 bytes Physical Memory Array Location: Other Use: System Memory Error Correction Type: Multi-bit ECC Maximum Capacity: 1 GB Error Information Handle: Not Provided Number Of Devices: 1 Handle 0x1100, DMI type 17, 40 bytes Memory Device Array Handle: 0x1000 Error Information Handle: Not Provided Total Width: Unknown Data Width: Unknown Size: 1 GB Form Factor: DIMM Set: None Locator: DIMM 0 Bank Locator: Not Specified Type: RAM Type Detail: Other Speed: Unknown Manufacturer: QEMU Serial Number: Not Specified Asset Tag: Not Specified Part Number: Not Specified Rank: Unknown Configured Memory Speed: Unknown Minimum Voltage: Unknown Maximum Voltage: Unknown Configured Voltage: Unknown |
可以看到内存是有 1GB 的, 但 free 指令便只有687MB.
用 dmesg 指令查�看开机信息:
$ sudo dmesg | grep -i memory
可以看到这句:
Memory: 261120K/1048040K available (12292K kernel code, 2244K rwdata, 9800K rodata, 2712K init, 15396K bss, 378628K reserved, 0K cma-reserved)
原来系统预留了 261MB 内存给 crashkernel, 在系统崩溃时使用。如果把 kdump 服务关闭, 系统便不会预留内存。