26

I found only this:

The UNFORMAT command is used to undo the effects of formatting a disk.

The command is available in MS-DOS versions 5 and later.

Source: https://en.wikipedia.org/wiki/List_of_DOS_commands#UNFORMAT

It's also considered important enough to mention as a "bullet point" in their rather comical MS-DOS 5 video: https://youtu.be/WxC6PytZMqc?t=178

But what exactly does "undoing the effects of formatting a disk" entail? It basically "factory-resets" the disk by writing zeroes all over it? Is that what "unformat" means? Why would anyone need or want to do that?

If this is indeed the case, why was this only added as late as in v5? Shouldn't it be an obvious little tool to go along with FORMAT, if there is indeed any use for it at all? (I personally cannot think of one.)

New contributor
P. Molet is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
3
  • 3
    Never had heard of unformat so I thought it might be part of "DOS9", a collection of joke programs (see discussion a thttps://rpgwatch.com/forum/threads/are-there-any-joke-programs-anymore.11587/). It seems to exist actually, however. Surprise!
    – U. Windl
    yesterday
  • The name unformat was chosen in the sense of undelete, i.e. "get back my data as it was before formatting the disk", not as in "I want to have the disk in pristine condition as if it came from the factory". yesterday
  • 4
    Fun fact: back in the '90s I worked for a company that was bought out of liquidation; the MD had hoped to remain in charge of the company but was sent packing, as a parting gesture he formatted the disk of his office PC, only realising after the fact that he had quick-formatted it and lacked the expertise to boot from a floppy and do the job properly. It was the work of a moment to restore the PC and extract a significant amount of incriminating evidence about his actions in the company's last days.
    – Frog
    yesterday

3 Answers 3

47

If you format a drive with quick format option (FORMAT /Q), it only clears the root directory and FAT area, but before doing so, the format command stores them in unused area of the disk. This is called as storing unformat information.

So while the drive looks empty, all the data is still there, with information how to recover root directory entries and FAT table.

The UNFORMAT command restores the root directory entries and FAT area, making the files appear as if the drive was never quickformatted.

MS-DOS 6.22 contains technology to store enough FAT information to restore also non-contiguous files. Previous versions of MS-DOS such as 6.21 and below did not contain this technology.

Unformatting only works if the the drive has not been used to write files, as it will overwrite existing data or the unformat information so not everything can be restored.

7
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Chenmunka
    yesterday
  • The behaviour when restoring fragmented files didn’t change with MS-DOS 6.22; see my answer for details of its significance. 20 hours ago
  • @StephenKitt MS documentation says that quickformat stores the unformat information identically to running mirror which was introduced in MS-DOS 6.22.
    – Justme
    19 hours ago
  • Do you have a pointer? I checked the behaviour with PC Tools, MS-DOS 5 and MS-DOS 6.22 before writing my answer ;-). MIRROR was available in MS-DOS 5 (and moved to the supplemental disk in 6.22). 18 hours ago
  • @StephenKitt I did not test and did not recall there was any problems with non-contiguous files. I simply trusted MS KB article Q69767 which says a copy of FAT is stored and quickformatting is identical to running mirror.
    – Justme
    16 hours ago
4

My recollection of this is that at some point Microsoft made the default behaviour of the FORMAT command so it would save a copy of the file system somewhere. So if you did a format and then realised your mistake you could use Unformat and it would copy back the hidden file system. Something like that. And Format picked up a new option called unconditional format (/U I think) which didn't save the information. Some people on the internet think /U did a wipe of the disk but format never did any deliberate wiping.

So essentially a sophisticated user could choose to perform an unconditional format but an 'ordinary' user could format a disk accidentally and then save themselves. My recollection is that it wasn't related to the /Q option. The point of a quick format was that drives got to a certain size and it was taking hours just to get a drive ready and thankfully someone realised it was possible to instantiate a file system without actually writing to every sector first.

Pretty sure /U is still accepted on the Format command now but it doesn't do anything - so as not to break old scripts I suppose.

New contributor
Geoff Vass is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
3

UNFORMAT has two modes of operation.

The first one restores a backup of the critical areas of the disk, a “Mirror” backup. These backups are created, space permitting, by the MIRROR tool and by FORMAT when it performs a quick format (which is the default in MS-DOS 5.0 and later). The backup contains a copy of the boot sector, FAT, and root directory; these are stored in a hidden file named MIRROR.FIL. Obviously formatting a drive means that the location of that file is lost; to work around that, a pointer to the MIRROR.FIL file’s clusters is stored in another hidden file named MIRORSAV.FIL, stored in the last cluster of the disk.

If UNFORMAT finds the signature of a Mirror backup, it displays the date and time at which the backup was created, and checks whether any file on the disk has been created since then. If everything is OK, and the user confirms they want to update the disk, the data from the backup is restored. Since a quick format only deletes the FAT and root directory, this results in a full restoration of the disk, if nothing was written to the disk after it was formatted.

The second mode of operation applies when no Mirror backup is available. In such cases, UNFORMAT first looks for a Mirror backup (for scenarios where a MIRROR.FIL file was stored on disk, but MIRORSAV.FIL was overwritten); if it can’t find one, it looks at every single sector of the drive, looking for data structures matching directories. If it finds any, it uses the information present in the directory to restore its contents; this allows it to restore any unfragmented file stored in a subdirectory.

There are two important limitations with the second mode of operation: it can’t restore files which were stored in the root directory, and it can’t restore fragmented files. When UNFORMAT comes across a fragmented file, it asks whether the user wishes to restore it (truncated), or delete it.

All of this was available in Central Point Software’s PC Tools, before it became available in MS-DOS 5. PC Tools also included a formatting tool, PC Format, which would perform quick formats and store Mirror backups. Microsoft licensed these tools for inclusion in MS-DOS 5 and later, in a simplified form compare to the PC Tools versions (in particular, the PC Tools versions have a more sophisticated user interface).

In MS-DOS 5 and later, it is also possible to quick-format a disk without storing the Mirror backup by specifying both /Q and /U options (FORMAT /Q /U, quick and unconditional).

Your Answer

P. Molet is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.