Skip to content

How to Disable Transparent Huge Pages (THP) on Linux

Updated 2 min read

Updated: 28 September 2026 · Applies to: AlmaLinux and Rocky Linux 9 and 10, RHEL 9 and 10 (grubby, tuned), Ubuntu 24.04 and 26.04, Debian 13

Transparent Huge Pages (THP) let the kernel use 2 MB memory pages instead of 4 KB ones, which speeds up many programs. Some databases work better without them, and their documentation says so: for example MongoDB 7.0 and earlier, Redis, and Oracle Database. Only disable THP if your software asks for it: MongoDB 8.0 and later, for instance, asks for THP to be enabled.

1. Check the current setting

cat /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/defrag

The active value is in square brackets. An AlmaLinux 9 server we checked shows [always] madvise never: THP is used for all memory. Debian 13 kernels also default to always; Ubuntu 24.04 kernels default to madvise, where only programs that ask for huge pages get them. never switches THP off.

2. Switch it off now (until reboot)

echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag

Restart the database afterwards; memory it already uses keeps its huge pages.

3. Switch it off permanently

AlmaLinux, Rocky Linux and RHEL: add a kernel parameter to all boot entries, then reboot:

grubby --update-kernel=ALL --args="transparent_hugepage=never"
reboot

If the server uses the tuned service, make sure its active profile does not switch THP back on: check with tuned-adm active, and look for transparent_hugepages in that profile's tuned.conf.

Ubuntu and Debian: add transparent_hugepage=never to GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub, then run update-grub and reboot.

4. Check after the reboot

cat /proc/cmdline
cat /sys/kernel/mm/transparent_hugepage/enabled

The second command should show always madvise [never].

madvise instead of never

Setting transparent_hugepage=madvise is often the better compromise: applications that benefit from huge pages can still request them, while others, such as the database, are not affected. Check your software's documentation for its recommendation.

Official documentation: Transparent Hugepage Support (Linux kernel).

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Linux server management

hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.

Was this answer helpful?

Still stuck? Open a ticket