Disable Transparent Huge Pages in Linux

Transparent Huge Pages (THP) is a Linux memory management system and needs to be disabled on several installations.

To check the current status of Transparent Huge Pages (THP), you can run the command:

cat /sys/kernel/mm/redhat_transparent_hugepage/enabled

This will give you 3 options, with the active selection surrounded by square braces. In the example below, the Transparent Huge Pages are set to always.

cat /sys/kernel/mm/redhat_transparent_hugepage/enabled
[always] madvise never

To disable Transparent Huge Pages (THP) temporarily, you can set the value of /sys/kernel/mm/redhat_transparent_hugepage/enabled to [never] by running the following command in the terminal:

echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled

This will disable Transparent Huge Pages (THP) until the server is restarted.

If you wish to make this change permanent, then add the following code to the /etc/rc.local file of your Linux server. The locations are based on a RedHat/CentOS based server.

# Disable Transparent Huge Pages
if test -f /sys/kernel/mm/redhat_transparent_hugepage/enabled; then
     echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
if test -f /sys/kernel/mm/redhat_transparent_hugepage/defrag; then
     echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag

Share your views