Storage

All about partitions: The right FAT can save your waste

When a 1-byte file can hog up to 32 KB of disk storage, it's no wonder they call it a FAT file system. In this Daily Drill Down, Brien Posey examines partitions and clusters, and he explains how to use your FAT to save space.

Many times, system administrators put a whole lot of work into planning every aspect of servers and workstations. Surprisingly often, they give little thought to the partition structure. However, taking some time to plan the partition structure of new servers and workstations can have a huge impact. For example, the way you establish your partitions can determine how quickly you’ll run out of hard disk space or how secure your system will be. In this Daily Drill Down, I’ll discuss some of the issues involved in partition planning.

What’s a partition?
A partition is a logical division of your hard disk that determines how the hard disk may be formatted. Before it can be formatted, at least one partition must exist. The partition provides the format program with the necessary information about the physical hard disk structure. Unless the hard disk has been partitioned, the format program will have no way of knowing things like how large the hard disk is or where to place the directory.

Partitions and formats
As I mentioned earlier, the hard disk must be partitioned before it can be formatted. However, the way that the hard disk is partitioned controls just how efficient the format will be. To fully understand why this is the case, you must understand the concept of clusters.

A cluster is an individual unit of storage on the hard disk. When you save a file to the hard disk, the file is saved in clusters. The hard disk can’t work with partial clusters. Therefore, even a 1-byte file occupies an entire cluster. The amount of space that’s wasted in such a situation is determined by the cluster size.

To illustrate this concept, consider the FAT16 file system. The FAT16 file system is limited to 65,536 clusters per partition. This limit is dictated by the 16-bit nature of the file system. Each bit is capable of holding one of two numbers, so taking the two possible values for each bit to the 16th power (for the 16 bits) produces 65,536, the number of available clusters.

Calculate the cluster size of your hard drive
Because you’re working with a fixed number of clusters, the cluster size must change with the size of the hard disk. To calculate the cluster size, simply take the size of the partition and divide it among the number of available clusters. For example, the maximum size of a FAT16 partition is 2 GB. To calculate the cluster size in bytes for a 2-GB partition, follow these steps:
  • Multiply 1,024 bytes (the size of a KB) by 1,024 to get the true (not rounded) number of bytes in one MB.
  • Multiply the result by 1,024 to get 1 GB.
  • Multiply by 2 to get 2 GB.
  • Divide the number that you’ve calculated by 65,536 (the total number of clusters). The result will be the byte count of the cluster size.
  • To see a more even number, divide by 1,024 to produce the final result of 32 KB. If this all sounds a little confusing, you can see a more traditional calculation below:

2 ^ 16 = 65,536 (total clusters)

1,024 bytes (1 KB) * 1,024 = 1,048,576 (1 MB)

1,048,576 (1 MB) * 1,024 = 1,073,741,824 (1 GB)

1,073,741,824 (1 GB) * 2 = 2,147,483,648 (2 GB)

2,147,483,648 (2 GB) / 65,536 (total clusters) = 32,768 (bytes per cluster)

32,768 (bytes per cluster) / 1024 (1 KB) = 32 (KB cluster size)

Cluster size limits
Because of the limitation on the number of clusters imposed by a 16-bit file allocation table (FAT) structure, and because only complete clusters can be used for file storage on a hard drive, there are a limited number of values for cluster sizes. You can see these values in Table A. Keep in mind that the maximum number of clusters may not always be used. For example, a 1-GB drive uses 32-KB clusters, just like a 2-GB drive does. This means that a 1-GB drive uses half as many clusters as a 2-GB drive, or 32,768 clusters.

Table A: FAT16 cluster sizes
Drive Size Cluster Size
256 MB – 511 MB 8 KB
512 MB – 1023 MB 16 KB
1024 MB – 2 GB 32 KB

As you can see, the smaller the partition, the smaller the cluster size. In addition, the smaller the cluster size, the less wasted space you have when a partial cluster is used. To see this concept in action, suppose you’re limited to using the FAT16 file system and you have a 1-GB hard disk. Let me illustrate the worst possible situation: a drive filled with 1-byte files.

They don’t call it FAT for nothing
Since even a 1-byte file occupies an entire cluster (32 KB in this case), each of the 32,768 clusters would waste 32,767 bytes. This means a total of 1,073,709,056 bytes wasted out of 1,073,741,824 bytes, or an astonishing 99.9 percent of the disk. Put another way, I’ve filled up an entire 1-GB hard disk with only 32,768 bytes of information.

Now, suppose I divided the drive into four 256-MB partitions instead of using one 1,024-MB partition. Doing so reduces the cluster size to 8 KB. Now, let’s imagine filling each of the four partitions with 1-byte files. This time 268,402,688 bytes out of 268,435,456 bytes are wasted in each partition. I’ve filled each partition with 32,768 bytes of information, but since I have four partitions, it takes 32,768 * 4, or roughly 131 KB, to fill up the disk. Not good, but it illustrates the point: Smaller partitions equal smaller cluster sizes equal less wasted space.

Of course, this isn’t exactly a real-world example. Rather, it’s a worst-case example on a small hard disk. If you want to see the concept in action in real life, take a 2-GB hard disk that’s formatted to use FAT16 and fill it with a variety of file sizes. When you’ve finished, convert the drive to FAT32. In the case of a 2-GB hard disk, this conversion reduces the cluster size from 32 KB to 4 KB. You’ll likely gain a very significant amount of space. In the past, I’ve gained anywhere from 30 MB to 200 MB from doing this conversion. The actual amount of space you’ll gain depends on the number and size of files on the hard disk.

Efficient FAT32
You may be wondering why FAT32 is so much more efficient than FAT16. FAT32 is more efficient than FAT16 because it uses a 32-bit cluster model. A FAT32 partition can have a maximum of 4,294,967,296 clusters. This means two things. First, it means that larger partitions are supported in FAT32 than in FAT16. It also means that on smaller partitions, the cluster sizes have been greatly reduced. You can see the breakdown in Table B.

Table B: FAT32 can support smaller cluster sizes.
  FAT16 FAT32
Partition Size Cluster Size Cluster Size
265 MB – 511 MB 8 KB Not supported
512 MB – 1023 MB 16 KB 4 KB
1,024 MB – 2 GB 32 KB 4 KB
2 GB – 8 GB Not supported 4 KB
8 GB – 16 GB Not supported 8 KB
16 GB – 32 GB Not supported 16 KB
>32 GB Not supported 32 KB

As you can see, FAT32 is much more efficient than FAT16. On larger drives, FAT32 eventually reaches the larger cluster sizes that are normally associated with FAT16. The concept remains the same, though: Smaller clusters mean less wasted space.

With the space savings of FAT32, it may seem foolish to ever use any type of partition. However, there are several different types of partitions that are specific to Windows operating systems. Each type of partition has advantages and disadvantages. Space limitations prevent me from discussing all the details of each type of partition. However, in the sections that follow, I’ll briefly outline the features of each type of partition used in Windows operating systems. You can find more articles on Windows file systems by searching TechProGuild.

FAT16
FAT16 is the oldest Windows partition in use. It’s supported by everything. Use FAT16 if you have to dual boot between multiple operating systems. The downside to FAT16 is its large cluster sizes and 2-GB partition limit, as I discussed earlier.

FAT32
FAT32 is simply a 32-bit version of the FAT16 file system. It supports reduced cluster sizes and offers support for much larger partitions than FAT16 does. FAT32 also has several safety features built in to prevent data loss during a hard disk crash and is designed to load programs faster than a FAT16 partition can. The downside to FAT32 is that not all operating systems support it. FAT32 can only be used with Windows 95 OSR2, Windows 98, Windows 2000, and eventually Windows ME.

NTFS
NTFS is a file system that’s specific to Windows NT. It uses a transaction-logging system that makes it much less susceptible to failure than FAT16 or FAT32. A transaction is a database technique that makes sure all changes to the database—in this case, NT’s file system tables—are successful before they are made permanent. Theoretically, you can create NTFS partitions up to 16 EB (EB stands for exabyte, which is one billion billion bytes, or a giga-gigabyte). NTFS is also designed to offer file system-level security. Each file on the partition may be assigned attributes that control who may access the file and what they may do with it (read, read/write, etc.) Because of the security that’s built into NTFS, only Windows NT and Windows 2000 can access an NTFS partition.

NTFS 5
NTFS 5 is specific to Windows 2000. It offers the same basic features as the Windows NT version of NTFS, with a few added benefits. For example, NTFS 5 supports features such as file-level encryption.

Conclusion
It’s clear that the file system, and the size of partition you choose, affects the storage efficiency of your machine. In this Daily Drill Down, I discussed how cluster and partition sizes affect file storage in FAT16 and FAT32 file systems, and I demonstrated how to calculate cluster sizes and wasted space. I also reviewed the file systems that the different Windows operating systems support.

Brien M. Posey is an MCSE who works as a freelance technical writer and as a network engineer for the Department of Defense. If you’d like to contact Brien, send him an e-mail. (Because of the large volume of e-mail he receives, it's impossible for him to respond to every message. However, he does read them all.)

The authors and editors have taken care in preparation of the content contained herein, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for any damages. Always have a verified backup before making any changes.
0 comments

Editor's Picks