1

IIRC my Operating Systems classes, the size of a directory in Linux is given by the number of files it contains([wikipedia link])1

So, why a directory with only 2 files occupies 32000 blocks?

# stat .
  File: «.»
  Size: 16855040        Blocks: 32968      IO Block: 4096   directorio
Device: 6805h/26629d    Inode: 3047425     Links: 2
Access: (0775/drwxrwxr-x)  Uid: (  501/   jboss)   Gid: (  501/   jboss)
Access: 2011-08-26 12:00:20.000000000 +0200
Modify: 2011-08-26 10:58:07.000000000 +0200
Change: 2011-08-26 10:58:07.000000000 +0200

The directory may have had lots of files(thousands) at some point of the past, but not now. What's happening here?

0

2 Answers 2

2

Your directory has probably seen lots of action and the OS hasn't reclaimed the space that has been used. You can fix this by shuffling things around, if your directory that is using up all the space was called bigdir then you could

mkdir newdir
mv bigdir/* newdir
rmdir bigdir
mv newdir bigdir

Make sure that whatever accesses bigdir isn't going to while you do the shuffle.

1

The filesystem doesn't necessarily reclaim blocks from directories once they're no longer in use.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .