# Kern.maxfiles



## rbizzell33 (Apr 26, 2010)

I am running Freebsd 8.0. and I am getting these maxfiles kernel errors. Where do I go to fix this and How do I increase this. I am running apache, mysql and moodle on the server.


----------



## SirDice (Apr 26, 2010)

> The kern.maxfiles sysctl determines how many open files the system supports.  The default is typically a few thousand but you may need to bump this up to ten or twenty thousand if you are running databases or large descriptor-heavy daemons.  The read-only kern.openfiles sysctl may be interrogated to determine the current number of open files on the system.



See tuning(7) and Handbook: Chapter 11.11 Tuning with sysctl.


----------



## rbizzell33 (Apr 26, 2010)

what is the correct syntax to use when editing the loader.conf file


----------



## SirDice (Apr 26, 2010)

Something like this:

```
kern.maxfiles="25000"
```


----------



## FBSDin20Steps (Apr 26, 2010)

etc/sysctl.conf is the file you need to edit. If I am not mistaken.


----------



## rbizzell33 (Apr 26, 2010)

don't edit the loader.conf and put the value inside quotes


----------



## SirDice (Apr 26, 2010)

@FBSDin20Steps and rbizzell33, kern.maxfiles can only be set before the kernel starts. Hence it must be set in /boot/loader.conf.



> LOADER TUNABLES
> Some aspects of the system behavior may not be tunable at runtime because memory allocations they perform must occur early in the boot process.  To change loader tunables, you must set their values in loader.conf(5) and reboot the system.


See tuning(7).


----------



## FBSDin20Steps (Apr 26, 2010)

Your correct...


----------



## rbizzell33 (Apr 26, 2010)

kern.maxfiles="25000"
This is the correct syntax right with the quotes


----------



## SirDice (Apr 26, 2010)

rbizzell33 said:
			
		

> kern.maxfiles="25000"
> This is the correct syntax right with the quotes



Yes, it was copy/pasted from my server :e


----------



## rbizzell33 (Apr 26, 2010)

I appreciate all your help. right now the loader.conf is empty now on my server. I just have all of the default values. So I need to input that change in the loader.conf and reboot the system


----------



## SirDice (Apr 26, 2010)

rbizzell33 said:
			
		

> I appreciate all your help. right now the loader.conf is empty now on my server. I just have all of the default values. So I need to input that change in the loader.conf and reboot the system



In /boot/loader.conf, yes. Do not edit or change /boot/defaults/loader.conf.


----------



## rbizzell33 (Apr 26, 2010)

Thanks! The reason why I ask because I edited that file but the change didn't take effect I guess I had the wrong syntax


----------



## FBSDin20Steps (Apr 26, 2010)

To be honest. I had kern.maxfiles in my sysctl.conf... must have copied in a blunt moment. I guess. :e


----------



## rbizzell33 (Apr 26, 2010)

Was it working when you put it in that file


----------



## FBSDin20Steps (Apr 26, 2010)

In what file?


----------



## rbizzell33 (Apr 26, 2010)

sysctl


----------



## FBSDin20Steps (Apr 26, 2010)

I am running 8.0-Stable for almost a year now and never noticed anything in performance.


----------



## rbizzell33 (Apr 26, 2010)

running the same version. I have two servers running that I was just asking what happened when you originally put those changes in the sysctl file. Did it change anything or it didn't work at all because it has to go in the loader.conf? On my other server that are both new hp ml 150 servers I noticed a lag when I type sometimes like it probably may not be tuned correctly.  I  am running postfix apache atmail mysql on that server. But on the one you have been helping me with that has apache mysql and moodle


----------



## FBSDin20Steps (Apr 26, 2010)

rbizzell33 said:
			
		

> I was just asking what happened when you originally put those changes in the sysctl file. Did it change anything or it didn't work at all because it has to go in the loader.conf?



Nothing happened. No error messages. No false entries in my logs... 'till SirDice came along and nothing happened after that.



			
				rbizzell33 said:
			
		

> On my other server that are both new hp ml 150 servers I noticed a lag when I type sometimes like it probably may not be tuned correctly.  I  am running postfix apache atmail mysql on that server. But on the one you have been helping me with that has apache mysql and moodle


DutchDaemon helped you a lot... I am not much on the forum.


----------



## rbizzell33 (Apr 26, 2010)

DutchDaemon You the Man I appreciate all your help Dutch.


----------



## FBSDin20Steps (Apr 26, 2010)

Would you like to support him financially?


----------



## rbizzell33 (Apr 26, 2010)

All you guys help me out. I really do appreciate you guys fast responses. One day hopefully I will be as knowledgeable as you guys


----------



## FBSDin20Steps (Apr 26, 2010)

Ah! That's better. Thanks man


----------



## rbizzell33 (Apr 26, 2010)

Do you run your servers for a business? I work for a k-12 school in the USA. I am just trying to get all this stuff under my belt. seem like it will take forever to learn all this stuff in Unix


----------



## FBSDin20Steps (Apr 26, 2010)

No, I don't run servers for a business. I am just a computer tinker.


----------



## SirDice (Apr 26, 2010)

I do run servers for a living, currently manage about 75 boxes. Mainly Solaris though, not FreeBSD 

You can see what your current maxfiles is using [cmd=]sysctl kern.maxfiles[/cmd]. Keep an eye on [cmd=]sysctl kern.openfiles[/cmd], if it regularly goes up, you may need to increase your maxfiles. Or you'll get kernel errors in your log


----------



## crsd (Apr 26, 2010)

SirDice said:
			
		

> @FBSDin20Steps and rbizzell33, kern.maxfiles can only be set before the kernel starts. Hence it must be set in /boot/loader.conf.



Where is it documented? I'm asking because changing kern.maxfiles after boot seems to work:

```
# sysctl kern.maxfiles
kern.maxfiles: 8008
# sysctl kern.maxfiles=25000
kern.maxfiles: 8008 -> 25000
# sysctl kern.maxfiles
kern.maxfiles: 25000
```


----------



## FBSDin20Steps (Apr 26, 2010)

Reading this should give you a clue.


----------



## crsd (Apr 26, 2010)

No clues in there, or I'm missing them.


----------



## SirDice (Apr 27, 2010)

crsd said:
			
		

> Where is it documented?


tuning(7)


----------



## crsd (Apr 27, 2010)

```
The kern.maxfiles sysctl determines how many open files the system supâ€
     ports.  The default is typically a few thousand but you may need to bump
     this up to ten or twenty thousand if you are running databases or large
     descriptorâ€heavy daemons.  The readâ€only kern.openfiles sysctl may be
     interrogated to determine the current number of open files on the system.
```

Can't find anything about kern.maxfiles being *READ-ONLY* anywhere in that manpage.


----------



## FBSDin20Steps (Apr 27, 2010)

My overall performance went a bit slower and applications became less responsive after applying "kern.maxfiles" to /boot/loader.conf. Guys aren't we mixing "kern.maxfiles" with "kern.maxusers"?


----------



## SirDice (Apr 27, 2010)

crsd said:
			
		

> Can't find anything about kern.maxfiles being *READ-ONLY* anywhere in that manpage.



It isn't. It seems I mixed up maxusers and maxfiles. Maxusers can only be set during boot and cannot be changed on a running system.

Blame it on my AD/HD induced dyslexia :\


----------

