I ran this on my CentOS 7.3 instance.
[user01@ ~]$ rm -rf my-very-own-directory/
[user01@ ~]$ mkdir my-very-own-directory/
[user01@ ~]$ stat my-very-own-directory/ | grep "Size"
Size: 6 Blocks: 0 IO Block: 4096 directory
[user01@ ~]$ mkdir my-very-own-directory/00
[user01@ ~]$ stat my-very-own-directory/ | grep "Size"
Size: 16 Blocks: 0 IO Block: 4096 directory
[user01@ ~]$ date > my-very-own-directory/date.txt
[user01@ ~]$ stat my-very-own-directory/ | grep "Size"
Size: 32 Blocks: 0 IO Block: 4096 directory
[user01@ ~]$ echo "content" > my-very-own-directory/content
[user01@ ~]$ stat my-very-own-directory/ | grep "Size"
Size: 47 Blocks: 0 IO Block: 4096 directory
- Initial creation => size = 6
- Add an entry with 2 bytes in name length => size is 16 (6 + 8 + 2)
- Add another entry with 4 bytes in name length => size is 32 (16 + 8 + 8)
- Add another entry with 7 bytes in name length => size is 47 (32 + 8 + 7)
2 Questions:
- A created directory has a size of 6. Why?
- Every new entry to the directory, be it file of a subdirectory will add to the size of 'my-very-own-directory'. The question is, the size increases by 8 + (length of the file name / directory name). Why 8?