How do I enable huge pages for Monero mining on Linux?
To enable huge pages for Monero mining on Linux, reserve some memory as 2 MB pages, then restart your miner and check its startup log. For a typical single-processor PC running XMRig, reserving 1,280 huge pages is a useful starting point, provided you have enough free RAM.
Why huge pages help
Linux normally divides memory into small pieces called pages, usually 4 KB each. Huge pages let software use larger pieces, reducing the work your processor does to keep track of memory.
Monero’s mining algorithm, RandomX, benefits from this. Its fast mode uses a dataset of about 2,080 MB, plus working memory. Huge pages can improve mining speed, but the gain depends on your hardware and setup.
These instructions apply to a native miner, such as XMRig, running directly on Linux. A browser-based miner generally cannot request Linux huge pages this way, so changing this setting does not guarantee faster mining in your browser.
Reserve 2 MB huge pages
First, check your current settings:
grep -E 'MemAvailable|HugePages|Hugepagesize' /proc/meminfo
Look for Hugepagesize: 2048 kB. The commands below assume that size.
On a typical PC with one memory node, reserve 1,280 pages:
sudo sysctl -w vm.nr_hugepages=1280
That reserves 2.5 GiB of RAM for huge-page use. This memory is no longer available for ordinary applications while reserved, even if your miner is stopped. Leave enough RAM for Linux and anything else you run.
Check the result:
grep -E 'HugePages|Hugepagesize' /proc/meminfo
HugePages_Totalshows how many pages were actually reserved.HugePages_Freeshows how many are not currently used.- If the total is below 1,280, Linux may lack enough suitable free memory.
After a machine has been running for a while, memory can become fragmented—split into scattered pieces. Reserving pages shortly after reboot often works better.
Enable and verify them in XMRig
XMRig normally enables huge-page support by default. If you edited its configuration, make sure its existing cpu section contains:
"huge-pages": true
Restart XMRig using your usual command or service. Check the startup output for a huge-page allocation result, ideally huge pages 100%.
A message saying huge pages are “supported” only means the feature is available. It does not prove that the miner successfully used them.
If allocation fails:
- Close memory-heavy applications and check the reserved-page count.
- Check whether another miner is already using the pages.
- Read any permission or memory-lock errors in the log. Service limits may need adjustment if you run XMRig through systemd, Linux’s service manager.
You do not need to run your miner permanently as root just to reserve memory; the sudo command above handles that administrative step.
Make the reservation persistent
To apply the setting at startup:
echo 'vm.nr_hugepages=1280' | sudo tee /etc/sysctl.d/80-monero-hugepages.conf
sudo sysctl --system
On multi-socket servers, NUMA means memory is grouped near particular processors. RandomX may need a separate dataset for each active NUMA node. A single global reservation may be insufficient or poorly distributed; check XMRig’s per-node allocation before increasing it.
To undo this configuration, stop your miner, then run:
sudo rm /etc/sysctl.d/80-monero-hugepages.conf
sudo sysctl -w vm.nr_hugepages=0
The bottom line
Reserve enough 2 MB pages, restart your native miner, and verify actual allocation in its log. Measure mining speed before and after, and avoid reserving so much RAM that your PC or server struggles with its other work.
