"size on disk" is zero for non-zero file in windows 8?
Asked Answered
P

2

10

I found there are some files on my disk, which
1) the real size is not zero, but it is small, around 500 bytes
2) the "size on disk" shows zero when you check its properties
3) if I make the file smaller, the "size on disk" is still 0
4) if I make the file bigger, even 1 bytes bigger, the size on disk will change to 4096
5) the disk is not compressed

How it is possible? My os is windows 8.1: Is this a new feature in windows 8?
Is windows 8 so smart that it can merge those small files into one disk sector?

Can anybody confirm this?

And if it is a new feature, how to disable it?

Pruett answered 10/4, 2014 at 16:41 Comment(0)
P
22

Files in NTFS consist of (at least one) file record in the master file record table (called MFT - each file record consists of attributes like name, file information, etc.) Data are usually located in one or more clusters on disk. The file record in the MFT contains references to those clusters (called a non-resident attribute). When the data size is really small, even its data are within the MFT record - the data attribute is resident. Thus NTFS doesn't have to allocate any clusters. Size on disk is the number of allocated clusters * size of a cluster, so if the data attribute is resident, size on disk is zero. If you reach the maximum size for the file record, the data attribute is made non-resident and NTFS allocates the first cluster, thus size on disk is 1 cluster - 4096 bytes.

Paulus answered 10/4, 2014 at 17:24 Comment(1)
Correct. The available space in an MFT record depends on the length of filename, the security attributes present, and other (usually rare) factors. In testing, the largest possible resident data is around 700–800 bytes with normal security and filename lengths.Safko
S
0

This is not specific to Windows 8 (so I modified your question). It is true of all NTFS managed by Microsoft's filesystem driver.

I can't imagine why you would want to disable this type of efficiency: it is a particularly excellent feature since many computer files tend to be small.

I have confirmed that NT versions up to XP NT do not move the data to the MFT record (and release the cluster(s)) if the file shrinks. So you could append some data to such files to make them at least 1024 bytes, and then truncate them back to the original size.

Safko answered 10/4, 2014 at 17:39 Comment(2)
I want to disable it because sometimes, I need to compare 2 directory, and make sure them exactly same. but this feature make that impossible. I can't control the size on disk for a file. a file is just 1 byte, but it use 4096 bytes on disk, but another file is 500 bytes, but size on disk is zero. it seems there is not a strict rule for size on disk property.Pruett
@MingDong How does the knowledge of file size on disk help you compare directories? It seems like actual file length would be more useful and more readily available information that you could use before resorting to binary comparisons.Plasterwork

© 2022 - 2024 — McMap. All rights reserved.