PC Hardware

High-Level Formatting

The high-level format is simply called "format" (the program used to perform a high-level format is called FORMAT.COM). This is the same format command used to prepare floppy disk drives. The high-level format performs two major functions:

  • It creates and configures the file allocation tables (FATs).
  • It creates the root directory, which is the foundation upon which files and subdirectories are built.

File Allocation Tables (FATs)

The base storage unit for drives is a sector. Each sector can store between one byte and 512 bytes of data. Any file less than 512 bytes is stored in a single sector, and only one file can be assigned a sector. Therefore, any part of a sector left unfilled is wasted. When files are stored in more than one sector (if they are greater than 512 bytes), MS-DOS needs a way to keep track of each location and the order in which data is stored. MS-DOS also needs to know which sectors are full and which sectors are available for data, so it uses the file allocation table (FAT) to keep track of this information.

The FAT is simply an index that keeps track of which part of the file is stored in which sector. Each partition (or floppy disk) has two FATs stored near the beginning of the partition. These FATs are called FAT #1 and FAT #2. They are identical. Each FAT can be looked at as a two-column spreadsheet.

Left Column

Gives each sector a number (in hex) from 0000 to FFFF (65,536 sectors). The left side contains 16 bits (4 hex characters = 16 bits). This FAT is called a 16-bit FAT. Floppy disk drives use 12-bit FATs because they store substantially less data.

Right Column

Contains information on the status of the sector. During formatting, any bad sectors are marked with a status code of FFF7 and good sectors are marked 0000.

Sectors and Clusters

As mentioned, the CHS values limit the maximum size of a hard disk drive to 504 MB under the older PC operating systems. The 16-bit FAT can address 64,000 (2l6) locations. Therefore, the size of a hard drive partition should be limited to 64,000 x 512 bytes per sector or 32 MB. With this limitation, you might ask, how are larger hard drives possible?

There are two solutions to this problem. The first method, used with earlier drives (under 100 MB), was to use FDISK to break the drive up into multiple partitions, each less than 32 MB.

The second method is called clustering. Clustering means to combine a set of contiguous sectors and treat them as a single unit in the FAT. The number of sectors in each cluster is determined by the size of the partition. There can never be more than 64,000 clusters. To determine the number of sectors in a partition, divide the number of bytes in the partition by 512 (bytes per sector). Then divide the number of sectors by 64,000 (maximum allowable clusters). The following table provides an estimate of sectors per cluster.

Partition (in MB) Total Bytes Total Sectors Sectors per Cluster Bytes per Cluster
32 33,554,432 65,536 1 524
64 67,108,864 131,072 2 1049
128 134,217,728 262,144 4 2097
256 268,435,456 524,288 8 4194
512 536,870,912 1,048,576 16 8389
1000 1,048,576,000 2,048,000 32 16,384
2000 2,097,152,000 4,096,000 64 32,768
4000 4,194,304,000 8,192,000 128 65,536

Remember: for this table, a sector is not the basic unit of storage-it is now the cluster.

How the File Allocation Table Works

When a file is saved:

  1. MS-DOS starts at the beginning of the FAT and looks for the first space marked "open for use" (0000). It begins to write to that cluster.
  2. If the entire file can be saved within that one cluster, the code FFFF (last cluster) is placed in the cluster's status field and the file name is added to the directory.
  3. The cluster number is placed with the file name.
  4. If the file takes more than one cluster, MS-DOS searches for the next open cluster and places the number of the next cluster in the status field. MS-DOS continues filling and adding clusters until the entire file is saved.
  5. The last cluster then receives the end of file code (FFFF).

FAT32

Windows 98 and Windows 95 (OSR2-the final version of Windows 95, available only on new machines, also called version C) support the new FAT32 file system. FAT32 can create partitions up to 2 terabytes (two trillion bytes) in size (much larger than the 2-GB limit of FAT16) and uses smaller clusters than FAT16. This results in a more efficient use of space on a large hard disk.

When deciding whether to use FAT32, take the following into consideration:

  • Don't use FAT32 on any partition that other operating systems-except for Windows 95 OSR2-will use.
  • MS-DOS, Windows 3.x, the original release of Windows 95, and Windows NT clients can read FAT32 partitions shared across a network.
  • If you dual boot between Windows 98 and another operating system (such as Windows NT 4.x), the drive C partition cannot be FAT32.
  • You cannot compress FAT32 partitions.
  • Windows 98 MS-DOS mode fully supports FAT32, so you can run most MS-DOS-mode games and applications from FAT32 partitions.
  • Some older applications written to FAT16 specification might not display disk space larger than 2 GB.
  • Do not use any utilities that do not support FAT32. This could result in data loss and might corrupt the file system on the hard drive.

Fragmentation

Fragmentation is the scattering of parts of the same disk file over different areas of the disk.

During PC use, files are opened and then saved back to disk. As mention earlier, the file is often stored in several small sections. Fragmentation is caused by the following:

  1. As a file is written to sectors (clusters), it is placed in the first available location.
  2. The continual addition and deletion of files begins to leave open clusters.
  3. These open clusters are filled by the first part of the next file to be saved.
  4. Soon, files become fragmented, or scattered, all over the drive.

This is an acceptable way to operate and causes no problems for the computer itself. However, excessive fragmentation slows down the hard disk drive because it has to access two or more areas to retrieve a file. It is possible for a single file to be fragmented into hundreds of pieces, forcing the R/W heads to travel all over the hard disk drive.

Most operating systems have either native or third-party applications that will defragment a drive. These should be used on a regular basis to improve performance and save wear and tear on the drive.

Disk Compression Disk compression is offered as part of the Microsoft Plus add-on product for Windows 95, but is included in Windows 98 as the DriveSpace 3 program. It works by creating a single big file (called a compressed volume file or CVF) that acts like a virtual disk drive (with its own drive letter). Files you write to the CVF will become records within the one big file. This process is normally transparent to the user.

Keep in mind that you cannot use DriveSpace 3 with partitions that use the FAT32 file system. If you wish to compress a drive under Windows 98, use the FAT16 file system when installing the drive.

Compression saves space in two ways. It:

  • Eliminates the wasted cluster space used by separate disk files.
  • Replaces sequences of identical values or characters in the file data with a special reference that represents the actual data, but occupies less disk space than the data itself would.
  • When the data is retrieved from the file, the real values are extracted from the special references. The result can be a dramatic reduction in the disk space occupied by files, especially with uncompressed graphics files and word-processing documents.

Using compression introduces some risk because an error in the compressed volume file can make data inaccessible. It is safest not to use a compressed file for critical data, and some older programs (particularly games) might not work with compression. With DriveSpace 3 you can use the Troubleshooter to identify and fix problems.

Compression is less necessary today, because of the advent of large hard disk drives and the availability of the FAT32 file system with its smaller cluster sizes.

The elimination of fragmentation improves the speed of the hard disk drive dramatically. Running a program to eliminate fragmentation is called defragmenting a drive. The slang term "defrag" is often used. MS-DOS installations include a defragmentation program called DEFRAG. Windows 95 and 98 include a defragmentation program that can be accessed from the Start menu-select Programs, then select Accessories, and finally select System Tools.

DEFRAG cannot rewrite or move systems and hidden files. These files might be program files that are copy protected and must not be moved after the program is installed. System files such as the MS-DOS core program must occupy a particular position on the disk.

Never run a defragmentation program designed for MS-DOS or Windows 3.x on a Windows 95 or 98 system. The program might not understand the Windows 95 and 98 long file names, and data might be lost.