CentOS – How to Configure Hugepages on CentOS Stream 9

centoskvm-virtualizationqemu

I need to reserve 12288 hugepages for QEMU/KVM virtual machines.

I followed the guide in 3 easy steps to configure hugepages in RHEL/CentOS 7/8 but it looks like in CentOS Stream 9 the configuration file /etc/sysctl.conf is not for manual edit any more.

grep -i huge /proc/meminfo
AnonHugePages:   1986560 kB
ShmemHugePages:        0 kB
FileHugePages:         0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB

when I try to modify the file nano /etc/sysctl.conf
it shows that this setting moved in another place

# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).

What is the proper way of hugepages configuration in CentOS Stream 9?

Best Answer

Move vm.nr_hugepages from /etc/sysctl.conf into a .conf file with your choice of name. Of those, /etc is for site-specific persistent settings, so /etc/sysctl.d/hugepages.conf

Drop-in config files like this are easy to deploy. Can copy in files for very specific purposes, like a VM host or a database or a router, without touching other tuning. Managing half of a config file is actually tricky.

Reboot. Huge pages require contiguous memory.

Related Topic