Windows file size and size on disk

Cluster Slack Space

You cannot access each individual byte on a storage medium separately. To do so would be terribly inefficient because the system needs some way of keeping track of which ones are used and which are free (i.e., a list), so doing so for each byte separately would create too much overheard (for each individual byte, i.e. 1-to-1, the list would be as big as the medium itself!)

Instead, the medium is broken up into chunks, blocks, units, groups, whatever you want to call them (the technical term is clusters), each of which contains a—consistent—number of bytes (you can usually specify the size of the clusters since different uses call for different sizes to reduce waste).

When a file is saved to disk, the size of the file is divided by the cluster size and rounded up if needed. This means that unless the filesize is exactly divisible by the cluster size, some of the cluster ends up being unused and thus wasted.

When you view the properties for a file, you see the true size of the file as well as the size it takes up on disk which includes any “slack”, that is, the “cluster tips” that are unused. This is usually not much per-file and the size on disk will usually be almost equal to the actual size, but when you add up the wasted space from all the thousands of files on a drive, they can add up. Therefore, when you view the size of a large folder, especially one with many tiny files that are smaller than a cluster, the size on disk (i.e., the amount of disk space marked as used) can end up being significantly larger than the actual size (i.e., the amount space the files actual require).

In a case like above, what you can try is to reduce the cluster size so that each file wastes less space. Generally, a drive with mostly lost of little files should use the smallest cluster size possible (to reduce waste) and a drive with mostly large files should use the largest cluster size possible (this way the bookkeeping structures end up being smaller).

Even at a lower level, if each cluster is only a single sector, unless a file is an exact multiple of the size of the sectors on the drive (usually 512 bytes traditionally, now often 4,096 with Advanced Format disks), then there will still be unused space between the end of the file and the end of the sector.

Compression

Another scenario where you might see a difference between the actual file size and size on disk is with compression. When a drive is compressed (e.g., using DriveSpace, NTFS compression, etc.) then there will be a difference between the size of the actual file (which needs to be know), and the actual size that the file occupies (i.e., uses or “takes up”) on the disk.

Shortcuts and Hardlinks

Yet another scenario that could result in a difference is with hardlinks. With file-systems that support hardlinks, when a duplicate file is created, instead of making a whole new file that takes up space for itself, the file-system creates a shortcut to the file so that both (or all three, etc.) copies point to the same physical file on disk. Therefore, when there are two files pointing to the same data, they each have the same size, but take up only slightly more than the space to store a single copy.

Have you ever wondered why Windows shows both Size and Size on Disk in the file and folder properties window? While both appear the same, there is a slight difference between Size and Size on Disk. Usually, the difference is a few bytes or kilobytes, and the Size on Disk will always be higher than the actual size. In fact, if you take a careful look at bytes in the properties window, you can see the difference.

size vs size on disk

In this article, let’s learn the difference between Size and Size on Disk and why Windows shows both in the properties window.

In simple terms, the “size” represents the actual size of the contents of the file or folder, and “size on disk” is the actual amount of space occupied by the file or folder including the file system’s allocation unit size and disk storage format. That is the reason why the Size on Disk is always more than the Size.

Here’s a more detailed explanation:

First of all, Size. It’s the straightforward one. It tells you the amount of space that file or folder’s content takes up. So, if you have a text document that’s 5 MB in size, that’s what it shows.

Size on Disk is a bit different from Size. It goes beyond the file’s content and takes into account the details such as the file system’s allocation unit size (cluster size) and the format of your storage disk. So, what is allocation size and why does it make “size on disk” bigger than “size”? Let’s break it down further.

Windows divides your storage into fixed-size chunks called allocation units or clusters. Each allocation unit or cluster is of a predefined size and depends on the file system. For example, the default cluster size of the NTFS file system is 4KB. That means each allocation unit is the size of 4KB. So, any time you save a file, Windows uses up a minimum of 4KB of storage space. Windows cannot further divide a cluster or save two different files in the same cluster. Any leftover space within a cluster is wasted and contributes to the larger “size on disk” compared to “size.”

For instance, if you are saving a 2KB text file, Windows uses 4KB of storage space because of the cluster size. That means the “size” of the file is 2KB and the “size on disk” is 4KB. So, the actual storage space used by the file is 4KB. The excess 2KB is wasted space. As another example, if the file you are saving is 10KB then Windows shows the “size” as 10KB and “size on disk” as 12KB (4KB multiplied by 3).

I hope this article helped you understand the differences between “size” and “size on disk.” I know it’s a bit confusing at first glance but all you need to remember is that “size” is nothing but the actual size of the file or folder contents whereas “size on disk” is the size of the file or folder contents plus the wasted size of allocation unit.

If you are stuck or need help, send an email, and I will try to help as much as possible.

Related tutorials:

  • How to extend partition using diskpart command
  • How to find large files in File Explorer
  • Useful File Explorer search syntax

size on disk vs. size

Many people claim that there is a significant difference between size vs size on disk, but why does this difference exist?

When people look at the properties of a folder, file, or drive they note that properties size and size on the disk are not the same and they get confused. When you see the size of the file on the properties page, it shows the actual file size.

On the other hand, the size on the disk indicates the total number of bytes occupied by a file on a hard drive. Mostly, both these values are very close, you will notice this difference after opening the properties of a folder or a file.

Here we explain why this difference exists and whether this should be a concern.

Acronis Cyber Protect

On this page:

  • Size vs Size on Disk
  • Why is there a difference between Size and Size on Disk
  • What are the reasons for a large difference between Size and Size on Disk?
  • How to decrease the difference between Size and Size on Disk?

Size vs Size on Disk

You can find out huge differences after understanding the central concept of both these terms. So, let’s explain both these terms individually.

What is meant by file size?

When you click on the properties of a folder or file, you get the value of bytes and size. This value is an indicator of the actual bytes and size in the file. The file size is used for the measurement of the data present in the storage device. This size is presented in the form of a byte.

See also: Data capacities – smallest to largest units of information

What is the meaning of file size on disk?

The size on the disk is the indicator of how much space a file occupies on the hard disk drive. When a file is stored in a modern storage device, it usually consumes slightly more storage than the actual file. That’s the reason why you see the difference between size vs size on disk. Check the screenshot below, and it will clear your basic concepts.

Size and Size on Disk

Why is there a difference between Size and Size on Disk

Now the question that comes in our minds is what factors affect this file size on disk. Obviously, it depends on how your file system stores file on the storage drive. A file uses different addresses and to reduce this file system treats the number of files as a single cluster. The capacity of file size not only decided by the maximum size of a file, but it is also determined by the number of bits reserved for the information of file size. For example, the maximum file size supported by the FAT32 file system is 4,294,967,295 bytes.

Usually, in the NFTS file system, the cluster sizes range from 512 Bytes to 64 KB. It doesn’t matter how small the actual file size is because when a file is written on the hard drive, it occupies a discrete number of clusters. For example, the size of a file is 1 KB, but you save it in a file system of 2 KB clusters, it will take up 2 KB size on disk.

Similarly, when you save the 1 KB file in the file system of 32 KB clusters, it will actually take up 32 KB on the disk. Now, it’s clear that the size of a file on disk will be bigger than the actual file size. Sometimes you may get surprised as well, but it will be an exception.

For example, you may encounter a situation is which size on disk will be smaller or equal to actual file size. Remember, it will happen only when you are using the automatic compression feature that you get from your operating system. This feature compresses the file so the size on the disk will be smaller than the actual file size.

There isn’t a vast difference between the size and size on disk, however many users have claimed that a significant difference between the actual file size and size on disk exists. So, let’s try to find out the reason why there is a massive difference between the two.

What are the reasons for a large difference between Size and Size on Disk?

A hard disk consists of sectors and tracks. When you are a Windows PC user, the operating system allocates disk space for cluster units. The file system of your storage drive set different cluster sizes that affect the size on disk.  When it comes to the considerable difference between size vs size on disk, you can check if there are lots of small files inside the folder and cluster size is large.

This difference will increase with the increase in the number of files because each file will waste the storage space of the drive. This size of wasted drive space keeps on adding and reaches a certain level; at that stage, the size on disk will be much larger than the actual size.

These situations occur when there are lots of small files in a folder. Along with the size on disk, it also depends on the cluster size of your file system. When you set a larger cluster size for disk, and you have a large number of files, more space will be wasted. Usually, the typical cluster size of a drive is 4 KB. For large files like games and 3D movies, you can choose 32 or 64 KB cluster size.

Acronis Cyber Protect

How to decrease the difference between Size and Size on Disk?

You can make the best use of storage devices when you manage the cluster size effectively. If you want to narrow down this vast difference, change the cluster size of the disk. You can use Windows built-in tools like Diskpart and Disk Management to change the cluster or allocation unit size. These tools can help significantly narrow down the differences between sizes.

People get confused when they see a difference in size and size on disk. It is because of the large number of small files and cluster size. Mostly the size on disk is much greater than the actual file size. Moreover, in some exceptions, this size can be less than the actual file size if your operating system uses the auto compression system. You can do this by using built-in tools mentioned-above. These tools create a partition and help reduce the allocation units and cluster sizes significantly.

I have a simple PowerShell script that makes a list of all files in a directory and prints that to a .txt file, as follows

$currentDir = 'C:\files'
Get-ChildItem $currentDir -Recurse -Force | ForEach-Object {
    $_.BaseName + "|" + $_.Extension + "|" + '{0:N2}' -f ($_.length/1MB) >> files_log.txt
}

However that only gets the size of the file. I want to get the size on disk of said file. The output should be something like:

BaseName | Extension | Size | Size_on_Disk
file | .pdf | 0.06 | 1.00
file2 | .mp3 | 0.30 | 1.00

I’ve searched but I only get results on how to get the sum of the sizes on disk for files within a folder. I haven’t found a proper way to access said property from ForEach-Object.

How can I get the Size On Disk parameter as seen in the properties of the file from PowerShell?

asked Apr 16, 2021 at 20:18

Jose Vega's user avatar

2

You could do some math tricks. According to this comment from here by DelphicOracle you could calculate it based on your drive’s allocation unit size.

function Get-SizeOnDisk {
    [CmdletBinding()]
    [OutputType([int64])]
    param (
        [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
        [string]
        $Path
    )

    process {
        $absolutePath = ($Path | Resolve-Path).Path
        $item = Get-Item $absolutePath
        $volume = Get-Volume $item.PSDrive.Name

        $d = [int][System.Math]::Ceiling($item.Length / $volume.AllocationUnitSize)
        return $d * $volume.AllocationUnitSize
    }
}

'myItem.ext' | Get-SizeOnDisk

Basically, you check how many times the Drive’s AllocationUnitSize fits in the actual length of the file, and if the division has a rest, you ceil it.

answered Apr 16, 2021 at 21:04

Vivere's user avatar

VivereVivere

1,9694 gold badges16 silver badges36 bronze badges

5

Size is the actual size of the file in bytes.

Size on disk is the actual amount of space being taken up on the disk. They differ because the disk is divided into tracks and sectors, and can allocate blocks of discrete size.

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.

  • Windows file recovery скачать торрент
  • Windows file recovery как пользоваться
  • Windows file recovery скачать бесплатно на русском
  • Windows file recovery microsoft store
  • Windows file protection windows xp