home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / private / mpc93mar.zip / 4MAT-CMD.DAT next >
Text File  |  1993-02-17  |  15KB  |  276 lines

  1.  
  2.              Beginner's Column:  The FORMAT Command
  3.  
  4.  
  5.      By Kenneth Johnson, Chicago Computer Society
  6.  
  7.      This month we will continue our look at the basic DOS commands by
  8.      considering one of the most powerful and dangerous commands in
  9.      DOS:  the FORMAT command.  FORMAT is probably the most dangerous
  10.      command that you use regularly, though as we'll see DOS 5.0 make
  11.      it a little safer.
  12.  
  13.      FORMAT prepares a disk for use by "initializing" the surface;
  14.      creating the sectors, File Allocation Table (FAT), and directory;
  15.      and checking for and marking bad sectors so they are not used.
  16.      FORMAT can also be used to create a bootable floppy disk and to
  17.      erase an old disk and check it for physical defects.
  18.  
  19.      Starting with DOS 4.0, FORMAT will also create a volume serial
  20.      number for each disk formatted.  The serial number is created
  21.      from the system clock, based on time the disk was formatted.  DOS
  22.      uses this serial number to keep track of disks, in particular
  23.      floppy disks.  (There were initially rumors that the serial
  24.      number could be used in a copy protection scheme since two disks
  25.      can have duplicate serial numbers only if formatted at the same
  26.      exact time, but this has not occurred.)  The volume serial number
  27.      is displayed as an eight digit hexadecimal number by some
  28.      programs and commands, including DIR and CHKDSK.
  29.  
  30.      A good analogy for what happens during a format is to think about
  31.      a developer building a new subdivision out in the country.  An
  32.      unformatted disk is like undeveloped land, with random hills,
  33.      gullies, and maybe a few random dirt roads.  The first thing the
  34.      developer does is flatten out the property, subdivide it into
  35.      regular-sized lots, and build a series of roads leading to each
  36.      lot.  The developer then builds an office, and puts a map of the
  37.      development on the wall.  Maybe a few of the lots have swampy
  38.      land and can't be built on; these are crossed off the map so that
  39.      they won't be sold.  As people start purchasing the lots, the
  40.      developer crosses them off the map one by one.
  41.  
  42.      The disk from the factory is just one large surface with random
  43.      bits and bytes on it.  Formatting takes the disk and divides it
  44.      into uniform sectors for use in storing files.  The random
  45.      magnetic hills and valleys are smoothed out, and the underlying
  46.      maps and structures (like the Directory and FAT) are created.
  47.      Any "bad" sectors unfit for holding data are marked.
  48.  
  49.      Continuing the analogy, reformatting a disk that currently
  50.      contains files is like SERIOUS urban renewal:  the bulldozers
  51.      come in and flatten everything in their path.  All the old
  52.      buildings and roads are destroyed, and replaced with new vacant
  53.      lots and new roads.  A map of the area shows there is nothing
  54.      left.
  55.  
  56.      FORMAT's power is what makes it so dangerous.  It can destroy
  57.      data that already exists on the disk.  You want to be
  58.      particularly careful not to format your hard disk.  Often the DOS
  59.      5.0 UNFORMAT program (or a similar utility from Norton Utilities
  60.      or PC Tools) can recover some or all of the data lost in an
  61.      accidental format ■ but don't bet your career on it!
  62.  
  63.      One of the best enhancements in DOS 5.0 is the "safe" format,
  64.      which is now the default.  If you format a previously formatted
  65.      disk, FORMAT will save the FAT and root directory information in
  66.      a hidden file (called the "MIRROR" file) on the disk.  The FAT
  67.      and root directory are then erased, but the data itself is not
  68.      deleted or physically overwritten.  The UNFORMAT command can use
  69.      this MIRROR file to restore the disk ■ if new data isn't written
  70.      to the disk meanwhile.  So with DOS 5.0 the rule is, if you
  71.      accidentally format a disk, attempt UNFORMAT ASAP.
  72.  
  73.      Since your worst nightmare is probably unknowingly formatting
  74.      your hard drive, there are a couple of safety nets in FORMAT to
  75.      discourage this from happening.  Starting with DOS 4.0, you have
  76.      to explicitly enter the drive identifier of the drive to format
  77.      (no more using the default drive, might be C:).  As far back as
  78.      DOS 3.0 you got an error message if you try to run FORMAT on a
  79.      hard disk:
  80.  
  81.      WARNING, ALL DATA IN NON-REMOVABLE DISK
  82.      DRIVE C: WILL BE LOST!
  83.      Proceed with format (Y/N)?
  84.  
  85.      You have to explicitly type in Y to start the format.
  86.  
  87.      As an additional precaution, starting with DOS 3.3 must enter the
  88.      volume label of the hard drive for the format to occur.
  89.      Unfortunately, if your hard disk doesn't have a volume label and
  90.      you simply press [ENTER] when prompted for the label, blank
  91.      matches blank and the format will begin.  So your first and
  92.      easiest protection against an accidental format is to use the
  93.      LABEL command (LABEL C:) to put a volume label on every hard disk
  94.      in your system.
  95.  
  96.      For even more protection, include the NULL character (ASCII 255)
  97.      as part of the volume label.  You enter NULL by holding down the
  98.      ALT key and typing 255 on the numeric keypad.  The NULL will look
  99.      like a space, but is a different character to DOS.  Anyone trying
  100.      to maliciously format the hard disk will probably type in a space
  101.      instead of the NULL since they appear the same.  But the labels
  102.      won't match so the format won't proceed.
  103.  
  104.      Now let's look at the FORMAT command itself.  The DOS 5.0 syntax
  105.      is:
  106.  
  107.      FORMAT drive: [/Q] [/U] [/V:label] [/F:size] [/S or /B]
  108.  
  109.      drive:    is the drive with the disk to format.  You must specify
  110.      the drive identifier with FORMAT.
  111.  
  112.      The FORMAT options include:
  113.  
  114.      /Q   Performs a Quick format of a previously formatted disk. The 
  115.      disk's FAT and root directory information are saved in the hidden 
  116.      MIRROR file, then cleared.  Other data is left on the disk, so 
  117.      recovery may be possible with UNFORMAT.  The disk is not checked for 
  118.      bad sectors.  If the disk has never been formatted, an unconditional 
  119.      format will be done.  The /Q switch was added in DOS 5.0.
  120.  
  121.      /U   Does an Unconditional, full format of the disk.  The FAT is
  122.      cleared, all data on the disk are deleted, and bad sectors marked.  
  123.      UNFORMAT cannot recover a disk that has been formatted with /U.  Use 
  124.      /U for new disks, to prepare older disks for reuse, and to completely 
  125.      "erase" disks of all information.  The /U switch was added in DOS 5.0.
  126.  
  127.      /V   Specifies the Volume label for the disk.  If you omit /V: you 
  128.      will be prompted for the label after the format is done. A volume 
  129.      label can be up to 11 characters and, unlike DOS file names, can 
  130.      include spaces but cannot include a period. However, if you use /V: 
  131.      the label text cannot have spaces because DOS interprets the text 
  132.      after the space as an invalid FORMAT parameter.  So keep your label 
  133.      in one "word." For example, /V:KEJPUBLISH will put the label 
  134.      KEJPUBLISH on the disk.  The /V: switch was added in DOS 4.0.
  135.  
  136.      /F   Provides an easy way to format a disk to a lower capacity than 
  137.      the default capacity of the disk drive.  The size can be expressed in 
  138.      either kilobytes or megabytes:  360, 720, 1200 or 1.2, and 1440 or 
  139.      1.44.  So to format 3½" disk to 720K in a high density (1.44Mb) drive, 
  140.      you would specify /F:720.
  141.  
  142.      /F:size was added in DOS 4.0 and replaces the older switches used to 
  143.      change the standard formatted capacity, though these switches are 
  144.      still available for compatibility:
  145.  
  146.      /1   formats 1-sided disk for use in one sided drives. /8 formats to 
  147.      the obsolete DOS 1.x 8-sector format. /4 formats a 360K Double Sided 
  148.      5¼" disk in a high density (1.2Mb) drive.  This is the same as using 
  149.      /F:360. /N:sectors /T:tracks ■ Available starting with DOS 3.3,
  150.      formats a disk to the number of sectors and tracks specified.  The 
  151.      most common specification is probably /N:9 /T:80, which formats a 
  152.      720K 3½" disk in a high density (1.44Mb) drive.  This is the same as 
  153.      using /F:720, which is a lot easier to remember!
  154.  
  155.      If you forget these "ancient" switches, don't worry; using /F is much 
  156.      simpler.
  157.  
  158.      A word of warning about /F:360:  When a 360K 5¼" disk is formatted in 
  159.      a 1.2Mb disk drive with /F:360 or /4, that disk can only be reliably 
  160.      read in another 1.2Mb drive.  You may get read errors when trying to 
  161.      use the disk in a 360K drive. This problem does not occur with 3½" 
  162.      disks, going between 1.44Mb and 720K drives.  To be on the safe side, 
  163.      always format 5¼" disks in the same capacity disk drive.
  164.  
  165.      /S  Creates a bootable floppy disk, formatting the disk then copying 
  166.      the hidden DOS System files IO.SYS and MSDOS.SYS (or their generic 
  167.      equivalents) and COMMAND.COM to the floppy. You can use /S to create
  168.      an emergency boot disk to allow you to boot up from the A: drive, an
  169.      important item every user should have.  [See the sidebar, "Creating
  170.      an Emergency Boot Disk" for more information.]
  171.  
  172.      /B   Transfers the DOS system files to the disk but not COMMAND.COM.
  173.  
  174.      With the new /Q and /U switches, it is important to understand
  175.      the what is meant by a "safe" format, and a "verified" format.
  176.      "Safe" means that the FAT and root directory information are
  177.      saved in a hidden file on the disk for possible recovery with
  178.      UNFORMAT.  "Verified" means that the entire diskette is checked
  179.      for errors and bad sectors marked so that they will not be used.
  180.  
  181.      Without the /Q and /U switches, FORMAT does a safe and verified
  182.      format.  This is the safest option:  recovery is possible and the
  183.      diskette is completely checked for bad areas.
  184.  
  185.      The /Q switch does a safe but unverified format.  The MIRROR file
  186.      is created for possible use by UNFORMAT, but the diskette is not
  187.      checked for bad sectors (which is why the format is "quick").
  188.      You would use /Q for previously formatted diskettes that you know
  189.      don't have any bad sectors.  You can also use /Q to completely
  190.      "erase" all files and directories on a diskette.  It can be much
  191.      faster than going into each subdirectory, deleting all the files
  192.      (and changing attributes if any files are Read-only, Hidden, or
  193.      System), then removing the directory.
  194.  
  195.      The /U switch does an unsafe but verified format.  The diskette
  196.      is scanned for bad sectors, but the FAT and root directory
  197.      information is not saved for possible unformatting.  You can use
  198.      /U to speed up the formatting of new diskettes since FORMAT
  199.      doesn't take the time to check the existing format.  Also use /U
  200.      to rehabilitate diskettes with write errors (though personally
  201.      I'll toss the bad disk ■ my data is worth more than the price of
  202.      a new diskette), and to reformat diskettes to a different
  203.      capacity with /F.
  204.  
  205.      Another important use of the /U switch is to truly erase
  206.      diskettes with confidential information.  Remember from last
  207.      month's column that DEL and ERASE don't physically erase data
  208.      from the diskette.  Unless written over, erased files can be
  209.      recovered with UNDELETE or a similar unerase program.  Similarly,
  210.      if you format a diskette without /U, the data remains and could
  211.      be restored with UNFORMAT.  If a diskette has sensitive
  212.      information, reformat it with /U to write over the data.
  213.  
  214.      [With the /U switch the data is overwritten and obscured to the
  215.      normal person trying to read or unformat the disk.  However, a
  216.      data recovery lab could likely retrieve the information using
  217.      sophisticated tools.  For truly sensitive data, use a WIPE
  218.      utility such as those available from Norton Utilities or PC
  219.      Tools.  WIPE programs perform multiple writes over the disk,
  220.      following a government standard for deleting sensitive data.]
  221.  
  222.      So what if disaster strikes and you format a disk accidentally?
  223.      The key is to run UNFORMAT immediately.  UNFORMAT will attempt to
  224.      recover the disk with the MIRROR file if one exists; if not it
  225.      will try to recover based on the data that remains.  If the newly
  226.      formatted disk is used (i.e., files are written to it), your
  227.      chances of recovery drop significantly.  We'll look at UNFORMAT
  228.      in detail in next month's column.
  229.  
  230.      FORMAT is both a necessary and a dangerous command in our
  231.      computing lives.  However, with DOS 5.0 it has become a little
  232.      more forgiving than in the past.  Keep these points in mind when
  233.      using FORMAT:
  234.  
  235.      ■    For the safest FORMAT, don't use either the /U or the /Q
  236.      switches.  FORMAT will save the recovery information in the
  237.      MIRROR file, and check the disk for bad sectors.
  238.  
  239.      ■    Use the /U switch for unconditional formatting of new disks,
  240.      to revitalize older disks, and to delete sensitive data on a
  241.      disk.  Remember though you cannot UNFORMAT after using /U.
  242.  
  243.      ■    Use the /Q switch to quickly format previously formatted
  244.      disks that you don't suspect have bad areas.  Keep in mind
  245.      the disk is not scanned for bad sectors.  /Q is a fast way
  246.      to "erase" all files and directories from a floppy disk.
  247.  
  248.      ■    Label your hard drive (LABEL C:).  Since the label must be
  249.      entered to format a hard drive, this is the easiest way to
  250.      protect against an accidental hard disk format.  For added
  251.      security, include the NULL character (ASCII 255) as part of
  252.      the label.  It will look like a space, but anyone trying to
  253.      format the hard disk must enter the NULL in the label for
  254.      the format to proceed.
  255.  
  256.      ■    Remember that 360K 5¼" disks formatted in a 1.2Mb drive with
  257.      the /F:360 or /4 switch can only be reliably read in another
  258.      1.2Mb drive.  Always try to format 360K 5¼" disks in a 360K
  259.      disk drive.
  260.  
  261.      ■    Create an emergency boot disk with FORMAT A: /S.  This will
  262.      allow you to boot your computer and bypass the C: drive.
  263.      [See the sidebar, "Creating an Emergency Boot Disk."]
  264.  
  265.      ■    Finally, in case of an accidental FORMAT, run UNFORMAT as
  266.      soon as possible.  As long as no new files are written to
  267.      the disk, and that you didn't use the /U switch, the chances
  268.      of recovery are good.  We'll look at UNFORMAT next month.
  269.  
  270.  
  271.      ===================================================
  272.      Author Information:  Kenneth Johnson is Training and Support
  273.      Manager at the law firm of Mayer, Brown & Platt in Chicago.  He
  274.      writes a monthly Beginner's Column and is contributing editor for
  275.      Hard-Copy, the Journal of the Chicago Computer Society.
  276.