LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   size of a blank file (https://www.linuxquestions.org/questions/linux-newbie-8/size-of-a-blank-file-4175483220/)

raj k yadav 11-03-2013 01:31 AM

size of a blank file
 
Why the size of a blank directory is 8K when the data block size is 4K.

[root@ pgsql]# ll /p05_old/pgsql/builderdb/
total 0
[root@pgsql]# du -sk /p05_old/pgsql/builderdb/
8 /p05_old/pgsql/builderdb/
[root@ pgsql]#

druuna 11-03-2013 02:23 AM

Quote:

Originally Posted by raj k yadav (Post 5057461)
Why the size of a blank directory is 8K when the data block size is 4K.

[root@ pgsql]# ll /p05_old/pgsql/builderdb/
total 0
[root@pgsql]# du -sk /p05_old/pgsql/builderdb/
8 /p05_old/pgsql/builderdb/
[root@ pgsql]#

Assuming an ext2/3/4 file system: I've answered a related question a few days ago: 4096

If you empty a directory these blocks are not reduced. This is a feature (or problem if you want) of the ext2/3/4 file system. The only easy way to reduce the amount of blocks assigned is to delete the directory and re-create it again.

Although I never used it myself the e2fsck command does have an option to optimize directories in file systems: the -D option. Do have a look at the man page for some extra information.


All times are GMT -5. The time now is 11:52 AM.