Enable huge pages in lxc container

Jul 18, 2018
26
5
43
20
Hi,
how can I enable huge pages on container? Need setup for DBs.

lxc-container~# sysctl -w vm.nr_hugepages=102400
sysctl: setting key "vm.nr_hugepages", ignoring: Read-only file system

Thanks
 
Hi,
how can I enable huge pages on container? Need setup for DBs.

lxc-container~# sysctl -w vm.nr_hugepages=102400
sysctl: setting key "vm.nr_hugepages", ignoring: Read-only file system

Thanks

Were you able to get this working?

I was able to enable huge pages in an LXC container for PostGres, by setting vm.nr_hugepages on the proxmox host itself. I also disabled Transparent Huge Pages on the proxmox host, via grub cmdline options.

You can watch cat /proc/meminfo on host (shows identical reading out lxc) to monitor huge page allocation.
 
Were you able to get this working?

I was able to enable huge pages in an LXC container for PostGres, by setting vm.nr_hugepages on the proxmox host itself. I also disabled Transparent Huge Pages on the proxmox host, via grub cmdline options.

You can watch cat /proc/meminfo on host (shows identical reading out lxc) to monitor huge page allocation.
Hi, yes - I did exactly what you describe (file /etc/sysctl.conf on the Proxmox server itself)... Thanks
 
Apologies for replying to a thread from 2022, but I'm fighting with the very same issue here...

I also need to enable huge pages for PostgreSQL 16 in a Proxmox container, managed to enable it on the host via kernel cmdline parameters and I can see the hugepage reservation in /proc/meminfo on both the host and within the container. Unfortunately, PostgreSQL itself is unable to use them by default, and enforcing their use via the huge_pages = on config value prevents PostgreSQL from starting as it's unable to allocate hugepages at all (it wants to do so via shared memory, not mmap). From the kernel docs it seems it's required to grant a given group rights to allocate shm hugepages and I set it to the postgres group running within the unprivileged container (GID 107 remapped to subGID 100107 on the host, so sysctl.d -> vm.hugetlb_shm_group=100107), but still no dice. Did you test whether the database within the container was able to start using them correctly?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!