The root directory of my ecryptfs filesystem has grown massively since I accidentally created many thousands of files in it. Now that I've deleted the files, I'd like to shrink the directory, as I believe it's causing some performance problems.

My home directory before the ecryptfs mount:

dr-x------ 2 ian ian 4096 May  4  2012 /home/ian

and after:

drwx------ 104 ian ian 42721280 Jun 18 13:46 /home/ian

https://serverfault.com/questions/264124/shrink-reset-directory-size discusses a similar problem with an ext3 filesystem, and suggests doing an e2fsck -D. However, ecryptfs doesn't seem to have its own fsck.

How can I shrink my directory without creating a new filesystem and copying everything over?

  • 1
    Have you checked that it's not in fact the underlying filesystem that has this directory size? – frostschutz Jun 18 '13 at 12:07
  • Yep -- have added details to the question. – Flup Jun 18 '13 at 12:50
  • 2
    You're comparing different directories. /home/ian/ (in ecryptfs) correlates to /home/ian/.ecryptfs/... (somewhere in the underlying filesystem). – frostschutz Jun 18 '13 at 14:31
  • Gah, you're right, I'd completely misunderstood how it works. I'd imagined ecryptfs as a big monolithic blob that gets mounted as a filesystem, whereas in fact there's a one-to-one mapping between encrypted and plaintext files. If you want to correct my stupidity in an answer, I'd be happy to accept it :) – Flup Jun 18 '13 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.