Maximum number of files in a directory
Hi
Can anybody tell me how many files could be created in one directory? I just need a rough figure. 10,000? 1,000,000? 1,000,000,000,? Thanks Neranjana |
I would think it depends on your hard drive space actually. Most configurations if your using Linux use 4k inodes. So each directory or file at minimum would take up 4k of space by default.
So lets make it easy, doing some simple math and hopefully I did it right as its way to early, if you had a 2 GB partition using 4k inode allocations, you could fit 500,000 files on the partition. So your question I think is irrelevant to directories, it all depends on your drive itself, size of inodes and size of all the files, etc. Lets just put it this way, too hard to determine, so if it was a multiple choice quiz question, I'd choose: "Not enough information provided to answer" ;) |
i'm sure you can have as many files as you want in a directory. A directory is merely a file which stores information about the other files which are "within" it.
|
it also depends on the file system used, reiserfs can support a lot... others can only support a few ..
|
This is a question to trickykid.
Suppose I have ext3 and I have 80 GB partition. Suppose the size of the file is immaterial. (I would not run out of disk space.) But there are some problems. As you have mentioned, if it takes 4k to allocate a file then if I have say 100 files of the size of 10k then that would mean it would take 1MB for the files. Suppose this is not important. But the directory would take 4*100 k just to keep the info about the files, wouldn't it? I've heard that there is a limit of 4GB for a file in Linux. So it would mean that any directory could only be as big as 4GB (this is without the actual files inside it. Just the file names.) So it would mean that 4,000,000/4 would be the maximum number of files that a directory could keep inside it, wouldn't it? Am I on track or am I way off the mark? |
Quote:
|
The size of the files doesn't matter, the directory is a file which contains references to the files, so it just has to store the address for the file. (i think thats how it works anyway)
plus, everything is inside the / directory |
Actually as trickykid said no, you can have 3 files of 4GB in the same dir. Its actually a physical limitation. 4GB is the maximum of a 32bit system, because the maximum number you can write is 2^32 = 4 294 967 296
so you can't say I would like to request bit number 5 000 000 000, that number can't be sent over a 32bit bus. On a 64 bit system that barrier is lifted to a much higher value 2^64 There are two things you must consider when figuring the file system. The space a file use, its data part, and the commonly forgotten aspect that this file also need adressing in the file allocation table. There is usually a maximum number of file in a single directory, I know there is one in FAT16 and FAT32. I just dont know if there are in other filesystem. Maybe the way ext2, ext3, ext4 or reiserfs are build there is no such limit. |
Actually, what I would suggest doing is ... use a database, or databases. That's basically what you're doing anyway, but you're doing it the hard way. If you start running into the general vicinity of "a design limit," back off.
|
I almost bit on this too, but I reviewed the thread, saw the dates, and said "this is a really moldy oldie".
|
Quote:
Also this only applys to memory, not hard drive space, if that was the case everyone who didn't have 64bit systems would be limited to a 4096mb hard drive. Since this is not the case the amount of data on a harddrive is irreverent, even if it where, you could always limit the addressing to 32 or even 36bits and have a zillion bit addressing, it would be horribly slower, but can be done via look up table. See unreal mode programming, you basically enter 32bit addressing space save the memory table in the stack and return to 16bit real mode reload the stack and you are now using a 16bit mode with 32bit addressing...so now you have all the benefits of 32bit protected mode with the speed of 16bit real mode. but you can only access 64kb of memory at a time (not a huge deal for an assembly coder). |
JUST READ WIKIPEDIA! (read both ext2 and ext3, reiserfs, etc.)
All the answers are there! There is a LOT of misinformation in this thread (e.g. 4 GB max file size -- not true) |
Quote:
|
All of you act like wikipedia is so untrustworthy yet its so well maintained, i think you are more untrustworthy.
|
Quote:
The maximum is 392,471,693. And five eighths. With a cherry on top. /sarcasm It's not so simple as that: the number is different for every partition, and is equivalent to the maximum number of inodes for that particular partition, which depends on the file system type, file system size, and block size. Most people will run out of drive space before they run out of inodes, so this is rarely an issue. If it's that important to you, go read wikipedia and figure it out for yourself. I'm not going to try and summarize what's there because you are too lazy to do some research. If you have an unusual use case where you might potentially run into the limit, then you'll need to understand what wikipedia says on the subject anyway. You're a big boy, you can read and do math without my help. |
All times are GMT -5. The time now is 06:56 AM. |