2

I'm working on a reasonably large project, and recently had to bump the nofile setting above 500,000. I tried to change it to five million in /etc/security/limits.d/99-users-nofile.conf, but afterwards I was no longer allowed to log in. After seeing other people having the same issue I ended up booting from an alternative medium and changing the value back, but I'm none the wiser about what the actual maximum nofile value is.

4
  • 1
    See if this helps: linuxvox.com/post/… Commented Oct 24, 2018 at 4:51
  • @kevlinux As far as I can tell nofile is not related to file-max or file-nr in any way. If that's wrong can you please clarify what you mean? Commented Oct 24, 2018 at 7:38
  • What distro/version are you using? Sorry, I'm not familiar with the config file. The referenced link discusses the actual limitations and reasoning, which is what I was addressing. Commented Oct 25, 2018 at 3:18
  • Arch Linux. As far as I can tell the linked article discusses some other limitations, hence my comment. Commented Oct 25, 2018 at 3:20

1 Answer 1

-1

On my Ubuntu 20.04 the limit for nofile is (2^20):

*                hard    nofile          1048576

Oddly if I add 1 the number falls to 524288 (2^19).

This limit is per process. The total limit for all processes is 2^63-1:

$ cat /proc/sys/fs/file-max
9223372036854775807

The number of files currently opened is first column of:

$ cat /proc/sys/fs/file-nr
74144   0       9223372036854775807

On my server I have run:

ulimit -n 1048576
open_files() { perl -E 'for(1..'$1') { open($f{$_},"<","/dev/null") || die $_;} say "Done"; sleep 10000'; }
export -f open_files
seq 20000 | time parallel --nice 10 -uj0 open_files 30000

This runs with no problems and opens 600M files:

$ cat /proc/sys/fs/file-nr
600320672       0       9223372036854775807

So the practical limit is clearly higher.

1
  • 1
    That's just the current limit, not the system maximum. Commented Dec 22, 2020 at 1:02

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.