In this article I will share the steps to disable Transparent Hugepage (AnonHugePages) using grub2-editenv command in RHEL 8 Linux.

Hugepages is a feature that allows the Linux kernel to utilise the multiple page size capabilities of modern hardware architectures. CPUs have a built-in memory management unit that contains a list of these pages, with each page referenced through a page table entry.

How to disable Transparent HugePage using GRUB2-EDITENV in RHEL 8


There are two ways to enable the system to manage large amounts of memory:

  • Increase the number of page table entries in the hardware memory management unit
  • Increase the page size

The first method is expensive, since the hardware memory management unit in a modern processor only supports hundreds or thousands of page table entries.

In Linux we use hugepages for this purpose where huge pages are blocks of memory that come in 2MB and 1GB sizes. The page tables used by the 2MB pages are suitable for managing multiple gigabytes of memory, whereas the page tables of 1GB pages are best for scaling to terabytes of memory


Disable TransParent HugePage in RHEL 8 (grub2-editenv)

In my earlier articles I have provided the steps to disable transparent hugepage on RHEL/CentOS 7. But with RHEL 8 the steps to update GRUB2 is different. Hence in this article I will use grub2-env to update the GRUB2 configuation. You can also use the traditional grub2-mkconfig to rebuild the GRUB2 configuration but those steps are explaine din my older article.

Before we start let us check the existing status of hugepage on our system.

[root@rhel-8 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never

So currently hugepage is enabled.

Next get the current kernel command line parameters.

[root@rhel-8 ~]# grub2-editenv - list | grep kernelopts
kernelopts=root=/dev/mapper/rhel-root ro crashkernel=auto resume=/dev/mapper/rhel-swap rhgb quiet

Here we must append transparent_hugepage=never at the end of kernelopts. This will modify kernelopts content in /boot/grub2/grubenv file.

[root@rhel-8 ~]# grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) transparent_hugepage=never"

Alternatively you can also give the entire section of kernelopts and just append transparent_hugepage=never as shown below: (ignore this command if you have executed above command)

[root@rhel-8 ~]# grub2-editenv - set "kernelopts=root=/dev/mapper/rhel-root ro crashkernel=auto resume=/dev/mapper/rhel-swap rhgb quiet transparent_hugepage=never"

Once added, verify the existing kernel options

[root@rhel-8 ~]# grub2-editenv - list | grep kernelopts
kernelopts=root=/dev/mapper/rhel-root ro crashkernel=auto resume=/dev/mapper/rhel-swap rhgb quiet transparent_hugepage=never

Next reboot the node to activate the changes

[root@rhel-8 ~]# reboot

Post reboot re-verify the transparent hugepage (AnonHugePages) status

[root@rhel-8 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]

Also check the following files to confirm that the transparent hugepage (THP) is disabled.

[root@rhel-8 ~]# grep AnonHugePages: /proc/meminfo
AnonHugePages:         0 kB

[root@rhel-8 ~]# grep nr_anon_transparent_hugepages /proc/vmstat
nr_anon_transparent_hugepages 0


Lastly I hope the steps from the article to disable transparent hugepage in RHEL 8 Linux was helpful. So, let me know your suggestions and feedback using the comment section.


Leave a Reply

Your email address will not be published. Required fields are marked *