home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / magazine / mpc93jun.zip / UN4MAT.TXT < prev    next >
Text File  |  1993-05-30  |  17KB  |  373 lines

  1.  
  2.      The UNFORMAT Command
  3.      By Kenneth Johnson, Chicago Computer Society
  4.  
  5.      In February's column we looked at the FORMAT command, and
  6.      discussed briefly how to deal with an accidental format.  This
  7.      month we'll continue with an in depth look at the UNFORMAT
  8.      command.  Introduced with DOS 5.0, UNFORMAT attempts to recover a
  9.      disk that has been inadvertently formatted.  Depending on the
  10.      type of format and whether any data has been written to the disk
  11.      meanwhile, UNFORMAT probably can completely recover the disk. 
  12.      UNFORMAT can also be used together with the MIRROR program to
  13.      restore a hard disk's partition table.  We'll look at both
  14.      functions.
  15.  
  16.      First, a quick review the FORMAT command.  FORMAT prepares a disk
  17.      for use by "initializing" the surface; creating the sectors, File
  18.      Allocation Table (FAT), and directory; and checking for and
  19.      marking bad sectors so they are not used.  FORMAT can also be
  20.      used to create a bootable floppy disk and to erase an old disk
  21.      and check it for physical defects.  
  22.  
  23.      A major enhancement in DOS 5.0 is the "safe" format, which is now
  24.      the default.  If you format a previously formatted disk, FORMAT
  25.      will save the FAT and root directory information in a hidden file
  26.      (called the "MIRROR image" file) on the disk.  The FAT and root
  27.      directory are then erased, but the data itself is not deleted or
  28.      physically overwritten.  The UNFORMAT command can use this MIRROR
  29.      file to restore the disk.
  30.  
  31.      If you need to recover an accidentally formatted disk, the key is
  32.      to run UNFORMAT immediately.  UNFORMAT will attempt to recover
  33.      the disk with the MIRROR image file if one exists; if not it will
  34.      try to recover based on the data that remains.  When the newly
  35.      formatted disk is used (i.e., files are written to it), your
  36.      chances of recovery drop significantly.  
  37.      
  38.      The one situation where UNFORMAT cannot help is a disk that has
  39.      been formatted with the "/U" switch.  /U does an Unconditional,
  40.      full format; the FAT is cleared, and all data on the disk is
  41.      overwritten.  Because the information is physically gone,
  42.      UNFORMAT cannot recover the disk. 
  43.  
  44.  
  45.      Recovering a Disk with UNFORMAT
  46.      
  47.      If you've accidentally formatted a disk using DOS 5.0, and didn't
  48.      use the /U switch, the format didn't physically delete
  49.      information on the disk and can possibly be undone.  The syntax
  50.      of the UNFORMAT command is:
  51.      
  52.      UNFORMAT [d:] [/J] 
  53.      UNFORMAT [d:] [/L] [/P] [/TEST] [/U]
  54.      UNFORMAT /PARTN [/L]
  55.  
  56.      d:   is the drive containing the disk to unformat.  It is
  57.           required unless using the /PARTN switch.
  58.  
  59.      /J   Verifies the existence of the MIRROR image file and checks
  60.           whether it corresponds with the system area of the disk. 
  61.           This option does not actually do the unformatting.
  62.  
  63.      /L   When used by itself, it lists all directories and files
  64.           found on the formatted disk without making use of the MIRROR
  65.           image file.  When used with the /PARTN switch, it displays
  66.           the current partition table.
  67.  
  68.      /P   Sends output messages of the procedure to the printer
  69.           (specifically LPT1, the first parallel port).
  70.  
  71.      /TEST     Simulates the unformat without using the MIRROR image
  72.                file.  UNFORMAT will show what files and subdirectories
  73.                will be recovered, but does not do the unformatting.
  74.  
  75.      /U   Unformats the disk without using a MIRROR image file.  You
  76.           would use this switch if the MIRROR file exists but is out
  77.           of date.
  78.  
  79.      /PARTN    Restores the hard disk partition table based on
  80.                information in the file PARTNSAV.FIL, created
  81.                previously on a floppy disk with the MIRROR /PARTN
  82.                command.  We'll discuss this use of UNFORMAT below.
  83.  
  84.      Unless you explicitly tell it otherwise with /U or /L, UNFORMAT
  85.      will search the disk for a MIRROR image file.  If more than one
  86.      is found, you can choose which file to use (you'll be shown the
  87.      dates and times each MIRROR file was created).  Upon your
  88.      confirmation, UNFORMAT will replace the system information on the
  89.      disk with that from the MIRROR file.  The FAT and root directory
  90.      are both restored.  If no information has been written to the
  91.      disk since the format, the recovery is 100% complete and nothing
  92.      else needs to be done.
  93.  
  94.      If the MIRROR image file is not used and the disk wasn't
  95.      unconditionally formatted, UNFORMAT will search the disk for
  96.      subdirectories and rebuild the disk's directory tree ■ a time
  97.      consuming process.  First level subdirectories will be restored
  98.      as SUBDIR.1, SUBDIR.2, etc. since their original names were lost
  99.      when the root directory was cleared.   Files in subdirectories
  100.      will be recovered as much as possible, but if a file is
  101.      fragmented UNFORMAT only can recover the first fragment.  You'll
  102.      be asked if fragmented files should be truncated or deleted.
  103.  
  104.      Unfortunately, UNFORMAT cannot recover any files in the root
  105.      directory because their directory entries are gone.  If you must
  106.      recover those files, you'll have to use a third-party utility
  107.      like Norton Utilities that lets you examine available clusters
  108.      and put them together into files.  Doing so is slow and
  109.      difficult; Peter Norton himself has likened it to the Iranians
  110.      trying to piece together the shredded documents at the American
  111.      Embassy!
  112.  
  113.      Let's look at what happens when you UNFORMAT with a MIRROR image
  114.      file.  Suppose you've accidentally formatted the disk in the A:
  115.      drive, but used DOS 5.0 and did not use the /U switch.  The
  116.      command
  117.  
  118.           UNFORMAT A:
  119.  
  120.      will display the following messages:
  121.  
  122.      Restores the system area of your disk by using the image file 
  123.      created by the MIRROR command.
  124.  
  125.      WARNING!!     WARNING!!
  126.  
  127.      This command should be used only to recover from the inadvertent use 
  128.      of the FORMAT command or the RECOVER command.  Any other use of the 
  129.      UNFORMAT command may cause you to lose data!  Files modified since the 
  130.      MIRROR image file was created may be lost.
  131.  
  132.      Searching disk for MIRROR image.
  133.  
  134.      The last time the MIRROR or FORMAT command was used was at 11:30 on 
  135.      02-24-93.
  136.  
  137.      The MIRROR image file has been validated.
  138.  
  139.      Are you sure you want to update the system area of your drive A 
  140.      (Y/N)?  Y  The system area of drive A has been rebuilt.
  141.  
  142.      You may need to restart the system.
  143.  
  144.      After the disk is unformatted, the FAT and directories will be 
  145.      restored to the way they were when the MIRROR image file was created.  
  146.      If no new data has been added to the disk since then, the directory 
  147.      and FAT will be correct.  If the formatted disk was used there may 
  148.      be problems with certain files, but at least you
  149.      won't have lost everything.
  150.  
  151.      To verify the MIRROR image file without actually doing the unformat, 
  152.      use the /J switch.
  153.  
  154.      UNFORMAT A: /J
  155.  
  156.      will display the following:
  157.  
  158.      Restores the system area of your disk by using the image file 
  159.      created by the MIRROR command.
  160.  
  161.      WARNING!!     WARNING!!
  162.  
  163.      This command should be used only to recover from the inadvertent use 
  164.      of the FORMAT command or the RECOVER command.  Any other use of the 
  165.      UNFORMAT command may cause you to lose data!  Files modified since 
  166.      the MIRROR image file was created may be lost.
  167.  
  168.      Searching disk for MIRROR image.
  169.  
  170.      Just checking this time.  No changes written to disk.
  171.  
  172.      The last time the MIRROR or FORMAT command was used was at 11:30 on 
  173.      02-24-93.
  174.  
  175.      The MIRROR image file has been validated.
  176.  
  177.      The system area does not agree with the MIRROR image file.
  178.  
  179.  
  180.      The system area doesn't agree because it was cleared by the
  181.      format.  If the MIRROR image file does agree with the system area
  182.      the last message will be:
  183.  
  184.      The system area of drive A has been verified to agree with the 
  185.      MIRROR image file.
  186.  
  187.      Unformatting without using the MIRROR image file is incomplete at
  188.      best, but is probably better than losing everything.  It may be
  189.      necessary if you formatted with an earlier version of DOS, used a
  190.      third-party formatting utility that doesn't save the MIRROR file,
  191.      or if the MIRROR file itself is corrupt or missing.  Remember
  192.      that you can't recover files from the root directory but probably
  193.      can get back files in subdirectories.
  194.  
  195.      You can use the /L switch to see the directories and files that
  196.      can be found.
  197.      
  198.      UNFORMAT A: /L
  199.           
  200.      will display:
  201.           
  202.  
  203.      CAUTION!
  204.  
  205.      This attempts to recover all the files lost after a format, 
  206.      assuming you've not been using the MIRROR command.  This method 
  207.      cannot guarantee complete recovery of your files.
  208.  
  209.      The search-phase is safe; nothing is altered on the disk.  You will 
  210.      be prompted again before changes are written to the disk.
  211.  
  212.      Using drive A:
  213.  
  214.      Are you sure you want to do this?
  215.      If so, press Y; anything else cancels.
  216.      ? Y
  217.  
  218.      Searching disk. . . .
  219.      x% searched, x subdirectories found.
  220.      
  221.      The count will continue until the entire disk has been searched. 
  222.      Next, UNFORMAT will "walk the directory tree," searching each
  223.      directory for files.  You'll see a list of all files and
  224.      subdirectories as UNFORMAT finds them.  Remember that all first-
  225.      level subdirectories will have lost their original names and will
  226.      be displayed as SUBDIR.1, SUBDIR.2, and so forth.
  227.  
  228.      You'll then be asked if you're ready to do the unformat.  If you
  229.      say Yes, UNFORMAT will recover the subdirectories and files.  If
  230.      a file is fragmented, UNFORMAT can only recover the first
  231.      fragment.  In such cases you'll be asked if you want to truncate
  232.      or delete the file.
  233.  
  234.      When UNFORMAT is complete, you'll want to do a DIR and examine
  235.      the directories and files on the disk.  If some files are still
  236.      missing, you can try the UNDELETE command to attempt recovery of
  237.      additional files.
  238.  
  239.      As you can see, unformatting with the MIRROR image file is easier
  240.      and much more certain.  So when running FORMAT, do a "safe"
  241.      format by not using the /U switch.  This will ensure the MIRROR
  242.      image file is created and that the data isn't physically
  243.      overwritten on the disk.  If you've accidentally formatted an
  244.      important disk, run UNFORMAT as soon as possible ■ certainly
  245.      before anything is written to the disk.
  246.  
  247.      Recovering a Partition Table with UNFORMAT
  248.  
  249.      Another, perhaps less obvious use of the UNFORMAT command is to
  250.      restore a damaged hard disk partition table.  UNFORMAT does this
  251.      together with the MIRROR command, which saves a copy of the
  252.      partition table and boot record information in a file on a floppy
  253.      disk.
  254.  
  255.      Each physical hard disk is organized into one or more partitions;
  256.      each partition is a logical disk drive.  For example, one
  257.      physical 130Mb disk drive might be partitioned into two logical
  258.      drives, a 100MB C: drive and a 30Mb D: drive.  The first sector
  259.      on each hard drive contains a partition table, with one entry for
  260.      each partition.  These entries have information on where the
  261.      partition starts, how many sectors it contains, and whether a
  262.      particular partition is the one to boot from.  The partition
  263.      table also includes the master boot record and the "bootstrap"
  264.      program that loads the operating system when you turn on the
  265.      computer.
  266.  
  267.      A partition table can become corrupted because of a hardware
  268.      problem or virus, or if you've been editing disk sectors and made
  269.      an error.  Viruses particularly like attacking the partition
  270.      table since a damaged table makes the entire hard disk
  271.      inaccessible.  If you can't boot from the hard disk, or get an
  272.      "Invalid drive specification" error when trying to access a hard
  273.      disk, it might be a damaged partition table.
  274.      
  275.      Before disaster strikes, use the DOS 5.0 MIRROR command to save a
  276.      copy of the partition table and boot record to a floppy disk. 
  277.      UNFORMAT can then use this copy to restore the hard disk
  278.      partition table.  The command is:
  279.      
  280.      MIRROR /PARTN
  281.  
  282.      You'll be prompted to insert a formatted disk into a specified
  283.      disk drive.  MIRROR will read the partition information for all
  284.      the hard drives and write it out to a file called PARTNSAV.FIL on
  285.      the floppy disk.  
  286.  
  287.      Ideally you should write PARTNSAV.FIL to your emergency boot
  288.      disk.  The emergency boot disk allows you to boot your computer
  289.      from the A: drive, thus bypassing the C: drive which may be
  290.      unaccessible.  Include the file UNFORMAT.EXE on the emergency
  291.      boot disk also, since you'll need it to restore the partition
  292.      table.  (See "Creating an Emergency Boot Disk" in the February
  293.      1993 Hard-Copy for more information.)
  294.      
  295.      To restore a damaged partition table, use this form of the
  296.      UNFORMAT command:
  297.      
  298.      UNFORMAT /PARTN [/L]
  299.  
  300.      You'll be prompted to insert the disk containing the PARTNSAV.FIL
  301.      file created by MIRROR.  Adding the /L switch will display the
  302.      disk's partition table, without doing any recovery.  Here is an
  303.      example display of the partition table information:
  304.      
  305.      
  306.      Hard Disk Partition Table display.
  307.      
  308.      Drive # 80h has 1023 cylinders, 9 heads, 17 sectors (from BIOS).
  309.      
  310.      The following table is from drive 80h, cylinder 0, head 0, sector 1:
  311.      
  312.                  Total_size      Start_partition  End_partition
  313.    Type        Bytes   Sectors   Cyl Head Sector  Cyl  Head Sector    Rel#
  314. -----------   ----------------  ---------------  ----------------   ------
  315. Huge  Boot      76M    15602     0    1     1    1022   8     17      17
  316.  
  317.      The Type "Huge" indicates a partition greater than 32Mb.  You
  318.      might also see "BIGDOS," or perhaps "DOS12" or "DOS16" indicating
  319.      DOS partitions with 12 or 16 byte FAT entries.  "Boot" identifies
  320.      this as the partition booted from.  If your disk has partitions
  321.      for other operating systems (such as Unix) or set up by a non-DOS
  322.      disk manager (such as OnTrack's Disk Manager), you'll see other
  323.      names here.
  324.      
  325.      Total_size shows the size of the partition in megabytes and the
  326.      total number of sectors.  Start_partition shows where the
  327.      partition starts, End_partition where the partition ends.  Rel#
  328.      shows the start of the partition in sectors from the beginning of
  329.      the disk.  If your partition table is damaged, you'll probably
  330.      see "garbage" or error messages in this display.
  331.      
  332.      
  333.      UNFORMAT and MIRROR are important additions to DOS 5.0 to recover
  334.      from accidental formats and damage to your partition table.  Some
  335.      points to keep in mind with UNFORMAT, MIRROR, and FORMAT:
  336.  
  337.      ■    For the safest FORMAT don't use the /U switch.  FORMAT will
  338.           save the recovery information in the MIRROR image file for
  339.           possible use by UNFORMAT.
  340.                
  341.      ■    UNFORMAT can never restore a disk that was unconditionally
  342.           formatted with /U.
  343.                     
  344.      ■    In case of an accidental format run UNFORMAT as soon as
  345.           possible.  As long as no new files are written to the disk,
  346.           and if you didn't use the /U switch, the chances of recovery
  347.           are excellent.
  348.  
  349.      ■    If you need to unformat a disk, first do the UNFORMAT with
  350.           the /J switch.  This will verify the MIRROR image file
  351.           exists and checks it against the current system area, but
  352.           doesn't do the unformat.  It will give you an idea how
  353.           successful the unformat might be.
  354.  
  355.      ■    If you believe the MIRROR image file is out of date, you can
  356.           use the /U switch to tell UNFORMAT to recover the disk
  357.           without using the MIRROR file.  Remember though that files
  358.           in the root directory cannot be restored.
  359.  
  360.      ■    If you want to see how UNFORMAT would recover the disk
  361.           without the MIRROR image file, and without doing the
  362.           unformat, use the /TEST switch.
  363.  
  364.      ■    Use the MIRROR /PARTN command to save your hard disk
  365.           partition information to your emergency boot disk.  Make
  366.           sure to include UNFORMAT.EXE on the disk.  If your partition
  367.           table is corrupted, you can use UNFORMAT /PARTN to restore
  368.           it from the floppy disk.
  369.  
  370.      ■    And remember ■ particularly with a hard disk ■ there is no
  371.           substitute for a good backup of your data.
  372.  
  373.