Wednesday, April 22, 2015

linux - Shrink/reset directory size?



Is there a way to shrink a directory entry?



My dovecot maildir directories have increased in size from the default 4096 to several megs, and it is messing with disk quotas.




The only way that I have found, is to delete and recreate the directory. I am hoping there is a magical function somewhere - I am open to anything, except for hand-coded assembler.



Edit:
For posterity, to find dirents>4096:



 find / -type d -size +4k -printf "%s\t%p\t%i\n" | sort -nr

Answer



See also rm on a directory with millions of files; tangentially related, but we discuss it there.




As far as I'm aware, at least on ext2/3, no, there's no (online) way to shrink them short of delete + recreate. Unmounted, several sources suggest e2fsck -D might work, though I can claim no personal experience with that option.



Some references for further reading:




No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...