• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Size and size on disk?

What is the difference between size and size on disk in the properties of a file on the computer?


wGx1hvm.jpg



I have always wondered this.
 
A disk is divided up into allocation blocks. Each allocation block can only hold data from one file. A 1 byte file uses an entire allocation block, so its size (1B) is different than its size on disk. (Whatever the allocation block size is, probably 4kB.)

The difference between size and size on disk is the wasted space from the partially full allocation blocks.
 
NTFS has a minimum block size which is set when you format the disk, default of 4kb but it can be more or less. With 4kb blocks, anything smaller than 4kb takes up 4kb, and anything larger is rounded up to the nearest 4kb multiple to take up full blocks.

e.g. a 100byte text file would take up 4kb as that's the minimum size of a block. A 22kb file would take up 24kb as that's the nearest multiple of 4kb blocks (6) that it can take up.

If you had 16kb blocks, your 100byte text file would be 16kb, and your 22kb file would be 32kb.
A large number of small files will have a bigger discrepancy between size and size on disk than a small number of large files because of this. e.g. 100x1kb files would be 400kb (4kb each).
2x50kb files would be 104kb (52kb each).

It's a feature of how NTFS works and allocates blocks out to files.
 
I know it's because of the whole allocation blocks shenanigans, I've known that for a while, but I don't know why some files (such as the case on the OP screenshot) have such large disparities between the two values.

I have seen files with say 200kb have like 1MB of size on this. Wouldn't a file with 200kb on a 4kb per block disk have, at most, 204kb of size on disk?

I assume it's because of the fragmentation of the file.

But then again, why would such a small file be fragmented in the first place? Specially on a mostly empty drive (as was the case on mine, I seem to remember, at the time).
 
I have seen files with say 200kb have like 1MB of size on this. Wouldn't a file with 200kb on a 4kb per block disk have, at most, 204kb of size on disk?

it is as mentioned by the others, one cluster, only one file can be there. With 200KB of files (plural is to be noted), it could take 1 MB quite easily. Each of the files have a bit of extra space, not just a bit of extra space after all the files have been counted.

taking the approach of multiple small files of 1 byte, and a cluster size of 4K (so one cluster, one file), you could have a total amount of actual data of 1MB (1 million files) and end up with the amount of space being used of about 4 TB.

ie: remove those million small files and you can place 4TB of data in it's place.

There have been a few methods over the years to address this issue, and NTFS' 4K cluster size is one of the better ones. with earlier ones like FAT and FAT32, you could set the size to what ever you wanted, up to 64KByte cluster sizes IIRC (needed a hack, otherwise it was limited to 16 or 32KBytes per cluster).

Another way was to run drive compression, but while it worked for making use of that cluster space, it required overhead and data corruption could have resulted in most of the data on the drive being lost instead of just a few files.
 
Another way was to run drive compression, but while it worked for making use of that cluster space, it required overhead and data corruption could have resulted in most of the data on the drive being lost instead of just a few files.


I had used compression on my SSD and the speed of the drive was amazing! But after I restated I got a Bootmgr error or something like that as the boot files couldn't be read. So I pulled the drive out of the laptop, connected it to my desktop with a SATA to USB adapter to uncompress the drive. Forgot I had an ATA password on the damn drive. Jammed the drive back into the laptop, went into BIOS and removed the ATA password. Went back downstairs to where my desktop is located and finally was able to access the SSD and uncompress the damn SSD. Won't do that again!

Now I just right click on specific folders and chose to compress them, like the programs folder, Downloads, Music, Video, Pictures, etc. Touch the Windows folder and you are looking for trouble.

So it begs the question: Why is this option here for the whole drive?

eAiYk3J.jpg
 
Last edited:
Back
Top