Re: Shrinking ext3 directories

Padraig Brady
2002-06-18T16:22:13Z

DervishD wrote:
> Hi all :))
>
> All of you know that if you create a lot of files or directories
> within a directory on ext2/3 and after that you remove them, the
> blocks aren't freed (this is the reason behind the lost+found block
> preallocation). If you want to 'shrink' the directory now that it
> doesn't contain a lot of leafs, the only solution I know is creating
> a new directory, move the remaining leafs to it, remove the
> 'big-unshrinken' directory and after that renaming the new directory:
>
> $ mkdir new-dir
> $ mv bigone/* new-dir/
> $ rmdir bigone
> $ mv new-dir bigone
> (Well, sort of)

The zipdir component of fslint does this (while maintaining permissions
etc.).

> Any other way of doing the same without the mess?

Not at present I think. Perhaps we'll get it for free with
the new htree directory indexing?

Padraig.