unformat(CMD) 19 June 1992 unformat(CMD) Name unformat - restore a disk erased by format command or restructured by recover command Syntax unformat drive: [/j] unformat drive: [/u] [/l] [/test] [/p] unformat [/partn] [/l] Description unformat restores only local hard disk drives and floppy disk drives; it cannot be used on network drives. The unformat command can also rebuild a corrupted disk partition table on a hard disk drive. Parameter drive: Specifies the drive that contains the disk on which you want to recover files. Switches /j Verifies that the file created by the mirror command has been saved and that it agrees with the system information on the disk. Like the /test switch, this parameter does not actually rebuild the disk. When the /j switch is used, it must be the only switch on the command line. /u Unformats a disk without using the mirror file. /l When used without the /partn switch, lists every file and sub- directory found by unformat. If you do not specify this switch, unformat lists only subdirectories and files that are fragmented. To suspend scrolling of the displayed list, press CtrlS; to resume scrolling, press any key. Use the /l switch only if you do not want unformat to use the file created by the mirror program. When the /l switch is used with the /partn switch, unformat displays the partition table of the current drive. The size of the parti- tion table is represented in megabytes and is based upon standard-sized sectors of 512 bytes. If the sectors on your hard disk are any other size, the displayed size in bytes may be incorrect. The total is the result of multiplying the number of sectors by 512. /test Shows how unformat would recreate the information on the disk, but does not actually unformat the disk. Use this switch only if you do not want unformat to use the file created by the mirror pro- gram. /p Sends output messages to the printer connected to LPT1. /partn Restores a corrupted partition table of a hard disk drive. This switch requires a PARTNSAV.FIL file that was created by using the mirror command with the /partn switch. Notes Limitation on the unformat command If the format command was used with the /u switch, unformat cannot restore the disk to its previous condition. Unformatting a disk by using a mirror file When a file created by the mirror program is available, unformat uses it to help restore the condition of the disk that existed before the disk was formatted or erased. The mirror program creates a file containing information about a disk's file allocation table and root directory. When this file is available, it provides the most reliable method for restoring a disk that was unin- tentionally formatted or erased. To enable unformat to recover files in the root directory that have been accidentally deleted, you should use the mirror command frequently to record the current state of your system. If your system contains a hard disk, it is highly recommended that you put the mirror command in your AUTOEXEC.BAT file to record the state of each hard disk in your system. The effect of using the format command without the /u switch is the same as the effect of using the mirror command. _________________________________________________________________________ CAUTION unformat attempts to restore the root directory of a disk to its condition when the mirror file was created. As a result, unformat cannot recover files in the root directory that were cre- ated or changed after the mirror file was created. Use the unfor- mat command to recover files deleted from the root directory by the del command only if the undelete command was unable to restore them. _________________________________________________________________________ By default, unformat uses the mirror file if it is available. If you specify the /l or /test switch, unformat does not use the mirror file. You can use the optional /j switch to verify that the mirror file exists and that it agrees with information on the formatted disk. With this switch, unformat does not actually rebuild the disk. When you rebuild a disk by using the mirror file, unformat displays the time and date of the most recent (last) mirror file on the disk and the time and date of the previous (prior) mirror file on the disk. Press L to update the system area of your disk with the latest information; or press P to update your disk with information from the prior mirror file. The only case in which you would want to use the prior mirror file is the following: you use the mirror command, then the disk is corrupted, then you use the format command. If you use the mirror command and the format command after the disk is corrupted, the unformat command will not work. unformat searches the disk for the mirror file. Because unformat searches the disk directly, the disk does not have to be ``readable'' by MS-DOS for unformat to work. Do not use the fdisk command before using unformat; doing so can destroy information not saved by the mirror program. Unformatting a disk without a mirror file If you do not have a mirror file or if your mirror file is very old, the unformat command can restore your disk by using information in the root directory and file allocation table on the disk. This method is slower and less reliable than restoring the disk by using the information in the mirror file, however, so you should use this method only if you cannot use a mirror file. If you specify the /l switch, unformat attempts to restore your disk by using information in the root directory and file allocation table. As unformat rebuilds the disk, it displays how many subdirectories it has found; and if you specified the /l switch, it shows you all files in each subdirectory. If unformat finds a file that appears to be fragmented (that is, stored in separate places on the disk), it cannot recover the file because it cannot locate the remaining portions of the file. In this case, the unformat command prompts you to confirm whether you want unformat to truncate the file (that is, recover only the first part of the file that it can locate) or delete the file altogether. If unformat does not prompt you for a specific file, that file is most likely intact. In certain circumstances, however, unformat may not recognize that a file is fragmented, even though it has located only a portion of the file. If this happens to a program file, the program does not run properly. If this happens to a data file, information is lost and the program that created the data file may not be able to read it. In these cases, your only recourse is to restore the files from your ori- ginal floppy disks or backup files. You can reduce how often unformat fails to recognize fragmented files by using the mirror program on a reg- ular basis. Restoring disk partition information In addition to restoring a disk after accidental formatting or erasure, you can also use the unformat command to rebuild the disk partition table of a hard disk when the table has become corrupted. Corruption of the disk partition table might be the problem when MS-DOS displays the fol- lowing message during an attempt by you or by a program to access a hard disk: Invalid drive specification This message indicates that MS-DOS cannot find the ``logical'' disk (which is defined by the partition table) on the physical hard disk. To be able to rebuild the disk partition table, you must have saved this information on a separate disk by using the mirror command with the /partn switch. The mirror program creates a file named PARTNSAV.FIL. To rebuild the disk partition table, type the following command: unformat /partn unformat prompts you to insert the floppy disk containing PARTNSAV.FIL and prompts you for the letter of the floppy disk drive. Insert the disk in the drive and type its letter at the prompt. Next, unformat checks the drive parameters that were saved in PARTNSAV.FIL against the actual drive parameters. If they do not match exactly, unformat does not restore the information. When you use unformat with the /partn switch, unformat prompts you to insert a system disk in drive A and press Enter to restart. This is necessary to inform MS-DOS that the partition-table information has changed. You should then use unformat without the /partn switch to recover your directories and file allocation table. Examples To determine whether unformat can restore a formatted disk in drive C by using a mirror file, type the following command: unformat c: /j To restore a formatted disk in drive A by using a mirror file (if avail- able), type the following command: unformat a: To determine whether unformat can restore a formatted disk in drive A without a mirror file, type the following command: unformat a: /test To restore a formatted disk in drive A without a mirror file, listing all files and subdirectories, type the following command: unformat a: /l Related commands For information about formatting a disk, see the format(CMD) command. For information about saving system information that can be used by unformat to restore a disk, see the mirror(CMD) command.