由于Centos系统为 kdump 服务预留了一部分内存导致服务器内存显示不足实际购买 4G
[root@VM_0_9_centos ~]# free -m
total used free shared buff/cache available
Mem: 3789 898 102 35 2788 2540
Swap: 0 0 0
停止kdump服务
停止并禁止自启动
[root@VM_0_9_centos ~]# systemctl stop kdump.service
[root@VM_0_9_centos ~]# systemctl disable kdump.service
修改grub文件
将crashkernel=auto 修改为crashkernel=0或删除
[root@VM_0_9_centos ~]# vim /etc/default/grub
`GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL="serial console"
GRUB_TERMINAL_OUTPUT="serial console"
GRUB_CMDLINE_LINUX="crashkernel=0 console=ttyS0 console=tty0 panic=5 net.ifnames=0 biosdevname=0"
GRUB_DISABLE_RECOVERY="true"
GRUB_SERIAL_COMMAND="serial --speed=9600 --unit=0 --word=8 --parity=no --stop=1"`
生成配置并重启
重启前注意无其他正在进行的工作,以免造成数据丢失
boot启动
[root@VM_0_9_centos ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
[root@VM_0_9_centos ~]# reboot
efi启动
[root@VM_0_9_centos ~]# grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
[root@VM_0_9_centos ~]# reboot
验证
减少了161MB内存
[root@nginx-server logs]# free -m
total used free shared buff/cache available
Mem: 3950 898 2502 32 550 2792
Swap: 0 0 0
其他
查看底层硬件信息,可以看到这台轻量云 4G 内存的服务器是分配足了 4096M 内存的。
[root@VM_0_9_centos ~]# dmidecode |egrep "Maximum|Size"
Runtime Size: 96 kB
ROM Size: 64 kB
Maximum Capacity: 4 GB
Size: 4096 MB
Range Size: 3584 MB
Range Size: 512 MB
Range Size: 3584 MB
Range Size: 512 MB
Reserving
[root@VM_0_9_centos ~]# dmesg | grep -i memory
[ 0.000000] Base memory trampoline at [ffff9f7000099000] 99000 size 24576
[ 0.000000] Early memory node ranges
[ 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] PM: Registered nosave memory: [mem 0xdfffe000-0xdfffffff]
[ 0.000000] PM: Registered nosave memory: [mem 0xe0000000-0xfeffbfff]
[ 0.000000] PM: Registered nosave memory: [mem 0xfeffc000-0xfeffffff]
[ 0.000000] PM: Registered nosave memory: [mem 0xff000000-0xfffbffff]
[ 0.000000] PM: Registered nosave memory: [mem 0xfffc0000-0xffffffff]
[ 0.000000] Memory: 4024148k/4718592k available (7664k kernel code, 524688k absent, 169756k reserved, 6055k data, 1876k init)
[ 0.000000] please try 'cgroup_disable=memory' option if you don't want memory cgroups
[ 0.024204] Initializing cgroup subsys memory
[ 0.556576] Freeing initrd memory: 18236k freed
[ 0.699529] Non-volatile memory driver v1.3
[ 0.702670] crash memory driver: version 1.1
[ 0.840195] Freeing unused kernel memory: 1876k freed
[ 0.845600] Freeing unused kernel memory: 516k freed
[ 0.848671] Freeing unused kernel memory: 600k freed
[ 1.579629] [TTM] Zone kernel: Available graphics memory: 2022702 kiB