Linux – Folder size is greater than 4K on ext3

ext3linuxls

Lets say we have a default formatted ext3 filesystem, I run under the assumption that folders take 4K of space on the disk.

But, what does it mean when a folder is bigger than 4K?

Here is a pic of one such folder: http://datanethost.net/stuff/puttysh.png
The only file was an .htaccess file that was a couple of bytes. I created a new directory, moved the .htaccess file into the new folder and delete the other weird folder and everything is fine again…but I just find it weird.

Can anyone explain this?

Best Answer

A directory starts off at 4K, but grows as it needs to store more file names. I'm pretty sure that it never shrinks again as those files are deleted. Something called "cache" might very well contain a lot of files, either now or at some time in the past.

As Stephen pointed out in the comments, once your cache directory grows large enough to hold, say, 10 000 files, then if those files are deleted it still has room to store 10 000 files, so if a new 10 000 files are created, the directory isn't going to grow again.