[CentOS] question about directory size in linux..

Thu Feb 23 00:06:35 UTC 2017
Robert Nichols <rnicholsNOSPAM at comcast.net>

On 02/22/2017 12:45 PM, Jason Welsh wrote:
> So its normal behavior.. thanks!
>
> Jason
>
>
>
> On 02/22/2017 01:40 PM, Gordon Messmer wrote:
>> On 02/22/2017 06:34 AM, Jason Welsh wrote:
>>> How does the directory *itself* have a size of 2.8 megs?
>>
>>
>> If you write a large number of directory entries in a directory, the directory will grow in order to provide storage for those directory entries.  You can imagine a directory as a text file containing all of the file names in the directory, with references to the location of those files, if that helps you understand why the directory itself will grow.

And for ext2/3/4 at least, an enlarged directory never shrinks. If the size gets really excessive (perhaps a rogue process created a huge number of files, which have since been deleted), you need to move everything you want to save to a new directory, remove the bloated directory, and then rename the new directory back to the old name.

You can also run e2fsck with the "-D" (optimize directories) option, but that acts on _all_ the directories in the filesystem and can take quite a long time.

-- 
Bob Nichols     "NOSPAM" is really part of my email address.
                 Do NOT delete it.