Why is the size of a file different on disk?

Water Cooler v2

When we look at the size of a file in any file management software such as the Windows Explorer, we see two different sizes, one that reads just Size and the other reads Size on disk.

enter image description here

  1. Why are these two different?

    Does the size on the disk include some overhead such as its entry in the File Allocation Table (FAT)? Could you please elaborate?

  2. When we programmatically query the size of a file, it always returns the size independent of the disk size. Where does it get this number from? Does the OS have to read the contents of the entire file to determine this size or just look up the file allocation table?

Priyank

Found this on Super User. What he says:

We know that a disk is made up of Tracks and Sectors. In Windows that means the OS allocates space for files in "clusters" or "allocation units".

The size of a cluster can vary, but typical ranges are from 512 bytes to 32K or more. For example, on my C:\ drive, the allocation unit is 4096 bytes. This means that Windows will allocate 4096 bytes for any file or portion of a file that is from 1 to 4096 bytes in length.

If I have a file that is 17KB (kilo bytes), then the Size on disk would be 20.48 KB (or 20480 bytes). The calculation would be 4096 (1 allocation unit) x 5 = 20480 bytes. It takes 5 allocation units to hold a 17KB file.

Another example would be if I have a file that is 2000 bytes in size. The file size on disk would be 4096 bytes. The reason is, because even though the entire file can fit inside one allocation unit, it still takes up 4096 of space (one allocation unit) on disk (only one file can use an allocation unit and cannot be shared with other files).

So the size on disk is the space of all those sectors in which the file is saved. That means,usually, the size on disk is always greater than the actual size.

So the actual size of a file(s) or folder(s) should always be taken from the Size value when viewing the properties window.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Why is the size of a folder different when copied to a different location on the same disk?

From Dev

java Why file size is different with operation system

From Dev

Why is the same .class file of a different size?

From Dev

why is the same code size produce different size exe file

From Dev

Why different UIs display different size of the same file?

From Dev

Why do .ftl file are exactly same have different file size?

From Dev

Why is the difference in file size and it's size on disk bigger than 4 KiB?

From Dev

Why is there such a big difference between "Size" and "Size on disk"?

From Dev

why writing into file in binary format result in different size files?

From Dev

Why is the byte size different for a variable that contains 1472 byte of a file

From Dev

Why are there several modules in Perl with the same name but different file size?

From Dev

UWP Is the size of Roaming ApplicationData the file Actual Size or Size on Disk?

From Dev

Why do File Explorer and Disk Management show different amounts of free space, and how to resolve the discrepancy?

From Dev

why is there a limitation on hard disk size in MBR partitioning?

From Dev

Why is ls show file size different when changing block-size?

From Dev

Same file, different file size

From Dev

What's the smallest possible file size on disk?

From Dev

Is there a way to output file size on disk in batch?

From Dev

How to measure the size of a file without saving it on disk?

From Dev

How to see/determine on disk file size on Linux?

From Dev

Unable to increase disk size on file system

From Dev

Why webpage size is diffrent from saved (on disk) size?

From Dev

Why are two different hard drives listed as one disk in Disk Management?

From Dev

How to show actual size and allocated size on disk of a file in Ubuntu?

From Dev

File allocation size issue: Size on disk larger than expected

From Dev

File size is different in Windows and Ubuntu

From Dev

Carrierwave different size limits for different file types

From Dev

Why are the file formats different?

From Dev

Exact files (Copied) have a different size on disk on the same drive?

Related Related

  1. 1

    Why is the size of a folder different when copied to a different location on the same disk?

  2. 2

    java Why file size is different with operation system

  3. 3

    Why is the same .class file of a different size?

  4. 4

    why is the same code size produce different size exe file

  5. 5

    Why different UIs display different size of the same file?

  6. 6

    Why do .ftl file are exactly same have different file size?

  7. 7

    Why is the difference in file size and it's size on disk bigger than 4 KiB?

  8. 8

    Why is there such a big difference between "Size" and "Size on disk"?

  9. 9

    why writing into file in binary format result in different size files?

  10. 10

    Why is the byte size different for a variable that contains 1472 byte of a file

  11. 11

    Why are there several modules in Perl with the same name but different file size?

  12. 12

    UWP Is the size of Roaming ApplicationData the file Actual Size or Size on Disk?

  13. 13

    Why do File Explorer and Disk Management show different amounts of free space, and how to resolve the discrepancy?

  14. 14

    why is there a limitation on hard disk size in MBR partitioning?

  15. 15

    Why is ls show file size different when changing block-size?

  16. 16

    Same file, different file size

  17. 17

    What's the smallest possible file size on disk?

  18. 18

    Is there a way to output file size on disk in batch?

  19. 19

    How to measure the size of a file without saving it on disk?

  20. 20

    How to see/determine on disk file size on Linux?

  21. 21

    Unable to increase disk size on file system

  22. 22

    Why webpage size is diffrent from saved (on disk) size?

  23. 23

    Why are two different hard drives listed as one disk in Disk Management?

  24. 24

    How to show actual size and allocated size on disk of a file in Ubuntu?

  25. 25

    File allocation size issue: Size on disk larger than expected

  26. 26

    File size is different in Windows and Ubuntu

  27. 27

    Carrierwave different size limits for different file types

  28. 28

    Why are the file formats different?

  29. 29

    Exact files (Copied) have a different size on disk on the same drive?

HotTag

Archive