西数超哥博客
运维经验教程分享

CENTOS8 内存显示和实际硬件内存大小不符

在一个CentOS8系统的VPS上,free显示不对,有1G内存但是只显示了818MB,少了200多MB

              total        used        free      shared  buff/cache   available
Mem:            818          87         453           7         277         597
Swap:          1023           0        1023

1、使用dmidecode命令查看linux硬件信息
dmidecode -t memory

# 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: Red Hat
	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,Size: 1 GB2、查看内核预留内存
dmesg | grep -i memory

[    0.000000] kexec: Reserving the low 1M of memory for crashkernel
[    0.000000] Reserving 160MB of memory at 688MB for crashkernel (System RAM: 1023MB)
[    0.000000] Early memory node ranges
[    0.000000] PM: Registered nosave memory: [mem 0x00000000-0x00000fff]
[    0.000000] PM: Registered nosave memory: [mem 0x0009f000-0x0009ffff]
[    0.000000] PM: Registered nosave memory: [mem 0x000a0000-0x000effff]
[    0.000000] PM: Registered nosave memory: [mem 0x000f0000-0x000fffff]
[    0.000000] Memory: 226252K/1048040K available (12292K kernel code, 2151K rwdata, 3848K rodata, 2404K init, 6476K bss, 239948K reserved, 0K cma-reserved)
[    0.016690] Freeing SMP alternatives memory: 32K
[    0.019298] x86/mm: Memory block size: 128MB
[    0.431178] Freeing initrd memory: 23456K
[    0.584810] Non-volatile memory driver v1.3
[    0.690726] Freeing unused decrypted memory: 2040K
[    0.691583] Freeing unused kernel memory: 2404K
[    0.695208] Freeing unused kernel memory: 2020K
[    0.695282] Freeing unused kernel memory: 248K

原来是为crashkernel保留了160MB的内存,属于kdump服务。kdump服务是在系统奔溃时生成内核转储文件。

3、停止kdump服务
systemctl stop kdump
systemctl disable kdump

4、修改grub文件
vi /etc/default/grub
将crashkernel=auto改为crashkernel=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=0 net.ifnames=0 biosdevname=0 rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true

5、更新grub配置文件、重启系统
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot

6、内存增加了160MB

              total        used        free      shared  buff/cache   available
Mem:            978          84         718           8         175         751
Swap:          1023           0        1023
赞(0)
声明:本站发布的内容(图片、视频和文字)以原创、转载和分享网络内容为主,若涉及侵权请及时告知,将会在第一时间删除。本站原创内容未经允许不得转载:西数超哥博客 » CENTOS8 内存显示和实际硬件内存大小不符

登录

找回密码

注册