Recover Formatted Disks in MS-DOS 6.22

In MS-DOS 6.22, the dedicated feature that allows users to restore data lost to accidental disk formatting is the UNFORMAT command, which works in tandem with the operating system's default "Safe Format" behavior. By capturing and storing critical disk structure information before wiping the directory, MS-DOS ensures that a freshly formatted drive can be rolled back to its previous state.

The Safe Format Mechanism

When you run the standard FORMAT command in MS-DOS 6.22 without additional switches, the operating system does not perform a destructive overwrite of the disk's data area. Instead, it executes a "Safe Format."

During a Safe Format, MS-DOS:

  • Clears the File Allocation Table (FAT) and the root directory to make the drive appear empty to the system.
  • Scans the disk for bad sectors.
  • Leaves the underlying data clusters untouched.
  • Saves a hidden image of the original FAT and root directory structure into an unallocated cluster at the end of the disk.

This preserved image serves as the blueprint needed to reverse the operation.

Restoring Data with UNFORMAT

To restore an accidentally formatted drive, the UNFORMAT command is executed against the target drive letter (for example, UNFORMAT C:).

Once executed, UNFORMAT scans the disk surface to locate the hidden backup file created during the Safe Format. If found, it reads the saved directory structure and FAT pointers, writing them back to their original locations. This process restores the root directory, subdirectories, and file links, making the drive's files immediately accessible again.

Limitations of Recovery

Recovery using UNFORMAT is only possible under specific conditions:

  • No Unconditional Format: If the drive was formatted using the /U (Unconditional) switch, MS-DOS overwrites the data areas or physically formats floppy disks, bypassing the creation of the recovery file and rendering UNFORMAT ineffective.
  • No New Writes: Any data written to the formatted drive before running UNFORMAT risks overwriting the clusters where the original files or the recovery image reside, resulting in permanent data corruption.
  • Fragmentation: If the backup image is missing or damaged, UNFORMAT can attempt a generic reconstruction using directory markers, but fragmented files may become partially corrupted because the exact cluster chains cannot be determined without the original FAT.