How to set HugePages in Linux Server

HugePages is a feature enabled into the kernel of Linux. By default you will have memory pages of size 4KB. But, Linux support memory pages of size greater than that. Using large page sizes improves the system performance. Especially, if you are going to use your server for Database then it is suggested to use large page sizes.

Set hugepages in Linux kernel
Set Hugepages in Linux kernel

In this tutorial I will explain how to see the HugePage size, total number of huge pages available on Linux server and how to modify the number of huge pages in kernel.

If you are on Linux server, you can check information about HugePages in meminfo file under /proc directory.

You can see from the above image that the Huge page size is 2MB. Now if you want to allocate more number of huge pages in your memory you can add below parameter into /etc/sysctl.conf file.

vm.nr_hugepages = 25 (example, you can add any number based upon the memory available)

Now, to make the changes in the kernel, you need to run sysctl -p command as a root user.
You can now check back in meminfo file under /proc to see the total number of huge pages has changed to 25.

About the Author: admin

You May Also Like

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.