HashFlare

Tuesday, August 6, 2013

Size vs. Size on Disk

This is a question you probably don’t ask yourself too much, and hey, you probably will live your life without even considering asking it, but there will be times where this knowledge could be useful and at least this way you won’t be lost.

Size

Check that image, normally you wouldn’t care about the Size-SizeOnDisk relation, just a few KB of difference, but in this case these are 10.2GB of difference, so how to know? What the fuck are you going to do now? Well…

Let’s start from the beginning. When you format a disk (Hard Drive, Flash Drive, SSD, CD, Diskette…) you assign a File System (Fat, NTFS, Ext…) to it. The file system defines how the files are stored in your disk, and related to this article, the cluster size. The cluster size is, lets say, the minimum storage of your disk. Meaning that if I save a file of 1KB, if the minimum cluster size is 10MB, the Size of the file will be 10MB. A clean example can be seen here:

Size

Since NTFS has a 4KB cluster size, if the file goes over it, another cluster will be automatically filled with the extra and take 8KB of DISK SIZE, not actual Size. I actually think that this image can sum up the whole post… and thousands of post on other thousand sites.

Returning to the first image, why the fuck it’s so fucked? Well, because something awesome is happening there. For starters, the files where quite corrupted, they had a size of 0 bytes, but the system “thought” that the size was another one, and in some cases it though that the files were still there even after deletion. This happened to almost every single file on that folder. And the awesome part - yes I consider this awesome - the Size on Disk doesn’t care shit about the actual size; “133903 clusters were filled, each one is sized to 4KB, that is 535612KB, so the size should be around 523MB”… I found this very awesome.

Now, each file system has it’s own cluster size, aka, minimum file size, a quick example:

  • NTFS: From 1GB to 16TB, 4kB.
  • Fat32:
    • From 256MB to 8GB: 4KB
    • From 8GB to 16GB: 8KB
    • From 16GB to 32GB: 16KB

These are used for Windows, of course, there are a lot of different file systems, if you want to go nuts, enjoy.

Something to remember is that Size on Disk will vary from one file system to another (if their cluster/blocks size differ), but the file size should be the same (IF files and folders are not modified in any way). This also applies to CD/DVD/BRD, these have their own file system, and since is not that easy to explain in two lines, it’s better to use a CD burner to tell you how much will the file fill in the disk.

So, in conclusion…

Size

No comments:

Post a Comment