Home Limit usable memory size in Linux
Post
Cancel

Limit usable memory size in Linux

In one case, I need to limit the usable memory size to 128GB from a system which has 1TB memory.

1
2
$ cat /proc/meminfo | grep MemTotal
MemTotal:       1056493068 kB

Edit /etc/default/grub file

Add “mem=128G” to the end of line “GRUB_CMDLINE_LINUX”.

1
2
3
4
5
6
7
8
$ cat /etc/default/grub
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=auto spectre_v2=retpoline rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet mem=128G"
GRUB_DISABLE_RECOVERY="true"

Generate new grub.cfg file

1
2
$ grub2-mkconfig -o /boot/grub2/grub.cfg
$ reboot

Verify the usable memory

1
2
3
4
5
$ cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-5.7.12-1.el7.elrepo.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto spectre_v2=retpoline rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet LANG=en_US.UTF-8 mem=128G

$ cat /proc/meminfo | grep MemTotal
MemTotal:       129486812 kB

Reference

This post is licensed under CC BY 4.0 by the author.

Install Golang from source

go-ycsb load db terminated with message 'Got signal [hangup] to exit'

Comments powered by Disqus.