[Wylug-help] Empty Directory is 1.2M

Nigel Metheringham Nigel.Metheringham at dev.intechnology.co.uk
Wed Apr 26 14:40:15 BST 2006


On Wed, 2006-04-26 at 14:17 +0100, Dan Walker wrote:
> $ ls -lha
> total 1.2M
> drwx------    2 vpopmail vchkpw 1.2M Apr 26 11:57 .
> drwx------  130 vpopmail vchkpw 8.0K Apr 26 14:08 ..
> 
> It's the 'cur' directory of a maildir - it was losing mail and eventually I 
> moved the weirdly-sized directories away and made new ones. We've tried 
> fscking the hard drive, and no change.

The size of a directory is basically the size of the directory entries
within it - each file/link/directory within it has an entry within the
directory (this is not the inode - its naming information).  Although
directory slots can be reused, they are not reclaimed, so if you have a
directory with a million files in it then the directory metadata size
(as seen by ls -d) (not the size of the directory contents) is going to
be a number of megabytes.  If you then delete all those files then the
directory size as seen by ls -d will still be several megabytes, but
creating new files in there will reuse the existing slots.

Reclaiming of directory slots is a filesystem dependant thing -
currently as far as I know ext3 can not reclaim them at all.

At present, under ext3 to reduce the directory size you have to create a
new directory, mv the contents of the original directory into the new
one, and rename both directories to put the new in place of the old.

There is an app - fslint - which apparently can do this for you.

On Wed, 2006-04-26 at 14:20 +0100, Graham Whaley wrote:
> What happens is somebody unlinks a file but still have a reference to
> the inode (ie. still has it open in an application) ?  A classic
> manouver for a temporary file.
>  Does anybody know who gets the space accounted?  Does it stay with
> the original directory, or get reparented somewhere ?

This is completely unrelated - the sizes being shown were for the
directory itself, not the content.
Disk accounting generally takes no notice of directories (think of files
linked into multiple directories) - instead its blocks for a uid.


	Nigel.
-- 
[ Nigel Metheringham           Nigel.Metheringham at InTechnology.co.uk ]
[ - Comments in this message are my own and not ITO opinion/policy - ]




More information about the Wylug-help mailing list