购买的服务器写的内存是 2GB,但是从宝塔看只用 1800 多 MB...
先用free
看一下:
total used free shared buff/cache available Mem: 1882000 422140 682784 776 777076 1283632 Swap: 1049596 40448 1009148
查看内核预留内存:dmesg | grep -i memory
[ 0.000000] Base memory trampoline at [ffff9eb200099000] 99000 size 24576 [ 0.000000] Reserving 161MB of memory at 688MB for crashkernel (System RAM: 2047MB) [ 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] Memory: 1858740k/2097008k available (7788k kernel code, 392k absent, 237876k reserved, 5954k data, 1984k init) [ 0.000000] please try 'cgroup_disable=memory' option if you don't want memory cgroups [ 0.331747] Initializing cgroup subsys memory [ 0.475802] x86/mm: Memory block size: 128MB [ 1.231809] Freeing initrd memory: 20320k freed [ 1.349328] Non-volatile memory driver v1.3 [ 1.352113] crash memory driver: version 1.1 [ 1.498955] Freeing unused kernel memory: 1984k freed [ 1.502904] Freeing unused kernel memory: 392k freed [ 1.505199] Freeing unused kernel memory: 536k freed [ 2.262990] [TTM] Zone kernel: Available graphics memory: 941000 kiB
crashkernel
保留了161MB
的内存,属于kdump
服务.
注意:kdump 是在系统崩溃、死锁或者死机的时候用来转储内存运行参数的一个工具和服务。打个比方,如果系统一旦崩溃那么正常的内核就没有办法工作了,在这个时候将由 kdump 产生一个用于 capture 当前运行信息的内核,该内核会将此时的内存中的所有运行状态和数据信息收集到一个 dump core 文件中以便于工程师分析崩溃原因,一旦内存信息收集完成,系统将自动重启。
停止并关闭kdump
systemctl stop kdump systemctl disable kdump
修改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 resume=UUID=XXXX-XXXX-XXXX-XXXX-XXXX" #改动此行 GRUB_DISABLE_RECOVERY="true"#请无视本行 GRUB_ENABLE_BLSCFG=true#请无视本行
更新grub
配置文件、重启系统
grub2-mkconfig -o /boot/grub2/grub.cfg reboot
你就会发现内存变多了..