LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Directory Size of etc, lost+found vs regular directory size. (https://www.linuxquestions.org/questions/linux-newbie-8/directory-size-of-etc-lost-found-vs-regular-directory-size-4175581656/)

dumblinuxuser 06-07-2016 08:59 AM

Directory Size of etc, lost+found vs regular directory size.
 
Hi

I am new to linux and have a question just by observation.
I understand that any directory when created has default size of 4096 however the directories such as etc, lost+found, dev have different sizes.

etc is 12288
lost+found is 16384

I have seen the size to be same irrespective of which distribution I use. Can someone help me understand why these directories have a different size.

Help much appreciated.

jpollard 06-07-2016 09:52 AM

Pretty much will be until /etc gets lots of configuration files added.

The size of etc (12288) is exactly 3 disk blocks (mine is too). Frequently services will put multiple configuration files in one directory (as ssh does) partly for consolidation (all relevant files are together), and partly for security (it makes it easy to check the files access modes easily). A directory entry doesn't need a lot of space, so 3 disk blocks might not change...

lost+found is a bit more special. It has 4 disk blocks "preallocated", and is normally empty. The pre-allocation is so that IF a filesystem check (fsck) detects lost files, there is somewhere to put them, without allocating blocks from a potentially corrupted free list (a "lost file" is identified by fsck as an inode that isn't referenced in any directory). With the current journalling filesystems, lost+found is almost always empty as the journal will normally contain the list of transactions that have been outstanding, and the list will be processed for the initial cleanup. SOMETIMES a system crash/power failure can still leave some thing out though...

By default a directory just created gets only 1 disk block, with only two entries (. and ..), so the rest of the block is unused.


All times are GMT -5. The time now is 04:13 PM.