How do I make huge pages persistent after a reboot on Linux?
To keep huge pages available after a Linux reboot, save your huge-page reservation in a file under /etc/sysctl.d/. For XMRig, a common starting point is 1,280 pages of 2 MB each, but you should check the page size, available RAM, and XMRig’s startup report before treating that as the right setting for your machine.
Save the reservation permanently
Huge pages are larger chunks of memory than Linux normally uses. They can help XMRig run RandomX, Monero’s mining algorithm, more efficiently. This setting is for native XMRig running on Linux, not a browser miner.
First, check your system’s default huge-page size:
grep Hugepagesize /proc/meminfo
If it shows 2048 kB, each page is 2 MB. Reserving 1,280 of them takes about 2.5 GiB of RAM, which becomes unavailable for ordinary applications while reserved.
Create a persistent configuration file:
echo 'vm.nr_hugepages = 1280' | sudo tee /etc/sysctl.d/99-xmrig-hugepages.conf
Apply it without rebooting:
sudo sysctl --system
Here, sudo gives the command administrator permission. Linux normally loads these configuration files automatically during startup.
This is a starting point for a typical single-dataset setup. Machines with multiple memory regions, called NUMA nodes, or additional mining workloads may need a different reservation. Do not reserve most of your RAM on a small system.
Check it after a reboot
Reboot when convenient:
sudo reboot
After signing back in, run:
sysctl vm.nr_hugepages
grep -E 'HugePages_Total|HugePages_Free|Hugepagesize' /proc/meminfo
You want to see:
vm.nr_hugepages = 1280HugePages_Totalmatching your requested reservation.- A page size of
2048 kBfor the calculation above.
HugePages_Free shows how many reserved pages are currently unused. A lower number is normal if XMRig or another application already uses them.
Then start XMRig and inspect its startup output. Look for its huge-page allocation percentage, ideally 100%. A reservation alone does not prove XMRig successfully used it.
If Linux reserves fewer pages than requested
Huge pages need contiguous memory: physical RAM that is available in one uninterrupted chunk. Linux may struggle to find enough after other programs have started.
If the reservation remains incomplete after reboot, reserve pages earlier through your bootloader. On a system using GRUB, edit /etc/default/grub and append these arguments inside the existing kernel command-line quotes:
hugepagesz=2M hugepages=1280
Keep the existing arguments intact. Regenerate GRUB’s configuration using your distribution’s instructions, then reboot and check again. On Debian and Ubuntu, the regeneration command is usually:
sudo update-grub
Other distributions can use different commands and paths. These boot arguments reserve ordinary 2 MB huge pages; XMRig’s optional 1 GB pages are a separate configuration.
The bottom line
For most setups, /etc/sysctl.d/99-xmrig-hugepages.conf is the simplest persistent solution. Verify both Linux’s reservation and XMRig’s actual usage after reboot. If Linux has enough pages but XMRig cannot use them, investigate the reported permissions or service limits rather than reserving more RAM or routinely running the miner as administrator.
