# Folders - Are there limits?



## Uniden (May 25, 2010)

I am using FreeBSD 6.3 and I am wondering if there are any limits (NOT counting physical limitations of the hard drives) as to the amount of the folders that can be created.

I am working on an application that has the potential of creating tens of thousands of folders and I would like to know where the "ceiling" is..


----------



## SirDice (May 25, 2010)

AFAIK there are no limits. You may run out of inodes though.


----------



## DutchDaemon (May 25, 2010)

http://serverfault.com/questions/53416/max-total-files-in-a-directory-in-freebsd-6-ufs

If you code the app yourself, consider using a hash-type subdirectory mechanism (/a/a/a, /a/a/b) to avoid searches in immense directories. There's also a kernel option to mitigate performance loss due to huge directories (UFS_DIRHASH).


----------



## Zare (May 25, 2010)

For the n-th time...

Folders are GUI concepts that abstract data storage structures, mainly directories.
For instance, "Mail folder" can store raw e-mail data in separate files, master file, database table, etc, in the back-end.

Therefore, there aren't any folders in FreeBSD filesystem, those are *directories*.

I just love when yuppie companies (Microsoft / Apple) distort terms and coin new ones.


----------



## DutchDaemon (May 25, 2010)

BTW, note that the number of _subdirectories_ per directory appears to be limited to 32K, as the information on that URL suggests, whereas the number of _files_ is virtually unlimited (inside system limit parameters).


----------



## Uniden (May 25, 2010)

Thank you all!

Yes, of course I meant "directories". While also being a Windows user, I am using that vocabulary when I refer to UNIX stuff ..at least as often as I type "ls -al" in a Windows command prompt window. 

As for the choices I now have after looking at the DutchDaemon's link, it appears that creating a DIRECTORY with 40,000 files is better (in terms of inodes) than creating 10,000 directories with 4 files each. This way I do not need to worry about the 32K limit. BTW, the file count in each dir created by my app is always 4.

Again, thanks!


----------



## phoenix (May 25, 2010)

"folders" are the same as "directories".  They are synonyms.


----------



## gordon@ (May 26, 2010)

Zare, your pedantic reply only serves to alienate people. We are all new at some point.

Dutch, UFS_DIRHASH has been a default for quite a while (a couple of years I believe?)

It is still advisable to come up with a system to avoid putting tons of files in a single directory. Even with dirhash, it'll suck when it comes to performance.


----------



## DutchDaemon (May 26, 2010)

gordon@ said:
			
		

> Dutch, UFS_DIRHASH has been a default for quite a while (a couple of years I believe?)



Sure, it's been in GENERIC for quite some time. Haven't used GENERIC in years myself though  and I'm sure there are others who routinely remove options like that.


----------

