Tiny Core Linux

Tiny Core Base => TCB Talk => Topic started by: qopit on May 02, 2012, 10:00:59 AM

Title: How to increase the max # of open file descriptors?
Post by: qopit on May 02, 2012, 10:00:59 AM
How do you increase the hard limit on the maximum number of open file descriptors in Core?  Right now the hard limit is 4096 for me.  Where is this being set?

On other systems I've been able to adjust /etc/security/limits.conf, but that seems to be a "pam" thing, which is not in use with Core, and I don't see a pam extension (nor am I sure I want one).

With ulimit being a shell thing, I've been looking into busybox, but no luck so far.  Same goes for pam, which is a new thing for me.

Code: [Select]
tc@box:~$ cat /proc/sys/fs/file-max
50644
tc@box:~$ ulimit -Hn
4096
tc@box:~$ ulimit -Sn 4096
tc@box:~$ ulimit -n
4096
Title: Re: How to increase the max # of open file descriptors?
Post by: curaga on May 02, 2012, 10:17:31 AM
No support for a limits file in busybox, based on a quick look. The 4096 is a linux default, likely.

Only root can raise the limits, so if you need higher, set them as root and then switch user (su tc).
Title: Re: How to increase the max # of open file descriptors?
Post by: Rich on May 02, 2012, 10:47:20 AM
Hi qopit
Don't know if this helps, but there is an extension called   Linux-PAM.tcz   and under the  Files  tab in AppBrowser it lists:
Quote
usr/local/etc/security/limits.conf
Title: Re: How to increase the max # of open file descriptors?
Post by: qopit on May 02, 2012, 10:58:57 PM
Curaga: thanks!  I hadn't considered that root could change the hard limits and they would stick on an su.  Even the soft limit/setpoint carries through...

Code: [Select]
tc@box:~$ ulimit -Hn
4096
tc@box:~$ sudo su
root@box:~# ulimit -Hn 10000
root@box:~# ulimit -Sn 10000
root@box:~# su tc
tc@box:~$ ulimit -Sn
10000

For anyone else looking for this, this is very convenient for adding to bootlocal.sh (which runs with root privs) to run an application with more than 4096 possible open file descriptors.  Something like this works perfectly:

Code: [Select]
ulimit -Hn 65535
ulimit -Sn 65535
su -c "some_program" tc

Also, Rich: thanks for the PAM link... I feel like an idiot not finding it. :(
Title: Re: How to increase the max # of open file descriptors?
Post by: Rich on May 02, 2012, 11:19:37 PM
Hi qopit
Changing the Search option to Provides in AppBrowser and entering  pam  in the search field finds it quickly.
Title: Re: How to increase the max # of open file descriptors?
Post by: qopit on May 03, 2012, 06:11:58 AM
Rich: Big thanks for that, too... I didn't know ab had that "Provides" option either.  Now that I see provides.sh behind it, I'll definitely be using that more!

This is probably a consequence of me never using anything other than MicroCore/Core... I expect that the existence of the "provides" option is more prominent in the GUI version.  That's my excuse and I'm sticking to it.