Here's what happened when I created a new directory and immediately ran du on it. There are no contents in this directory.

me@mybox[~]$ mkdir /scratch/test2
me@mybox[~]$ du -sh /scratch/test2
4.0K    /scratch/test2

OK, so, a new directory in /scratch (which is a LV on sda which is running RHEL 6.6) takes up 4.0K of space.

me@mybox[~]$ mkdir /home/me/test
me@mybox[~]$ du -sh /home/me/test
512 test

A new directory in my home directory (which is an ZFS directory hosted via NFS from a Solaris server) takes 512 bytes. Now if I wait a minute or so and du /home/me/test again:

me@mybox[~]$ du -sh /home/me/test
1.5K     test

The amount of space taken jumps to 1.5K, despite the directory still being empty (as far as I can tell from ls -la)

I would like to understand the technical reasons for these differences. Just in general, like what is happening in the short span between the directory taking 512 bytes and 1.5K? What does that extra space signify? Why are both 512 bytes and 1.5K significantly smaller than the 4.0K required for a directory on the local disk?


You don't say what filesystem type is used for /scratch; I expect it's ext4. ext4 uses 4k blocks for allocation, so that's the smallest amount of space that a filesystem object can use (excluding zero-sized files, of course).

ZFS is quite a special filesystem and apparently uses 512-byte blocks for allocating space. Perhaps after you had accessed the directory some extended attributes were attached to the directory, increasing the space used by that directory. As it's an NFS-mounted filesystem there can be some buffering of attributes, perhaps if you looked at the data on the NFS server side then you might not see the change in size.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.