Updated: 28 September 2026 · Applies to: AlmaLinux and Rocky Linux 9 and 10, RHEL 9 and 10, Ubuntu 24.04 and 26.04, Debian 13 (x86_64)
Huge pages are memory pages of 2 MiB (or 1 GiB) instead of the normal 4 KiB. Large databases and some Java and virtualisation workloads run faster with them, because the CPU needs fewer address translations. This page covers static huge pages, which you reserve in advance for a program that asks for them, such as PostgreSQL with huge_pages = on, Oracle Database or DPDK. The automatic kind (Transparent Huge Pages) is described in how to disable Transparent Huge Pages.
1. Check the current state
grep -i huge /proc/meminfo
HugePages_Total is the number reserved, HugePages_Free how many are unused, and Hugepagesize the default size (2048 kB on x86_64).
2. Work out how many you need
Divide the memory the program will use for huge pages by the page size, and add a small margin. Example: a PostgreSQL shared_buffers of 8 GiB needs about 8192 MiB / 2 MiB = 4096 pages; PostgreSQL can tell you its exact need with postgres -D /var/lib/pgsql/data -C shared_memory_size_in_huge_pages (version 15 and later).
3. Reserve them now and permanently
sysctl -w vm.nr_hugepages=4200 echo "vm.nr_hugepages = 4200" > /etc/sysctl.d/90-hugepages.conf grep HugePages_Total /proc/meminfo
Reserved huge pages are taken away from normal use, even while unused. Reserve them soon after boot: on a long-running server, memory may be too fragmented to find enough contiguous 2 MiB blocks, and HugePages_Total then stays below the number you asked for.
4. 1 GiB pages
1 GiB pages must be reserved at boot, with kernel parameters (see how to change the kernel command line permanently):
default_hugepagesz=1G hugepagesz=1G hugepages=16
5. Let the program use them
- The program's user may need permission to lock that much memory: set
memlockin/etc/security/limits.d/for login sessions, orLimitMEMLOCK=infinityin the program's systemd service. - Programs that use huge pages through files need a
hugetlbfsmount; systemd already mounts one at/dev/hugepages. - Configure the program to use them, for example
huge_pages = oninpostgresql.conf, and restart it. AfterwardsHugePages_Freegoes down.
Common problems
- The program fails to start after enabling huge pages: not enough pages are free. Check
HugePages_Freeand increase the reservation. - Too little memory left for everything else: the reservation is too large. Lower
vm.nr_hugepages.
Official documentation: HugeTLB pages (Linux kernel).