Is smallest file size 512 or 4096 bytes

H

hubbobubbo

Hi

I use a small routine that calculates CRC on files. This routine reads
in 4096 bytes at a time, I assume this is set as the smallest file size
(size on disk) available. This seems to be valid when I check a small
file in my Windows XP installation. However when I check my Windows
2000 installation the size on disk for a small file is only 512 bytes.

Both systems are installed with NTFS.

Can someone explain how this works, is 512 the smallest size on disk on
2000? Can there be other combinations for instance if you use FAT
instead of NTFS etc.

All comments appriciated.
 
S

Sven

You are confusing "cluster" size and "file" size.



File size is dynamic. The size of a file is determined by the application
which created the file. I have, for instance a MS Access database file that
is 1,216KB. My Pagefile file, created by the Operating system, is
1,570,904KB. Most icon (*.ico) files, on the other hand, are 1KB.



Cluster size is static. Cluster size is determined during the FORMAT
process.The number of clusters and the type of file system impacts minimum
and maximum cluster size.



End users have no input as to FAT cluster sizes, other than adjusting
partition sizes so that one's desired cluster size coincides with the
default cluster size.



End users have input as to NTFS cluster sizes.



Read:



Default cluster size for FAT and NTFS



http://support.microsoft.com/kb/140365/





Steve
 
R

Rick \Nutcase\ Rogers

Hi,

The Win2000 installation is probably formatted NTFS with 512byte clusters,
this often results from a conversion from a FAT32 volume. The norm in NTFS
is 4k (4096byte) clusters. The file size is independent of this, the cluster
size is merely an indicator of the minimum amount of space that will be
allotted to the storage of a file. So, if a file is 892bytes, it will still
occupy 4096bytes of space on the drive. The CRC utility is likely geared to
read the cluster size when validating the file, so this is why you are
seeing a difference.

--
Best of Luck,

Rick Rogers, aka "Nutcase" - Microsoft MVP

Associate Expert - WindowsXP Expert Zone

Windows help - www.rickrogers.org
 
A

Al Dykes

Hi

I use a small routine that calculates CRC on files. This routine reads
in 4096 bytes at a time, I assume this is set as the smallest file size
(size on disk) available. This seems to be valid when I check a small
file in my Windows XP installation. However when I check my Windows
2000 installation the size on disk for a small file is only 512 bytes.

Both systems are installed with NTFS.

Can someone explain how this works, is 512 the smallest size on disk on
2000? Can there be other combinations for instance if you use FAT
instead of NTFS etc.

All comments appriciated.



Per [1] files smaller than 1500 bytes may be stored in the $MFT table
which is created when the partition is formatted, so your file is
effectively using zero space, Since a record is created in the $MFT no
matter how big a file is. If a file fits into the $MFT no clusters
are allocated. If you turn file system compresson on you can fit more
data in each record (assuming your data is compressable). You'll also
never get fragmentation and opening a file will be very fast since a
seek is eliminated and probably the entire file is buffered.

ISTR that with the right tools, the $MFT size can be set when
formatting and that the $MFT expands dynamically.

There are lots of details I don't understand. Someone please correct
me if I'm off base here.

[1] http://www.ntfs.com/ntfs-mft.htm
 
M

Micky

Hi

I use a small routine that calculates CRC on files. This routine reads
in 4096 bytes at a time, I assume this is set as the smallest file size
(size on disk) available. This seems to be valid when I check a small
file in my Windows XP installation. However when I check my Windows
2000 installation the size on disk for a small file is only 512 bytes.

Both systems are installed with NTFS.

Can someone explain how this works, is 512 the smallest size on disk on
2000? Can there be other combinations for instance if you use FAT
instead of NTFS etc.

All comments appriciated.

This relates to cluster sizes, and is dependent on the file system and
the partition size. Essentially, a cluster is the smallest unit of disk
storage, and the larger the partition is, the larger the clusters need
to be. Different partitions on the same physical disk can have
different cluster sizes.

512 byte clusters typically apply to NTFS partitions < 0.5GB.
4096 byte clusters typically apply to NTFS partitions > 2GB <= 4GB.

Thus, if you have a file smaller than the cluster size, its physical size
remains the same, but its size on disk reflects the cluster size. That
is because no two files can share a cluster; any remaining space in the
cluster is considered "slack" or wasted space. Only the file using
the cluster can make use of this space.

Files that are larger than the cluster size use chains of clusters. If the
file isn't an exact multiple of the cluster size, then the final cluster in
the chain will contain slack.

It is generally good practice to place small files on small partitions
and large files on larger partitions. This not only reduces the amount
of slack, it helps speeds up access by ensuring files occupy as few
clusters as possible, thus reducing file fragmentation. Obviously you
can't organise every file in this way, but it makes perfect sense to
store small files such as icons on a small partition, and larger files
such as MP3s and videos on larger partitions.
 
K

Ken Blake, MVP

I use a small routine that calculates CRC on files. This routine reads
in 4096 bytes at a time, I assume this is set as the smallest file
size (size on disk) available. This seems to be valid when I check a
small file in my Windows XP installation. However when I check my
Windows 2000 installation the size on disk for a small file is only
512 bytes.

Both systems are installed with NTFS.

Can someone explain how this works, is 512 the smallest size on disk
on 2000?


Space is allocated on disk drives in units called clusters. The size of the
cluster varies with the file system, and sometimes with the size of the
partition.

If you're using NTFS, your cluster size is normally 4K. That means that
every file between 1 byte and 4096 bytes (size) uses one cluster, 4096 bytes
(size on disk). Every file between 4097 bytes and 8192 bytes uses two
clusters, 8192 bytes, and so on.

If, in Windows XP, you convert from FAT32 to NTFS, instead of the normal 4K
clusters, you usually get 512-byte clusters. I believe the same is triue of
Windows 2000, but I'm not sure.


Can there be other combinations for instance if you use FAT
instead of NTFS etc.


Certainly. For all partitions larger than 8GB, FAT32 has much larger
clusters than NTFS.
 
H

hubbobubbo

Thanks for all the great feedback.

Can I interpret it this way:

If I want the last "read" iteration of the CRC routine to get data up
to the very last byte of the file and I want this to be guaranteed for
all filesystems, then I must read 512 bytes in each loop. If I read
4096 on a system with cluster size 512 then there might be a rest that
I have to take care of that is somewhere between 512 and 4096 bytes.
Does this sound correct.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top