The size is 78 bytes because the directory is almost empty. With "directory" I mean the immediate descendant content of that folder, i.e., if you have
.../controllers/
Class1/Whatever
/Resources...
Class2/Whatever
/Resources...
then "controllers" only has three entries (.., Class1 and Class2. I do not know exactly whether or how .. is actually stored).
Even if, on disk, the directory will occupy one whole block, therefore 4K (but see below...), the directory logical size remains 78 bytes, and in many ways it is treated as a file (the XFS white papers refers to it as a directory file). If you create a new object immediately under controllers
, I expect that size to increment.
https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Performance_Tuning_Guide/ch07s03s02s02.html
Also, very small directories can be stored inside inodes, thereby occupying zero actual blocks:
Very small files
Most symbolic links and directory files are small files. XFS allows
these files to be stored in inodes for increased performance. XFS also
uses delayed writes to wait to gather the entire small file in the
buffer cache before writing to disk...
To recap, as far as I understand, you can have
Testing
The space available inside a XFS inode for a directory file seems to be around 156-157 bytes on my Linux system. When exceeded, a 4K block is used, but releasing space also releases the block, storing back the info into the inode.
mkdir temp
drwxr-xr-x 2 root root 6 2013-04-22 08:59 temp
touch temp/x; ls -la temp
drwxr-xr-x 2 root root 14 2013-04-22 09:00 temp
mv temp/x temp/{ 100 x's }
drwxr-xr-x 2 root root 113 2013-04-22 09:01 temp
{ 130 x's }
drwxr-xr-x 2 root root 143 2013-04-22 09:02 temp
{ 140 x's }
drwxr-xr-x 2 root root 153 2013-04-22 09:02 temp
{ 146 x's }
drwxr-xr-x 2 root root 4096 2013-04-22 09:03 temp
{ 142 x's }
drwxr-xr-x 2 root root 155 2013-04-22 09:03 temp
Here is a script displaying a human readable directory size using Unix standard tools (POSIX).
#!/bin/sh
find ${1:-.} -type f -exec ls -lnq {} \+ | awk '
BEGIN {sum=0} # initialization for clarity and safety
function pp() {
u="+Ki+Mi+Gi+Ti+Pi+Ei";
split(u,unit,"+");
v=sum;
for(i=1;i<7;i++) {
if(v<1024) break;
v/=1024;
}
printf("%.3f %sB\n", v, unit[i]);
}
{sum+=$5}
END{pp()}'
eg:
$ ds ~
72.891 GiB
Best Answer
It's the initial size necessary to store the meta-data about files contained in that directory (including names). The initial allocation equals the size of one sector, but can grow above that if necessary. Once allocated, space is not freed if files are removed, to reduce fragmentation.
For example:
source