Limits and Systemd

When editing system limits in /etc/security/limits.d some of those limits do not apply to logged in users (but do to the root user if you su). If this occurs, you also have to add the change to the user configuration file under systemd (/etc/systemd/user.conf). For example, if you change the number of open file limit from the default you also need to update the DefaultLimitNOFILE value under systemd for the change to be applied on a user account when logging in.

In my case, I was modifying limits for a video game. To play it I had to set the vm.max_map_count to 16777216 and the open file descriptors to 524288. This required adding a file “/etc/sysctl.d/vm.conf” with the contents

vm.max_map_count = 16777216

Setting my nofile values in /etc/security/limits.d/12-nofile.conf to:

soft nofile 524288
hard nofile 1048576

And setting the DefaultLimitNOFILE in /etc/systemd/user.conf to 524288. Then rebooting my system.

About

Agathezol is a gamer, programmer, father, husband, and musician. When he's not writing blog posts nobody reads he generally writes protocol stacks, network code, and core telecommunications software but has dabbled in game design, web programming, mobile device software, and desktop software.

Categories: Linux