SmartFormat 2.1

An Advanced Floppy Format Program

Vinay Pai


Click here to download SmartFormat
(TFORMAT.ZIP; 22kb)

Synopsis

Table of Contents

1. History
2. SmartFormat Features
3. Techniques and Technology
3.1 Floppy Fundamentals
3.2 DOS/Win9x FAT System
3.3 SmartFormat Track Zero Workaround
3.4 Data Capacity Extension
4. Implementation Details
4.1 Formatting Process Overview
4.2 User Interface
5. Miscellaneous Information
5.1 Installation/Uninstallation
5.2 System Requirements
5.3 Known Problems

1. History

Despite all claims of great reliability made by manufacturers, 3½" floppies seemed to have a great tendency go bad. The words "Track Zero Bad - Disk Unusable" became all too familiar. When seven of a brand new box of ten floppies went bad within a couple of months, the search for a solution began.

Early attempts at fixing the problem included tweaking the BIOS floppy drive parameters to ensure that floppy timing parameters were not causing the problem. However, later investigation showed that each floppy reported different sectors as unreadable and the same sectors for a given floppy each time. This showed that the problem lay not in the hardware or BIOS but the disks itself. This preempted the possibility of fixing the errors. It only remained to devise a workaround. This led to the development of SmartFormat 1.0 in early 1998. The latest release, SmartFormat 2.1 includes a number of new features.

2. SmartFormat Features

Salient features of SmartFormat 2.1

3. Techniques and Technology

3.1 Floppy Fundamentals - Track and Sector Layout on a Floppy Disk

Before it is possible to deal with the actual details of the Track Zero workaround and capacity extension a little background information on the physical layout of sectors and tracks on a floppy disk is necessary.

Tracks on a floppy are a physical concept. The head is first calibrated to track zero (the outermost track) by detecting the index hole. A stepper motor then moves the head in fixed increments to give track 1, track 2 and so on.

Sectors are not physically defined on the floppy but are logically created by the Intel 8272 FDC controller (or equivalent chip). During formatting, sector headers are written for each sector. These headers are used to define sectors. Normally sectors are laid out in the order 1, 2, 3 etc. However, it is possible to define them in any order. This is transparent to other software because when a sector is requested from the disk the FDC locates the relevant sector independent of other sectors on the track. This aspect is used in the Track Zero Workaround by SmartFormat.

In addition to the sector headers and the actual data, there is also a CRC (Cyclic Redundancy Check) code for each sector (to help verify data) and inter-sector gap to allow the head time to stabilize and read the sector. By tweaking this gap length, SmartFormat can increase the floppy disk capacity to 1.72 MB.

3.2 DOS/Win9x FAT System

Under DOS and Windows 9x, floppy drives use the FAT12 (12-bit File Allocation Table) system. Under this system three critical system areas of the floppy are stored at the beginning of the disk:

  1. Boot Sector
  2. First Copy of FAT
  3. Second Copy of FAT
  4. Root Directory

On a 1.44 MB disk, the Boot Sector, First Copy of FAT and a part of the Second Copy of FAT lie on Track 0, side 0. The remaining lie on size 1, along with the first few data sectors. If these areas are unreadable data on rest of the disk becomes useless because there is no way to locate files and directories. This prevents other format programs from formatting disks with errors on track zero.

3.3 The SmartFormat Track Zero Workaround

As is seen from the above list there are two copies of the File Allocation Table. In case one is unreadable, the other is used. Thus, if the first copy of FAT is completely readable, the second copy is never used. SmartFormat takes advantage of this redundancy. Using the technique mentioned in the previous section, SmartFormat reorders the sectors on track zero, so that the bad sector lies on either the second copy of FAT or on the data sectors (depending on whether it is size zero or one). This ensures that the Boot Sector, First Copy of FAT and Root Directory are always readable.

Eight sectors of the second copy of FAT lie on side zero. Hence SmartFormat can tolerate upto eight bad sectors on size zero. This leaves plenty of margins even for very bad disks.

On side one, however, there is only one sector of the second copy of FAT (the FATs are 9 sectors long) and three data sectors. Thus SmartFormat would normally be able to tolerate only four bad sectors on size one. However, the Root Directory normally occupies 14 sectors.

By tweaking the boot record (on the boot sector) it is possible to reduce that. SmartFormat arbitrarily restricts the reduction to 4 sectors, thus allowing eight bad sectors on size one, as well. Reducing the size of the root directory, however, reduces the number of files that can be stored in the root directory. That is why SmartFormat ensures that the root directory uses at least 10 sectors. (Of course, subdirectories can hold any number of files).

3.4 Data Capacity Extension

As mentioned in section 3.1, there is an inter-sector gap on sectors to allow the drive to stabilize before reading the sector. This value is normally 80 bytes per sector. By reducing this, SmartFormat can squeeze in 21 sectors per track instead of the normal 18, bye tweaking the BIOS Disk Parameter Block (pointed to by Interrupt Vector 1Eh) However, this would leave insufficient time for the head to stabilize for the read. Hence, sectors are interleaved, i.e. put in order:

1, 12, 2, 13, 3, 14 etc.

Thus, when the head tries to read sector 2 it first has to skip over sector 12, if it reads 13 it first has to skip over 2 and so on. This gives enough time to ensure reliability.

However, squeezing in 21 sectors instead of 18 only increases the capacity to 1.68MB. SmartFormat achieves 1.72MB by forcing the heads stepper motor to give 82 tracks instead of the normal 80. This does not threaten the hardware in any way. If the head is unable to move due to the physical construction of the drive, it will simply ignore the seek command. In this worst case scenario the last two tracks will get marked bad, still leaving 1.68MB. (Note that such a problem was never actually encountered during testing on any drive)

4. Implementation Details

4.1 Formatting Process Overview

  1. Initialization
    1. Reset the FDC Controller
    2. Wait 1000ms for the spindle motor to come to speed (~360 rpm)
    3. Select Boot Sector for 1.44 MB or 1.72 MB formats
    4. Call BIOS interrupt 13h to get DPB. Tweak if 1.72MB is required.
    5. Setup FAT in memory buffer and set Media Descriptor Byte
  2. Special Case - Track Zero
    1. Do physical format
    2. Check for bad sectors (Verify operation)
    3. If bad sectors are found, renumber them to lie on Second Copy of FAT or data sectors. Shrink the root directory if necessary, by adjusting the "Max Root Entries" parameter in the boot record.
    4. Reformat the track with the new sector order
    5. Verify that the Boot Sector, First Copy of FAT and Root Directory are readable. If not, retry the complete operation upto three times.
    6. Continue if successful, abort the format, otherwise.
  3. Formatting other Tracks
    1. Do physical format
    2. Check for bad sectors (Verify operation)
    3. Mark any bad sectors in the FAT
  4. Writing System Areas
    1. Get label from user and set it in the root directory
    2. Get date and time from system clock and store it as serial number in boot record
    3. Write boot sector on head 0, track 0, sector 1.
    4. Write First Copy of FAT (9 sectors for 1.44 MB, 10 for 1.2 MB)
    5. Write Second Copy of FAT (Identical to first copy)
    6. Write Root Directory
  5. Display Disk Statistics (Unusable Space, etc.)

4.2 User Interface

SmartFormat uses an easy to use text mode interface. Of startup, it presents the user with the main menu. With the following options:

An option can be selected either by moving the highlight with the arrow keys and pressing the 'Enter' key, or simply typing the letter printed in bold face. For example, pressing the 'H' key. (In keeping with convention, the F1 key will also bring up the help screen).

The lowermost line of the screen (the status bar) will always tell the user what to do next. For example, during format, it will say "Format in progress. Press to abort". In the main menu it briefly describes the highlighted item. The user can get more help by accessing the help screen.

SmartFormat uses robust user input validation. For example, it checks for all available 3.5" drives at startup, and will not allow the user to select an invalid drive letter.

All error messages in SmartFormat are easy to understand and descriptive. They not only describe the error but also advise the user of probable causes and suggested solutions.

5. Miscellaneous Information

5.1 Installation / Uninstallation

To install simply unzip the TFORMAT.ZIP file into any directory using PKZip or WinZip. This extracts two files -

To run, just go the directory where SmartFormat was installed and type "TFORMAT", or double click the TFORMAT.EXE file from Windows Explorer.

To uninstall, simply delete these two files. This cleanly installs the application, because SmartFormat does not make any changes to any files on the disk.

5.2 System Requirements

5.3 Known Problems

There are currently no major known problems with SmartFormat. There are, however a couple of minor problems:

Back to top