Take Control of Your Hard Disk Space

Now a days managing files and folders on PCs seems to be a critical task for network administrators and data storage managers due to huge capacity hard disks and millions of files and folders.

This article will help you in two ways

1. Understand the disk space allocation and wastage.

2. Understand how to manage your disk space.

Topics covered

What is File Allocation Table

The FAT is a roadmap, or index, that points to the location where all the information in files is stored on a floppy disk or hard drive. The FAT is extremely important because the system uses it to store and retrieve files containing information.

When you save a file in Windows, it is stored in multiple pieces (in clusters made up of multiple sectors) on the disk. Windows also saves the roadmap, or index, that points to these clusters in two copies of the FAT (File Allocation Table). The FAT contains the directions to all the pieces of your files, so that applications can find them again later

Disk Efficiency and FAT.

Every file on your system is stored in clusters in your hard drive, the maximum of one file can be stored in a particular cluster, so this results in wastage if the file is under the cluster size. The current FAT version (FAT16) organises files in 32K clusters in drives over 1.2gig, while FAT32 will use a minimum cluster size of 4K. This means that a 3K file wastes only 1K of disk space on FAT32, while it wastes 29K of space on a standard FAT system. This wastage can result in over 50% of a 2gig drive being wasted. See the table below.

What's a cluster and why does cluster size matter?

The whole problem of wasted space arises from the fact that DOS allocates file space in "clusters". Clusters are sequentially numbered on the disk, starting at 0, and cluster numbers are used both in the FAT (file allocation table) and in the individual directory entry for each file.

Allocation by clusters means some space on the disk will be wasted. Regardless of the actual length of a file as reported by the DIR command, the file will actually occupy a whole number of clusters on the disk. So a 1-byte file will actually use a whole cluster, a file that's 1 cluster plus 1 byte long will use 2 clusters, and so on.

Is this serious? It can be, depending on the pattern of file sizes on your disk. For instance, if you have an 2GB disk with 5,000 files on it, about 100 MB of your disk is being wasted. And the figures can be much worse, depending on the pattern of your usage. One user reported copying 450 MB of files to a 1.6 GB disk and having them take up 600 MB! As your disk approaches being full, you may wish you could squeeze some extra space out of it instead of buying a new disk.

How does cluster size depends on hard-disk size?

As mentioned above in the table the cluster size for various partition sizes so that you can make intelligent choices about how to partition your hard disk.

From the above table we see that even 2.1 GB drive is over the 1023 kilo-byte limit for 16 KB clusters and therefore its cluster size (unpartitioned) is 32 KB. With a 32 KB cluster, even a 1-byte file will use 32 KB of disk space. A file whose length is 32,769 to 65,536 bytes will likewise use two clusters (64 KB), and so on for higher file sizes.

Even so, you may be inclined to think this is no big deal. But think about it: if you have a 2.1 GB drive with 5,000 files, you're probably wasting about 160 MB.

How are cluster sizes determined?

Clusters are always some power of 2 times 512 bytes, but just which power of 2 depends on the disk size. Why should this be so? I mentioned above that clusters are numbered sequentially. The problem is that the directory structure and the FAT have room for only 16 bits for a cluster number. Since the largest unsigned number that will fit into a 16-bit field is 2^16-1 = 65535, the disk can hold at most 2^16 = 65536 clusters. This gives the formula

disk size
cluster size = ---------, rounded up to a power of 2
65536

In general the wasted space per file will be half a cluster.

-----

What is Wasted Space?

Whenever a file is created, space will be allocated to the file in the form of clusters. A cluster can be of 8 KB , 16 KB or 32 KB depending upon your hard disk partition size. Following is the chart for cluster size.

FAT FAT32
Partition Size Cluster Size Partition Size Cluster Size
128 - 256 MB
4 KB
1 - 8 GB
4 KB

257 - 512 MB
8 KB
8 - 16 GB
8 KB

513 - 1024 MB
16 KB
16 - 32 GB
16 KB

1025 - 2048 MB
32 KB
>32 GB
32 KB

So the formula for wasted space is Wasted Space = Allocated Space - Actual File Size.

We will take an example of file which is of 900 bytes in size and your partition type is - FAT and its size is 1024 MB. So the allocated space for your file will be 16384 bytes or 16 KB whether you store 900 bytes or 1 byte in the file. So the wasted space in this case will be

Wasted Space = 16384 - 900 = 15484 bytes.

So the conclusion is : Lesser the file size, more the wasted space.

Solution

So to analyze how our disk space is being wasted we need a smart program which will show us the space hogging files and their locations.

We are working with File system softwares since last 2 years. We have developed a powerful disk space analysis and cleaning software - DiskAnalyzer Professional 1.5 which allows you to take control of your disk space and reclaim gigabytes of lost disk space.

You can visit our website to get more information about the software http://www.craveworldwide.com

Manoj Shinde
Crave Worldwide, India.