echo 'c $ALLWRITE 1 3 1 1 hugepages/null' > /etc/makedev.d/01hugepages
2) tell udev to create it on boot if needed:
echo 'hugepages/null' > /etc/udev/makedev.d/52-hugepages.nodes
3) tell udev what the right permissions are for it:
echo 'KERNEL=="hugepages*", OWNER="root", GROUP="root", MODE="0775"' > /etc/udev/rules.d/52-hugepages.rules
4) Under CentOS/RHEL run “huge_page_setup_helper.py” to get your hugepages setup
5) Set the hugetlbfs to be mounted on boot:
echo 'hugetlbfs /dev/hugepages hugetlbfs defaults 0 0' >> /etc/fstab
That’s it! After a reboot, you can check that hugepages are setup with “sysctl vm.nr_hugepages” and “grep -i huge /proc/meminfo” and check that hugetlbfs is mounted with “mount | grep huge“.
Check /proc/meminfo once your KVM guests start to make sure the number of free pages decreases. If not confirm your guest’s XML file has “<memoryBacking><hugepages/></memoryBacking>” below the “<currentmemory>” section and that they have “-mem-prealloc -mem-path /dev/hugepages/libvirt/qemu” in the qemu-kvm command line (it should be auto-set by libvirt).