MS-DOS 6.22 Drive Volume Serial Numbers

This article explains how MS-DOS 6.22 queries, retrieves, and displays drive volume serial numbers from the command prompt. It details the user-facing commands used to display this data, the underlying FAT filesystem structures where the serial number is stored, and the low-level MS-DOS Interrupt 21h system calls that execute the operation.

Command Prompt Utilities

In MS-DOS 6.22, users query a disk’s volume serial number directly from the command prompt using two primary internal commands built into COMMAND.COM:

  • VOL [drive:]: Displays the volume label and volume serial number of the specified drive. If no drive is specified, it reports the data for the current working drive.
  • DIR [drive:]: Displays the directory listing, preceded by a header that shows the volume label and the volume serial number in the format Volume Serial Number is XXXX-XXXX.

The Underlying DOS Interrupt Calls

When either VOL or DIR is executed, MS-DOS 6.22 does not manually parse the raw disk sectors each time. Instead, COMMAND.COM interfaces with the MS-DOS kernel using system interrupts:

  1. INT 21h, Function 440Dh, Minor Code 66h (IOCTL - Get Media ID)
    • AH: 44h (IOCTL)
    • AL: 0Dh (Generic Block Device Request)
    • BL: Drive number (0 = default, 1 = A:, 2 = B:, 3 = C:, etc.)
    • CH: 08h (Disk category)
    • CL: 66h (Get Media ID)
    • DS:DX: Pointer to a 24-byte Media ID buffer.

When issued, the DOS kernel fills this buffer with disk identification metadata. The Media ID structure includes:

  • Bytes 00h–01h: Info level (0)
  • Bytes 02h–05h: Volume Serial Number (32-bit binary value, stored in Little-Endian format)
  • Bytes 06h–10h: Volume Label (11 bytes, padded with spaces)
  • Bytes 11h–18h: File system type (8 bytes, e.g., "FAT12 " or "FAT16 ")

Sector Origin: The Extended BIOS Parameter Block

The serial number returned by the IOCTL call originates on the disk media itself. When a drive is initialized via FORMAT.COM under MS-DOS 4.0 through 6.22:

  1. A pseudo-random 32-bit value is generated using the system date and time down to the hundredth of a second.
  2. This 4-byte value is written to the Extended BIOS Parameter Block (BPB) inside the volume boot record (Sector 0 of the partition) at offset 027h (0x27).
  3. During drive access, the DOS device driver reads the BPB into memory, allowing Function 440Dh to quickly pull the cached serial without re-reading Sector 0 repeatedly.

Display Formatting

Once the 32-bit integer is returned to COMMAND.COM via the IOCTL buffer, MS-DOS splits the 4-byte double word into two 16-bit segments (High Word and Low Word). It translates the binary values into hexadecimal ASCII characters and formats them with a hyphen:

[High Word in Hex] - [Low Word in Hex]

For example, a 32-bit value stored in memory as EF CD AB 12 (represented as 12AB-CDEF) is output on screen as:

Volume Serial Number is 12AB-CDEF