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.
1 Answer
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.
-
1That's just the current limit, not the system maximum.l0b0– l0b02020-12-22 01:02:45 +00:00Commented Dec 22, 2020 at 1:02
nofileis not related tofile-maxorfile-nrin any way. If that's wrong can you please clarify what you mean?