If I run cat /proc/sys/fs/file-max it returns a value over 3,000,000 - but I can't set ulimit to more than 1,000,000. If I try I get -bash: ulimit: open files: cannot modify limit: Operation not permitted
(I have tried modifying /etc/security/limits.conf, /etc/sysctl.conf, /etc/pam.d/common-session per other found documentation - but if I set these to higher numbers, then my ulimit just drops down to 1024). I have the same experience on Ubuntu 16.04.6 LTS and Ubuntu 18.04.4 LTS.
Is the ulimit value based on memory, cpu, disk size or other? What is the formula for determining the file max value?