[Home]

MS-DOS 3.20 FORMAT.EXE bug

I noticed that when using modern emulators and/or BIOS versions, MS-DOS 3.20 fails to format a hard drive (tested using a 32 MB disk):

A>format c:

WARNING, ALL DATA ON NON-REMOVABLE DISK
DRIVE C: WILL BE LOST!
Proceed with Format (Y/N)?y

Format complete

Error reading partition table
Format failure

The above example was produced using SeaBIOS (1.13.0-1ubuntu1.1) and QEMU (4.2.1 (Debian 1:4.2-3ubuntu6.29)). Depending on BIOS, the returned error may also be ``Bad Partition Table''.

This is interesting given that back-in the day MS-DOS 3.20 was used in millions of computers apparently without such an issue.

After some debugging, it seems the root cause is that FORMAT.EXE is trying read the partition table by passing the (0,0,0) CHS address to INT 13h BIOS read disk routine. The routine assumes that sectors start from 1, so depending on BIOS it either rejects the read or reads data from an incorrect location. Apparently this was somehow working when ``real'' CHS addressing was used. Modern systems that convert it to LBA fail.


Last updated: 2024-08-05 21:25 (EEST)