Hard Disk Partitioning

How and Why (or Why Not)
for MS-DOS/Windows PCs

revised 20 Apr 2002
Copyright © 1996–2004 Stan Brown, Oak Road Systems

Summary:  This page explains reasons why you might want to partition your hard disk, and reasons why you might not want to. If you decide to proceed, it shows you how to partition your disk without buying more software. Primary relevance is to Windows 9x, as opposed to Windows NT and its successors.

Apology:  This page was originally written in the days when Windows 3.1 was the cutting edge of new technology. While I have updated it considerably since then, it's definitely showing its age. But every time I remove it, I get a lot of e-mail requests to bring it back, so here it is. My thanks to Sandy Archer for giving it Web space.
 
I can't help with questions about specific models of hard drive and specific operating systems. Your best bet is to post a question to the Usenet newsgroup that deals with your specific hardware or operating system.

Contents: 

You're welcome to print copies of this page for your own use, and to link from your own Web pages to this page. But please don't make any electronic copies and publish them on your Web page or elsewhere.

And for the litigious among us: The information here is offered without warranty of any kind. Sigh.


Does this information apply to my hard disk?

The information in this article about cluster size applies to uncompressed hard-disk partitions on MS-DOS, MS-Windows 3.x, and MS-Windows 95 or 98 using FAT16.

In the following situations, cluster size is not a worry, though you may want to partition your hard disk for other reasons:


Why repartition a hard disk?

I can think of six reasons: That last reason is the one that applied to all of us before FAT32, and the effects can be dramatic. For example, partitioning my own 1080 MB drive increased its effective capacity by almost 18 percent under Win 3.x and later under Win95.

Some users prefer disk compression utilities like DoubleSpace. Such programs will probably save you more space than partitioning your disk. But I'm a suspicious sort and don't trust any compression program more complicated than ZIP; I've heard enough reports of problems with the disk compression software to make me stay away from it.

ZIP and UNZIP from Info-ZIP are freeware (not shareware). File formats are identical to PKZIP format. You can download copies from the Info-ZIP home page at <http://www.info-zip.org/pub/infozip/>.)


Why not repartition a hard disk?

It is not necessary to install Windows 95 in a separate partition from DOS 6.x/Win 3.x. The Win95 installation procedure will give you the option of installing Win95 without overwriting your previous version of DOS. This works just fine, and in fact it's how I used to have my system set up.

What's a cluster and why does 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. You can read the math in appendix 2 if you like, but the bottom line is that, on average, an average file will waste an amount of space on your hard disk equal to half a cluster.

Is this serious? It can be, depending on the pattern of file sizes on your disk. For instance, if you have a traditional FAT 800 MB disk with 3,000 files on it, about 25 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.

By the way, there is a utility that will examine your disk and compute wasted space for you. WASTED is a small program (30,733-byte ZIP file) that runs under MSDOS or in a DOS window under Windows and computes the amount of wasted space at your current partition size and for other possible partition sizes. It's freeware. Though I haven't seen the source code and so can't verify the calculations, the report seemed reasonable when I tried WASTED on my disks.

I know of two other WASTED-type utilities available at Simtel, wastdv and wastre. I haven't tried out either of them myself. File names at Simtel change as new versions are released, so if you can't retrieve those particular files, try searching in the directories.


How does cluster size depend on hard-disk size?

You need to know the cluster size for various partition sizes so that you can make intelligent choices about how to partition your hard disk.

Here are the cluster sizes for various disk sizes; you can read the math in appendix 1 if you're interested. A megabyte means different things: Microsoft calls 1024 times 1024 = 1,048,576 bytes a megabyte, but hard disk manufacturers tend to inflate their nominal capacities a bit by calling 1,000,000 bytes a megabyte. In the table I use the Microsoft definition because that's what you'll have to use in entering your choices to FDISK.

disk size in bytes cluster size
under FAT16
up to 128 MB134,217,7282 KB
256 MB268,435,4564 KB
512 MB536,870,9128 KB
1024 MB1,073,741,82416 KB
2048 MB2,147,483,64832 KB
over 2048 MB 64 KB
Special note on Windows NT:
Windows NT clusters never exceed 4 KB, according to an article in the 27 June 1995 issue of PC Magazine. According to a Usenet article posted on 18 February 1996 by sangria@inlink.com, Windows NT partitions have configurable cluster size, 512 to 4096 bytes. This means that you can use the information in this article to calculate probable wasted space based on a cluster size you choose. You don't have to select a partition size based on a desired cluster size.

I haven't tried Windows 2000, but since it's really Windows NT 5.0 the preceding paragraph probably applies.

From the above table we see that Western Digital's popular 1080 MB drive is just barely over the 1,073,741,824-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 1080 MB drive with 5,000 files, you're probably wasting about 80 MB (5000 times 16,384 bytes which is half the cluster size).


Beware!

Before you go any further, please check each of these warnings carefully and take corrective action if it applies to you.

Compressed volumes: The following warning comes from Microsoft's application note PD0771:

Warning: If you are using software such as Disk Manager, SpeedStor, Priam, or Everex to replace the BIOS in interactions between MS-DOS and the hard disk controller, do not repartition your hard disk with the MS-DOS Fdisk program. Instead, use the disk-partitioning program you originally used to partition your hard disk.

To determine whether you have one of these disk-partitioning programs on your computer, search for the following files: DMDRVR.BIN (Disk Manager), SSTOR.SYS (SpeedStor), HARDRIVE.SYS (Priam), and EVDISK.SYS (Everex). If you need help in repartitioning your hard disk or are unsure whether the BIOS is being replaced, contact the manufacturer of your original disk- partitioning software.

Windows 95 driver bugs:

If you have an Enhanced IDE disk larger than 504 MB, and you'll be using the Win95 version of FDISK, you should read Microsoft's description of a bug in the Win95 drivers, which includes a fix that you can download and install.

As of 1998-11-18, you could find that information at <http://www.microsoft.com/windows/downloads/contents /Updates/W95DiskType/default.asp>. Unfortunately, Microsoft reorganizes its site several times a year, and I have given up on trying to stay abreast of the URL changes. You may want to try searching Alta Vista or another search engine for the string "Disk Type Specific Driver Update" (with the quotes), or you can pick up the information from this non-Microsoft site:

(Disclosure: I haven't needed to try the fix, because I created my partitions using an earlier version of FDISK.)

Long file names (Windows 95 or 98 users):

If you're running Windows 95 or 98, and you have some long file names, make sure you have a version of backup software that will treat those names correctly on both backup and restore. (If you use a DOS-based backup program, as I did until recently, you can use a utility like DOSLFNBK to save and restore the long filenames.)

How to repartition

Following the procedure below, you will back up all your files, repartition and reformat your disk, and restore your files.

I don't partition a hard disk often: every year or so. I prefer to use FDISK because it's free, and that's what I recommend to everyone who asks.

If you partition frequently, or you want a slick graphical interface with lots of options, you may prefer one of the shareware or commercial partitioning utilities. Note! I have not tried any of them, and therefore nothing I say should be taken as an endorsement or criticism of any of them. If you choose to buy such a utility, at least make sure before you pay for it that it will adjust cluster size. Why pay money for something that does no more than FDISK?

(In the past I linked to the home page of a popular partitioning utility, for the convenience of people who might want to investigate it. The problem is that people who preferred a different one kept e-mailing me to get me to list their choice; and even partisans of the one I listed kept e-mailing me with testimonials, for reasons that I suppose seemed good to them. I no longer link to any partitioning utility under any circumstances, because I continue to prefer using FDISK -- not because it's wonderful, but because it's free and I can't see spending money for simple software that I use less than once a year.)

The following procedure will use FDISK to partition your hard drive.

Select your partition sizes

First select your partition sizes. You want to think a bit about which files will go in which partitions. Since the wastage penalty is half a cluster per file, in general you want small files to go in small partitions and large files in large partitions. (If you have a 1 KB file in a partition whose cluster size is 32 KB, you're wasting 31 KB on that file, which is considerably more than half a cluster. Moving that file to a smaller partition, say one with a 2 KB cluster, reduced wastage to 1 KB and saves you 30 KB on disk.) Look at the table in the previous section and make sure you don't accidentally select a partition size that just nudges into a larger cluster size.

Example: I divided my 1080 MB Western Digital drive (1080 MB nominal; 1033 MB according to FDISK) into three partitions of 453, 453, and 126 MB. The first two then have 8 KB clusters and the third has a 2 KB cluster, versus 32 KB clusters for the unpartitioned drive. This reduced wasted space to 16.6 MB (5.2 %) from 70.8 MB (22.0 %), and increased the number of files that the disk could hold. (You can look at the details in appendix 3.) But another division may be right for you, based on your file sizes. Don't be too concerned, though: almost any partitioning will save you space over an unpartitioned drive.

Step-by-step procedure

  1. Do a full backup of your disk. If you're at all uncertain about your backup hardware and software, do a second full backup. Don't give in to temptation to skip this step, because when you run FDISK you're going to make all the old files on your hard disk disappear.
     
  2. Make sure you have a bootable floppy. (If you received DOS on floppy diskette, your #1 diskette should be bootable. If you're running Windows 95 or 98, to create a bootable floppy you open Control Panel, select Add/Remove Programs, and then the Startup Disk tab.) Also make sure you have the following on a floppy: (If you prefer not to use your DOS disk as a bootable floppy, you can create one by putting the MS-DOS 6.x setup disk in drive a: and then typing the command "A:SETUP /F" to create a separate bootable floppy. Please check to make sure you have all files mentioned above on diskette before proceeding.)
     
  3. Decide what partition sizes you want, as discussed earlier. At this point I should warn you about terminology. In Microsoftese, you don't create N partitions on a disk. Instead you create one "primary DOS partition" and one "extended DOS partition" and then you create N-1 "logical drives" (also known as "logical partitions") in the extended DOS partition. So if you're trying to partition your only hard disk into C:, D:, and E:, you'll create a primary DOS partition which will automatically be C:, then an extended DOS partition, then logical drives D: and E: on the extended partition.

    (If you have multiple operating systems, you can put the additional operating systems in additional primary partitions. Some OSes can boot from a logical partition within an extended partition. A disc can contain as many as four primary partitions, or three primary partitions plus one extended partition.)
     

  4. Boot from the floppy, and then type FDISK (or run your third-party disk-partitioning utility). I'll try to explain the steps that you will follow if you are using FDISK. Be aware that different versions of FDISK may have slightly different menu selections so look for the proper key words in the menus that appear on your screen.
     
  5. Type "FORMAT C: /S" to make the hard disk bootable again. Type "FORMAT D:", "FORMAT E:", and so on for each of the logical drives. Don't use "/S" with D: or any of the later drives because you don't want to make them bootable.
     
  6. Restore the files you backed up. (You don't need to restore them all to C. But unless you plan on reinstalling Windows from scratch, it's probably best to restore the Windows files to the same disk letter where they were before you repartitioned.)
     
  7. Your CD-ROM drive letter will now be different. You'll have to change the drive letter in any Windows icons that point to it (click on each icon, then click File, click Properties, then edit the command line and possibly the working directory, then click). You can do this more easily with programs like COA from PC Magazine. This freeware can be downloaded in either a 16-bit version or a 32-bit version called COA2. If you installed MS-Office from a CD-ROM, you'll also need to edit the source directory setting in setup\setup.stf under your msoffice directory (Maybe COA does this for you; I don't know.)
You don't need to make any changes in your CMOS settings. Even though DOS and Windows now behave as if you have several hard disks, the CMOS will still correctly show the actual hard disk(s).

This completes the procedure. The rest of this document is background for those who may be interested in the numerical details.


Appendix 1: 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, in the traditional FAT or FAT16 file system, 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

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

For FAT32, the cluster number can be 32 bits, allowing for 2^32 = 4,294,967,296 clusters. Therefore any disk size up to 32 TB (32 million million million bytes) can be accommodated with a cluster size of just 8 KB.

For both FAT16 and FAT32, the average wasted space per file will be half a cluster. We'll explore the implications of this after we look at cluster sizes for various disk sizes.


Appendix 2: how is wasted space calculated?

First, as a rule of thumb you should know that each file on your disk, regardless of size, wastes half a cluster. How can we say this? Consider for a moment all the files that take up N clusters on the disk. This will include the files whose true size is N-1 clusters plus 1 byte, up to those whose true size is N clusters exactly. Assuming that file sizes are distributed fairly evenly, the average true size of all the files that take up N clusters will be N-(1/2) clusters. Since the actual space consumed for each of those files is N clusters, we have N-(N-(1/2)) = 1/2 cluster wasted space per file. Note that this result no longer depends on N: the average wasted space per file is half a cluster, regardless of file size and regardless of cluster size.

(Note: In the rule of thumb that "the average file wastes half a cluster", the word *average* is important. If the file is just a few bytes above a whole number of clusters, it will waste almost the whole of the next cluster. All the math in this note assumes that your files are roughly randomly distributed in size (modulo cluster size). If your file distribution is highly unusual the conclusions in this note may not apply.)

Next, we want to calculate how much space is wasted over the whole disk. Let's define some symbols. We'll call

N the number of files on a partition (counting each directory as a file)
S the average file size in KB
K the cluster size in KB
D the disk size in KB
See below for how to determine these numbers.

From this we have the following (I use * for the multiplication sign instead of × [&times;], which some browsers still can't interpret correctly):

K/2 = average wasted space per file (as shown above, on average each file wastes half the cluster size)
N*S = total amount of space that is actually part of files (number of files times average file size)
N*K/2 = total amount of wasted space (number of files times average per file)
(N*K/2) / (N*S) = K/(2*S) = fraction of wasted space (As a percentage this is 50*K/S.)
N*S+N*K/2 = N*(S+K/2) = total amount of space taken up on the disk (sum of the two previous numbers)
D/(S+K/2) = number of files the disk can hold (disk size divided by actual space used per average file)

Note that the fraction of space wasted doesn't depend on the number of files, only on the cluster size K and on the average file size S. The exact same files will waste proportionally four times as much space on a drive with 32 KB clusters as on one with 8 KB clusters.

How to determine N, S, K, and D

It ought to be easy to determine these parameters (which were defined above), but DOS makes some of the information rather obscure.

You can determine K, D, and N by using the CHKDSK command. K is the number of bytes in each allocation unit; D is the bytes of total disk space; and N is the sum of the numbers of hidden files, directories, and user files.

S, the average file size, is extraordinarily difficult to obtain. It's just the total file size divided by N, but the total file size can't be obtained, as far as I know, without examining the entries in each and every directory.

Fortunately (see above), the amount of wasted space depends on the total number of files and the assumption that their sizes (module cluster size) are fairly randomly distributed. So even without knowing S you can tell how much disk space you'll free up if you reduce cluster size.

In fact, you don't even have to do the math, since the WASTED utility (described above) will examine your disk and compute it for you. My calculations assume a random distribution of file size, and therefore they will only approximate any actual disk; but the utility will make an exact calculation for your disk.


Appendix 3: Historical example

These statistics from when I repartitioned my own disk are quite old now (late 1995), but still illustrative. The math is still valid, though all three partitions have more files (and bigger files!) in them now, and I've had to buy a second disk. I have my 1080 MB hard disk partitioned in three: C = 453 MB, D = 453 MB, E = 126 MB. (Those are FDISK megabytes, 1024^2 = 1,048,576 bytes each. Owing to rounding errors those figures don't quite add to 1034 MB, which is the drive capacity in FDISK megabytes.) C is for DOS and Windows and the MSVC compiler, D is for Windows and DOS utilities, and E is for data files, letters, and the like.
C: 453 MB partition, 2,352 files, 187,118,114 bytes
N = 2352, S = 78, K = 8
number of files the partition can hold: 5656
waste = 9.2 MB = 5.1%
(This drive is a mix of big Windows programs, including a 21 MB swap file, and gazillions of those little .INI files.)
D: 453 MB partition, 1,791 files, 115,589,208 bytes
N = 1791, S = 63, K = 8
number of files the partition can hold: 6923
waste = 7.0 MB = 6.3%
E: 126 MB partition, 389 files, 35,041,958 bytes
N = 389, S = 88, K = 2
number of files the partition can hold: 1449
waste = 389 KB = 1.1%
(I was surprised at how many very large files I had on this partition. I had expected S to be around 10 KB or less.)

Now to compare the partitioned situation with what it would have been if I had not partitioned the disk:

unpartitionedpartitioned
disk or partition size in MB (1 MB = 1024&#sup2; bytes) 1034453, 453, 126
total amount of file data in KB 329,833329,833
N = number of files 45324532
S = average file size in KB 7373
K = cluster size in KB 328-8-2
wasted space in MB 70.816.6
wasted space relative to actual file data 22.0%5.2%
number of files the disk can hold 11,89614,028

The differences are pretty dramatic. Using the partitions I selected, I cut wasted space to 5 % from 22 %, and increased effective capacity of my disk to 14,028 files from 11,896, an increase of almost 18 percent.


Was this page useful? Visit my other Technical Articles.

 

Click here to go back to Archer's page