home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
private
/
mpc93mar.zip
/
4MAT-CMD.DAT
next >
Wrap
Text File
|
1993-02-17
|
15KB
|
276 lines
Beginner's Column: The FORMAT Command
By Kenneth Johnson, Chicago Computer Society
This month we will continue our look at the basic DOS commands by
considering one of the most powerful and dangerous commands in
DOS: the FORMAT command. FORMAT is probably the most dangerous
command that you use regularly, though as we'll see DOS 5.0 make
it a little safer.
FORMAT prepares a disk for use by "initializing" the surface;
creating the sectors, File Allocation Table (FAT), and directory;
and checking for and marking bad sectors so they are not used.
FORMAT can also be used to create a bootable floppy disk and to
erase an old disk and check it for physical defects.
Starting with DOS 4.0, FORMAT will also create a volume serial
number for each disk formatted. The serial number is created
from the system clock, based on time the disk was formatted. DOS
uses this serial number to keep track of disks, in particular
floppy disks. (There were initially rumors that the serial
number could be used in a copy protection scheme since two disks
can have duplicate serial numbers only if formatted at the same
exact time, but this has not occurred.) The volume serial number
is displayed as an eight digit hexadecimal number by some
programs and commands, including DIR and CHKDSK.
A good analogy for what happens during a format is to think about
a developer building a new subdivision out in the country. An
unformatted disk is like undeveloped land, with random hills,
gullies, and maybe a few random dirt roads. The first thing the
developer does is flatten out the property, subdivide it into
regular-sized lots, and build a series of roads leading to each
lot. The developer then builds an office, and puts a map of the
development on the wall. Maybe a few of the lots have swampy
land and can't be built on; these are crossed off the map so that
they won't be sold. As people start purchasing the lots, the
developer crosses them off the map one by one.
The disk from the factory is just one large surface with random
bits and bytes on it. Formatting takes the disk and divides it
into uniform sectors for use in storing files. The random
magnetic hills and valleys are smoothed out, and the underlying
maps and structures (like the Directory and FAT) are created.
Any "bad" sectors unfit for holding data are marked.
Continuing the analogy, reformatting a disk that currently
contains files is like SERIOUS urban renewal: the bulldozers
come in and flatten everything in their path. All the old
buildings and roads are destroyed, and replaced with new vacant
lots and new roads. A map of the area shows there is nothing
left.
FORMAT's power is what makes it so dangerous. It can destroy
data that already exists on the disk. You want to be
particularly careful not to format your hard disk. Often the DOS
5.0 UNFORMAT program (or a similar utility from Norton Utilities
or PC Tools) can recover some or all of the data lost in an
accidental format ■ but don't bet your career on it!
One of the best enhancements in DOS 5.0 is the "safe" format,
which is now the default. If you format a previously formatted
disk, FORMAT will save the FAT and root directory information in
a hidden file (called the "MIRROR" file) on the disk. The FAT
and root directory are then erased, but the data itself is not
deleted or physically overwritten. The UNFORMAT command can use
this MIRROR file to restore the disk ■ if new data isn't written
to the disk meanwhile. So with DOS 5.0 the rule is, if you
accidentally format a disk, attempt UNFORMAT ASAP.
Since your worst nightmare is probably unknowingly formatting
your hard drive, there are a couple of safety nets in FORMAT to
discourage this from happening. Starting with DOS 4.0, you have
to explicitly enter the drive identifier of the drive to format
(no more using the default drive, might be C:). As far back as
DOS 3.0 you got an error message if you try to run FORMAT on a
hard disk:
WARNING, ALL DATA IN NON-REMOVABLE DISK
DRIVE C: WILL BE LOST!
Proceed with format (Y/N)?
You have to explicitly type in Y to start the format.
As an additional precaution, starting with DOS 3.3 must enter the
volume label of the hard drive for the format to occur.
Unfortunately, if your hard disk doesn't have a volume label and
you simply press [ENTER] when prompted for the label, blank
matches blank and the format will begin. So your first and
easiest protection against an accidental format is to use the
LABEL command (LABEL C:) to put a volume label on every hard disk
in your system.
For even more protection, include the NULL character (ASCII 255)
as part of the volume label. You enter NULL by holding down the
ALT key and typing 255 on the numeric keypad. The NULL will look
like a space, but is a different character to DOS. Anyone trying
to maliciously format the hard disk will probably type in a space
instead of the NULL since they appear the same. But the labels
won't match so the format won't proceed.
Now let's look at the FORMAT command itself. The DOS 5.0 syntax
is:
FORMAT drive: [/Q] [/U] [/V:label] [/F:size] [/S or /B]
drive: is the drive with the disk to format. You must specify
the drive identifier with FORMAT.
The FORMAT options include:
/Q Performs a Quick format of a previously formatted disk. The
disk's FAT and root directory information are saved in the hidden
MIRROR file, then cleared. Other data is left on the disk, so
recovery may be possible with UNFORMAT. The disk is not checked for
bad sectors. If the disk has never been formatted, an unconditional
format will be done. The /Q switch was added in DOS 5.0.
/U Does an Unconditional, full format of the disk. The FAT is
cleared, all data on the disk are deleted, and bad sectors marked.
UNFORMAT cannot recover a disk that has been formatted with /U. Use
/U for new disks, to prepare older disks for reuse, and to completely
"erase" disks of all information. The /U switch was added in DOS 5.0.
/V Specifies the Volume label for the disk. If you omit /V: you
will be prompted for the label after the format is done. A volume
label can be up to 11 characters and, unlike DOS file names, can
include spaces but cannot include a period. However, if you use /V:
the label text cannot have spaces because DOS interprets the text
after the space as an invalid FORMAT parameter. So keep your label
in one "word." For example, /V:KEJPUBLISH will put the label
KEJPUBLISH on the disk. The /V: switch was added in DOS 4.0.
/F Provides an easy way to format a disk to a lower capacity than
the default capacity of the disk drive. The size can be expressed in
either kilobytes or megabytes: 360, 720, 1200 or 1.2, and 1440 or
1.44. So to format 3½" disk to 720K in a high density (1.44Mb) drive,
you would specify /F:720.
/F:size was added in DOS 4.0 and replaces the older switches used to
change the standard formatted capacity, though these switches are
still available for compatibility:
/1 formats 1-sided disk for use in one sided drives. /8 formats to
the obsolete DOS 1.x 8-sector format. /4 formats a 360K Double Sided
5¼" disk in a high density (1.2Mb) drive. This is the same as using
/F:360. /N:sectors /T:tracks ■ Available starting with DOS 3.3,
formats a disk to the number of sectors and tracks specified. The
most common specification is probably /N:9 /T:80, which formats a
720K 3½" disk in a high density (1.44Mb) drive. This is the same as
using /F:720, which is a lot easier to remember!
If you forget these "ancient" switches, don't worry; using /F is much
simpler.
A word of warning about /F:360: When a 360K 5¼" disk is formatted in
a 1.2Mb disk drive with /F:360 or /4, that disk can only be reliably
read in another 1.2Mb drive. You may get read errors when trying to
use the disk in a 360K drive. This problem does not occur with 3½"
disks, going between 1.44Mb and 720K drives. To be on the safe side,
always format 5¼" disks in the same capacity disk drive.
/S Creates a bootable floppy disk, formatting the disk then copying
the hidden DOS System files IO.SYS and MSDOS.SYS (or their generic
equivalents) and COMMAND.COM to the floppy. You can use /S to create
an emergency boot disk to allow you to boot up from the A: drive, an
important item every user should have. [See the sidebar, "Creating
an Emergency Boot Disk" for more information.]
/B Transfers the DOS system files to the disk but not COMMAND.COM.
With the new /Q and /U switches, it is important to understand
the what is meant by a "safe" format, and a "verified" format.
"Safe" means that the FAT and root directory information are
saved in a hidden file on the disk for possible recovery with
UNFORMAT. "Verified" means that the entire diskette is checked
for errors and bad sectors marked so that they will not be used.
Without the /Q and /U switches, FORMAT does a safe and verified
format. This is the safest option: recovery is possible and the
diskette is completely checked for bad areas.
The /Q switch does a safe but unverified format. The MIRROR file
is created for possible use by UNFORMAT, but the diskette is not
checked for bad sectors (which is why the format is "quick").
You would use /Q for previously formatted diskettes that you know
don't have any bad sectors. You can also use /Q to completely
"erase" all files and directories on a diskette. It can be much
faster than going into each subdirectory, deleting all the files
(and changing attributes if any files are Read-only, Hidden, or
System), then removing the directory.
The /U switch does an unsafe but verified format. The diskette
is scanned for bad sectors, but the FAT and root directory
information is not saved for possible unformatting. You can use
/U to speed up the formatting of new diskettes since FORMAT
doesn't take the time to check the existing format. Also use /U
to rehabilitate diskettes with write errors (though personally
I'll toss the bad disk ■ my data is worth more than the price of
a new diskette), and to reformat diskettes to a different
capacity with /F.
Another important use of the /U switch is to truly erase
diskettes with confidential information. Remember from last
month's column that DEL and ERASE don't physically erase data
from the diskette. Unless written over, erased files can be
recovered with UNDELETE or a similar unerase program. Similarly,
if you format a diskette without /U, the data remains and could
be restored with UNFORMAT. If a diskette has sensitive
information, reformat it with /U to write over the data.
[With the /U switch the data is overwritten and obscured to the
normal person trying to read or unformat the disk. However, a
data recovery lab could likely retrieve the information using
sophisticated tools. For truly sensitive data, use a WIPE
utility such as those available from Norton Utilities or PC
Tools. WIPE programs perform multiple writes over the disk,
following a government standard for deleting sensitive data.]
So what if disaster strikes and you format a disk accidentally?
The key is to run UNFORMAT immediately. UNFORMAT will attempt to
recover the disk with the MIRROR file if one exists; if not it
will try to recover based on the data that remains. If the newly
formatted disk is used (i.e., files are written to it), your
chances of recovery drop significantly. We'll look at UNFORMAT
in detail in next month's column.
FORMAT is both a necessary and a dangerous command in our
computing lives. However, with DOS 5.0 it has become a little
more forgiving than in the past. Keep these points in mind when
using FORMAT:
■ For the safest FORMAT, don't use either the /U or the /Q
switches. FORMAT will save the recovery information in the
MIRROR file, and check the disk for bad sectors.
■ Use the /U switch for unconditional formatting of new disks,
to revitalize older disks, and to delete sensitive data on a
disk. Remember though you cannot UNFORMAT after using /U.
■ Use the /Q switch to quickly format previously formatted
disks that you don't suspect have bad areas. Keep in mind
the disk is not scanned for bad sectors. /Q is a fast way
to "erase" all files and directories from a floppy disk.
■ Label your hard drive (LABEL C:). Since the label must be
entered to format a hard drive, this is the easiest way to
protect against an accidental hard disk format. For added
security, include the NULL character (ASCII 255) as part of
the label. It will look like a space, but anyone trying to
format the hard disk must enter the NULL in the label for
the format to proceed.
■ Remember that 360K 5¼" disks formatted in a 1.2Mb drive with
the /F:360 or /4 switch can only be reliably read in another
1.2Mb drive. Always try to format 360K 5¼" disks in a 360K
disk drive.
■ Create an emergency boot disk with FORMAT A: /S. This will
allow you to boot your computer and bypass the C: drive.
[See the sidebar, "Creating an Emergency Boot Disk."]
■ Finally, in case of an accidental FORMAT, run UNFORMAT as
soon as possible. As long as no new files are written to
the disk, and that you didn't use the /U switch, the chances
of recovery are good. We'll look at UNFORMAT next month.
===================================================
Author Information: Kenneth Johnson is Training and Support
Manager at the law firm of Mayer, Brown & Platt in Chicago. He
writes a monthly Beginner's Column and is contributing editor for
Hard-Copy, the Journal of the Chicago Computer Society.