0

I need to increase the stack limit on Ubuntu 18.04 permanently, such that the new limit is in place for all users in all circumstances. Thus, setting in with ulimit -s ..., including in Bash profile and similar solutions, will not work for me. I tried:

  • Setting the limit in /etc/security/limits.conf. This had no effect. I tried setting both hard and soft limits, for root and my user. Restarted. Nothing changes.
  • Set DefaultLimitSTACK=32768 in /etc/systemd/system.conf and /etc/systemd/user.conf. 32768 is the desired stack limit in Kb. The window manager wouldn't load after restart, instead I was dropped into some kind of emergency root shell, where most commands segfaulted as well. I interpreted it as the stack limit being set to 32Kb instead of 32Mb as intended.
  • Set DefaultLimitSTACK=33554432 in /etc/systemd/system.conf and /etc/systemd/user.conf. The system loads normally, ulimit -s still shows 8192, nothing changed.

Could someone advise how to make this work? Thank you!

2 Answers 2

0

You can try writing a script(where you set the ulimit) in /etc/init.d/ directory.

Syntax of scripts in /etc/init.d/ - https://bash.cyberciti.biz/guide//etc/init.d

These scripts are executed while switching on and off the system [Specific function is called for start and stop].

1
  • ulimit is a Bash command that will only set the limit for the current shell session and its children. So it can't work, because the shell that executes init.d scripts doesn't start all other processes. Or does it? Please correct me if I'm wrong.
    – sor.rge
    Apr 9, 2019 at 17:26
0

Firstly systemd ignores parameters set in ulimits, see https://serverfault.com/a/678861

On my Ubuntu 18 system I'm using 16mb stack and set it in /etc/systemd:

user.conf:    DefaultLimitSTACK=16777216

system.conf:  DefaultLimitSTACK=16777216
  • System restart or log out of the session for the new settings to take effect. You can then use ulimit -s <value> to set your stack for the user's shell session at or below the DefaultLimitStack.

Additionally you can add ulimit -s 16384 into your user's .bashrc file. Then Each time its session is started the stack will be set to this desired value.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .