Thursday, July 24, 2014

How to determine the actual size on disk for a folder in Windows

I am either confused as to how Windows calculates the Size on disk value in the properties of a folder, or it is incorrect.


The cluster size on my drive is 4096 byes.


I've created a folder called size-on-disk-test in which I have 64 direct sub-folders and 362,496 files. Each and every file is a text file 3 bytes in size simply containing the text: aaa.


Given each file should in theory use up a single cluster of 4096 bytes, then I should expect to see the file size on disk to read:


number-of-files * cluster-size362,496 * 4096 = 1,484,783,616 (1.4GB).


Instead it reads: 0:


size on disk properties


The Size is, as expected, exactly 3 bytes multiplied by the number of files.


I then made a note of the free space on my disk at the root level and duplicated the folder (this is not a drive with any activity or programs installed, so it should not be affected by other caching etc. on the disk during the test).


According to the check at root level (i.e. clicking properties on my drive in This PC) after duplicating the folder, my free space was reduced by 589,352,960 bytes.


So what is going on? Why is Windows reporting 0 bytes for the size on disk? Why are my calculations wildly off from the reality?


Additionally, does the length of the file name matter? Shouldn't this be taken into account in an accurate calculation? Perhaps the file name length puts a 4095 byte file into two clusters on a 4096 cluster disk? And surely folders take up some allocation space somewhere?


That's a lot of questions for one "question", but I'm hoping someone can just explain to me how the space is taken up including file names, folders and clusters.

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...