Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Dear all,
I would like to ask you if there is any maximum allowed number of files per folder in linux (without risking it to lose everything).
I am using openuse 11.4 with latest kde (4.6?).
I am trying something fast and dirty and it might be that one folder will contain like 10^6 files.
Is there is anything I should be warned about that?
I don't think there is a maximum number of files per directory, the maximum amount of files depends on the file-system used. Have a look here: Of filesystems and partitions
Depending on the FS there is a maximum amount of sub-directories you can create in one directory (31998 for ext3 for example).
If one million or more files in a directory is workable is another question, you might run into other (command) limits. For example: rm * might not work (argument list too long).
To be more precise, since we stopped using the old POSIX standard: OS limits on the number of files in a directory, the number of directories, or the size of files is irrelevant. The real restriction if from the File System limits. In some cases those are tunable to achieve different numbers, but the defaults are published.
Most of the limits would currently require someone do something VERY STUPID to approach on a small or home system. Personally, I cannot afford enough storage to even come close.
If you have more detailed questions you can post them here, but you may find the information faster through google using the key "FILE SYSTEM LIMITS and the name of your file system. (EXT4, EXT3, EXT2, JFS, XFS, REISERFS, etc)
I have always assumed a number of limits. Files per folder seemed to be one of them in all file systems but may be actually sub directories and files are considered the same.
As for ext3
^ The maximum number of inodes (and hence the maximum number of files and directories) is set when the file system is created. If V is the volume size in bytes, then the default number of inodes is given by V/213 (or the number of blocks, whichever is less), and the minimum by V/223. The default was deemed sufficient for most applications. The max number of subdirectories in one directory is fixed to 32000.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339
Rep:
Quote:
Originally Posted by jefro
I have always assumed a number of limits. Files per folder seemed to be one of them in all file systems but may be actually sub directories and files are considered the same.
As for ext3
^ The maximum number of inodes (and hence the maximum number of files and directories) is set when the file system is created. If V is the volume size in bytes, then the default number of inodes is given by V/213 (or the number of blocks, whichever is less), and the minimum by V/223. The default was deemed sufficient for most applications. The max number of subdirectories in one directory is fixed to 32000.
Any object in the file system must have a directory entry that connects it into the file system. For example, if you have a directory like "/tmp", there's a pointer in the root directory ("/") that points to the "tmp" directory entry. So that gives you one link.
Every directory contains the "." link that points back to itself. So that gives us the minimum value of 2 links per directory.
Every subdirectory has a ".." link that points back to its parent, incrementing the link count on the parent directory by one for each subdirectory created.
The .. (dot dot) entry points to (and increases) its parent!
Code:
cd /
ls -la /tmp
drwxrwxrwt 5 root root 4096 May 2 09:56 .
drwxr-xr-x 26 root root 4096 May 2 10:42 ..
mkdir /Foo
ls -la /Foo /tmp
/Foo:
drwxr-xr-x 2 root root 4096 May 2 10:45 .
drwxr-xr-x 27 root root 4096 May 2 10:45 ..
/tmp:
drwxrwxrwt 5 root root 4096 May 2 09:56 .
drwxr-xr-x 27 root root 4096 May 2 10:45 ..
rm -rf /Foo
ls -la /tmp
drwxrwxrwt 5 root root 4096 May 2 09:56 .
drwxr-xr-x 26 root root 4096 May 2 10:46 ..
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.