The very first comment that should be made about
MS-FORMAT is this:
A hard drive is not
required to have been set up by MS-FDISK in order for Microsoft's
FORMAT.COM to work correctly. That is an important point in trying to ascertain
why MS-FDISK acts the way it does. To be specific, the F6-byte sectors
that MS-FDISK writes to a drive, are never checked by the MS-FORMAT
programs. At one time I had assumed that was the case, simply thinking,
"Well, they must be writing all those F6-bytes so that MS-FORMAT can find
them, right?" Wrong! You can just as easily use the FreeFDISK tool
or even edit the MBR with a disk editor, and MS-FORMAT could care less. However,
MS-FDISK itself does check that it can write to/read from a number of sectors
that MS-FORMAT will be using; thus, for someone using both programs, a check
has been made.
NOTE: MS-FORMAT will zero-out the existing FAT data from any healthy (perfectly operational) FAT partition without checking any of the sectors there!
On our FDISK98 page, we began with a rather small experimental drive of 540 MB (1046 Cyl., 16 Hd., 63 Sectors), and completed the FDISK process on it. 92,260 consecutive sectors were filled with 5Eh bytes; the (^) character, so we'd know where/when FORMAT.COM writes any zero-byte sectors to the drive. The drive has 1,054,368 sectors (giving us a total size of: 514.828125 BinaryMB).
Here's what you'll see on the screen after entering the command:
WARNING, ALL DATA ON NON-REMOVABLE DISK DRIVE C: WILL BE LOST! Proceed with Format(Y/N)?y Formatting 513.81M <-- Since the BIOS of this computer reserved the last cylinder. nn percent completed. <-- This line is replaced with: "Format complete." when it's finished.
Some good news: It appears that this phase of the FORMAT command only 'reads' from the drive until the very end of the process! At 50%, 90% and even 98%, a forced reboot was activated and the drive was checked for any writes; there were none found. So, if you accidentally begin to FORMAT the wrong drive letter, then at anytime during this rather long process (up to about 99%), just perform a forced reboot and your drive should still be intact! It's only at the very end of this process that FORMAT.COM actually writes to the drive.
At the end of the process, FORMAT.COM writes two copies of the MSWIN4.1 Boot Record (for FAT32 partitions) to the volume (or logical drive) you're formatting. The first occupies relative offset sectors 1 through 3 (and if it's the very first partition on the disk, as it is in our case, that would normally be Abs. sectors 63 through 65) and the second (a backup copy) is written to relative sectors 7 through 9 (usually Abs. sectors 69 through 71). Offset sectors 4 through 6 (Abs. sectors 66 through 68), plus all of the other sectors through to offset sector 32 (Abs. Sector 94 in this case), are filled with zero-bytes!
The next phase, the writing out of the FATs, begins like this:
Writing out file allocation table nn percent completed. <-- This line is replaced with a simple: "Complete." When it's finished (it took less than 2 seconds for this drive).
During this phase, FORMAT wrote two whole copies
of the FAT (File Allocation Table) to the drive; essentially all zero-bytes,
since no new files have been written to the drive yet. A number of sectors
past the beginning of the Root Directory (more on this below)
were also filled with zero-bytes. Absolute Sector 2,156
was the last sector that FORMAT wrote zero-bytes to. For any drive letter
that corresponds to the first physical partition of a drive, its FAT almost
always begins at Absolute Sector 95,
and the first 16 bytes of a new 32-bit FAT will appear as follows in a disk
editor (running under DOS):
F8 FF FF 0F FF FF FF 0F FF FF FF
0F 00 00 00 00
If you view that same line in a disk editor running under a Windows OS, the
8th byte (a 0Fh) will be changed into an F7h or FFh (see my "Dirty
Shut Down" page for more about it).
A nice side-effect of having two copies of the
FAT is that this makes it easy to figure out how many sectors it occupies
by simply searching for the next copy (using the bytes: F8 FF FF 0F FF FF
FF) and then doing some simple arithmetic:
1,122 <-- First sector
of 2nd FAT (for this drive).
- 95 <-- First sector of 1st FAT (for
this drive).
1,027 <-- The length of each FAT (for
this drive).
+ 1,122
2,149 <-- First sector of the Root Directory.
And that's exactly where I found the volume label that I entered below, the second time I ran through these tests.
So, we now know that FORMAT also zero-filled 8 sectors for the Root Directory (Sectors 2149 through 2156). Here's the rest of what you'd see on the screen:
Calculating free space (this may take several minutes)... [ which has Complete. always seemed rather strange, since it hardly takes any time at all; especially when compared to how very long the ' formatting process' above takes! ] Volume label (11 characters, ENTER for none)? voltestname 537,702,400 bytes total disk space 537,702,400 bytes available on disk 4,096 bytes in each allocation unit. 131,274 allocation units available on disk. Volume Serial Number is 4776-07EE
Here's how that Volume Label appears in a disk editor (at the beginning of the Directory, since it was the very first item entered):
Absolute sector 2149 (cylinder 1, head 2, sector 8) 0000: 56 4F 4C 54 45 53 54 4E 41 4D 45 28 00 00 00 00 VOLTESTNAME(.... 0010: 00 00 94 2D 00 00 C6 0C 94 2D 00 00 00 00 00 00 ...-.....-......
The longer you wait to give your drive a volume label, such as after using SYS.COM on the drive or even after installing an OS, the further down the list of files and subdirectories you'd need to look for its entry.
In yet another test (with a different drive), I left the volume label blank and started the FORMAT command with the /S (System) switch which caused it to transfer System Files from the boot diskette to the drive volume. The FORMAT session appeared like this on my screen:
WARNING, ALL DATA ON NON-REMOVABLE DISK DRIVE C: WILL BE LOST! Proceed with Format(Y/N)?y Formatting 799.28M Format complete. Writing out file allocation table Complete. Calculating free space (this may take several minutes)... Complete. System transferred Volume label (11 characters, ENTER for none)? Win98 836,452,352 bytes total disk space 393,216 bytes used by system 836,059,136 bytes available on disk 4,096 bytes in each allocation unit. 204,115 allocation units available on disk. Volume Serial Number is 0D75-18F7
And here's how the Directory appeared after running this test:
The system files added to the drive by use of the '/S' option are shown inside the GREEN line. It should now be obvious that a Volume Label (if it exists) can appear almost anywhere in the Root Directory just like any filename found there.
Created: 19 DEC 2002.
Revised: 15 February 2004.
Updated: 15 May 2007.
You can write to me using this: online
reply form.
(It opens in a new window.)
Back to:
"What MS-FDISK does to a Hard Drive"
MBR
and Volume Boot Records Index
The Starman's Realm Index Page