LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 04-28-2011, 07:23 AM   #1
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Rep: Reputation: 45
Maximum number of files per folder


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?

Best Regards
Alex
 
Old 04-28-2011, 09:00 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400
Hi,

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).

Hope this helps.
 
1 members found this post helpful.
Old 04-28-2011, 03:16 PM   #3
wpeckham
Senior Member
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, Vsido, tinycore, Q4OS
Posts: 3,699

Rep: Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677
File and directotry limits

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)
 
Old 04-28-2011, 04:38 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 20,689

Rep: Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337
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.
 
Old 05-01-2011, 02:07 AM   #5
punitsolanki
LQ Newbie
 
Registered: Apr 2011
Posts: 5

Rep: Reputation: 0
Hi,

Yes there is a limit but not as per files its as per filesystem or partiion , its 4 TB for ext4 filesystem.

Punit
 
Old 05-01-2011, 02:56 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400
Hi,
Quote:
Originally Posted by punitsolanki View Post
Yes there is a limit but not as per files its as per filesystem or partiion , its 4 TB for ext4 filesystem.
You seem to have mixed size and amount for ext4:

- Max file size: 16 TiB
- Max number of files: 4 billion


But...... that was _not_ the question the OP asked. Maximum number of files per folder. Which has already been answered.
 
Old 05-01-2011, 03:26 PM   #7
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by jefro View Post
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.
32000? Are you sure its not 32767 (0x7FFF)?
 
Old 05-01-2011, 03:33 PM   #8
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400
Hi,

The correct number is 31998 (ext3, max sub-directories per one directory).

From Ext3 (wiki):
Quote:
There is a limit of 31998 sub-directories per one directory, stemming from its limit of 32000 links per inode.
The other 2? A directory starts with a link count of 2.
 
Old 05-01-2011, 05:38 PM   #9
jefro
Moderator
 
Registered: Mar 2008
Posts: 20,689

Rep: Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337
Dot and dot dot?
 
Old 05-01-2011, 11:08 PM   #10
punitsolanki
LQ Newbie
 
Registered: Apr 2011
Posts: 5

Rep: Reputation: 0
oh koool Thanks druuna
 
Old 05-02-2011, 03:48 AM   #11
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400
Hi,
Quote:
Originally Posted by jefro View Post
Dot and dot dot?
Dot, yes. Dot dot, no.

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 ..
Hope this helps.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find the total number of files in a folder cnm Linux - Newbie 18 08-25-2015 01:01 AM
[SOLVED] How to list folder size, and number of files and folders in folder steven.c.banks Linux - General 3 11-24-2010 06:24 AM
find the number of files in a folder swift2008 Programming 5 10-25-2010 03:22 AM
Maximum number of files in a directory neranjana General 14 05-13-2010 01:33 PM
Maximum number of files in a folder in Linux lionking_x Linux - Newbie 2 12-08-2007 10:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration