- Install prerequisites, e.g. on Ubuntu install the following packages:
$ sudo apt install build-essential linux-headers-generic
- Build kernel module
$ cd driver
$ make
- Create a group for users of hugepages, and retrieve its GID (in this example, 1001) then add yourself to the group.
$ sudo groupadd hugetlbfs
$ sudo getent group hugetlbfs
$ sudo adduser dasidler hugetlbfs
- Edit
/etc/sysctl.conf
and add this text to specify the number of pages you want to reserve (see page-size)
# Allocate 8192*2MiB for HugePageTables
vm.nr_hugepages = 8192
# Members of group hugetlbfs(1001) can allocate "huge" shared memory segments
vm.hugetlb_shm_group = 1001
- Create a mount point for the file system
$ mkdir /media/huge
- Add this line in
/etc/fstab
(The mode 1770 allows anyone in the group to create files but not unlink or rename each other's files.)
# hugetlbfs
hugetlbfs /media/huge hugetlbfs mode=1770,gid=1001 0 0
-
Reboot
-
Add the following line to
/etc/security/limits.conf
to configure the amount of memory a user can lock, so an application can't crash your operating system by locking all the memory.
@hugetlbfs hard memlock 1048576