home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: SysTools / SysTools.zip / chkpart.zip / CHKPART.DOC next >
Text File  |  1997-02-20  |  14KB  |  344 lines

  1.  
  2.  CHKPART Version 1.0 - An OS/2 program that checks and displays the partition
  3.  table chain (MBR/EBR) on disk drives.
  4.  
  5.  Written by:
  6.  
  7.   Doug Azzarito
  8.   IBM OS/2 Change Team
  9.   Azzarito@austin.ibm.com
  10.  
  11.  (c) 1994-1997, IBM Corp. All rights reserved.
  12.  
  13.  This program is for internal use only, and for use by customers who use it
  14.  under the direction of OS/2 support personnel.  NO ONE MAY USE, REDISTRIBUTE
  15.  OR UPLOAD THIS PROGRAM TO AN ON-LINE SOFTWARE REPOSITORY WITHOUT PRIOR
  16.  WRITTEN PERMISSION FROM THE AUTHOR.
  17.  
  18.  What is it?
  19.  
  20.  CHKPART is an OS/2 text-mode program that will scan the hard disk partition
  21.  tables (the Master Boot Record, or MBR, and the Extended Boot Records, or
  22.  EBRs), looking for errors.  It won't fix any errors, and does not write to
  23.  your hard disk.  It just displays the results of the search.  The output is
  24.  not meant for "casual" users, but if you are familiar with the structure of
  25.  the MBR/EBR, you should be able to use the output from CHKPART to fix the
  26.  error yourself.
  27.  
  28.  HINT: If you save the output from CHKPART, the information in the report
  29.        can help recover a system if the partition tables are destroyed
  30.        (virus, accidental FDISK use, disk crash, etc).
  31.  
  32.  CHKPART looks for things like:
  33.  
  34.     Partitions that don't end on a cylinder boundary
  35.     BPBs that have a different geometry than the drive unit
  36.     HPFS sizes that don't match the partition size
  37.     And anything else I could find by walking the MBR/EBR chain.
  38.  
  39.  To run CHKPART, just type CHKPART from an OS/2 command session.  It takes
  40.  no parameters, but since you will usually want to save the output to a
  41.  file, the best way to run it is with the command:
  42.  
  43.    CHKPART > A:\CHKPART.LOG
  44.  
  45.  You can then view the file A:\CHKPART.LOG, which contains the results from
  46.  CHKPART's scan.  If there are any errors, you'll see a message at the end of
  47.  the report, and then you can scan through the report to see exactly what
  48.  CHKPART found.
  49.  
  50.  If you don't understand the output from CHKPART, it would take a book to
  51.  explain it all.  If you are familiar with the layout of the MBR and
  52.  EBRs, you will probably recognize just about everything in the report.
  53.  
  54.  Some rules that will help you decipher the output:
  55.  
  56.   - Most numbers are reported in HEX and DECIMAL, with the decimal value in
  57.     parenthesis.  Example:   01A2 (418)
  58.  
  59.   - If a number is calculated by CHKPART (using other values obtained by 
  60.     querying the system), the number will be followed by an asterisk (*).
  61.     The calculation and the source of the number is described later in this
  62.     document.
  63.  
  64.  A CHKPART report looks like this:
  65.  ---------------------------------------------------------------------------
  66.  Partition Diagnostic Utility - Version 1.00
  67.  Copyright (c) 1994-1997, IBM Corp.
  68.  Distribution of this program without author's consent is PROHIBITED!
  69.  For information, contact: Azzarito@austin.ibm.com
  70.  
  71.  Report generated on Tue Feb 18 15:07:19 1997
  72.  
  73.  Physical Drives Detected: 1
  74.  
  75.  Drive Information for Physical Disk 1:
  76.    Cylinders            012E  (302)
  77.    Heads                  40  (64)
  78.    Sectors/Track          20  (32)
  79.    Total Sectors    00097000* (618496)
  80.    Drive Size (MB)   302.000* (316669952 bytes)
  81.    Partition 1:
  82.      Boot Indicator         00  (0)
  83.      Partition Type         05  (5)  [Extended]
  84.      Begin CHS       00A,00,01  (10,0,1)
  85.      End CHS         12C,3F,20  (300,63,32)
  86.      Rel Sectors      00005000  (20480)
  87.      Sectors          00091800  (595968)
  88.      Begin RBA        00005000* (20480)
  89.      End RBA          000967FF* (616447)
  90.      Begin CHS       00A,00,01* (10,0,1)
  91.      End CHS         12C,3F,20* (300,63,32)
  92.      Size (MB)         291.000* (305135616 bytes)
  93.      Extended Partition Information
  94.      Partition 1:
  95.        Drive                  D:
  96.        Boot Indicator         80  (128)  [Bootable]
  97.        Partition Type         07  (7)  [Installable File System]
  98.        Begin CHS       00A,01,01  (10,1,1)
  99.        End CHS         0E6,3F,20  (230,63,32)
  100.        Rel Sectors      00000020  (32)
  101.        Sectors          0006E7E0  (452576)
  102.        Begin RBA        00005020* (20512)
  103.        End RBA          000737FF* (473087)
  104.        Begin CHS       00A,01,01* (10,1,1)
  105.        End CHS         0E6,3F,20* (230,63,32)
  106.        Logical Cylinders    00DD  (221)
  107.        Heads (BPB)            40  (64)
  108.        Sectors/Track (BPB)    20  (32)
  109.        Sectors (BPB)    0006E7E0  (452576)
  110.        Sectors (HPFS)   0006E7E0  (452576)
  111.        Size (MB)         220.984* (231718912 bytes)
  112.      Partition 2:
  113.        Boot Indicator         00  (0)
  114.        Partition Type         05  (5)  [Extended]
  115.        Begin CHS       0E7,00,01  (231,0,1)
  116.        End CHS         12C,3F,20  (300,63,32)
  117.        Rel Sectors      0006E800  (452608)
  118.        Sectors          00023000  (143360)
  119.        Begin RBA        00073800* (473088)
  120.        End RBA          000967FF* (616447)
  121.        Begin CHS       0E7,00,01* (231,0,1)
  122.        End CHS         12C,3F,20* (300,63,32)
  123.        Size (MB)          70.000* (73400320 bytes)
  124.        Extended Partition Information
  125.        Partition 1:
  126.          Drive                  E:
  127.          Boot Indicator         80  (128)  [Bootable]
  128.          Partition Type         07  (7)  [Installable File System]
  129.          Begin CHS       0E7,01,01  (231,1,1)
  130.          End CHS         12C,3F,20  (300,63,32)
  131.          Rel Sectors      00000020  (32)
  132.          Sectors          00022FE0  (143328)
  133.          Begin RBA        00073820* (473120)
  134.          End RBA          000967FF* (616447)
  135.          Begin CHS       0E7,01,01* (231,1,1)
  136.          End CHS         12C,3F,20* (300,63,32)
  137.          Logical Cylinders    0046  (70)
  138.          Heads (BPB)            40  (64)
  139.          Sectors/Track (BPB)    20  (32)
  140.          Sectors (BPB)    00022FE0  (143328)
  141.          Sectors (HPFS)   00022FE0  (143328)
  142.          Size (MB)          69.984* (73383936 bytes)
  143.        Partition 2:
  144.          [Empty]
  145.        Partition 3:
  146.          [Empty]
  147.        Partition 4:
  148.          [Empty]
  149.      Partition 3:
  150.        [Empty]
  151.      Partition 4:
  152.        [Empty]
  153.    Partition 2:
  154.      Drive                  C:
  155.      Boot Indicator         00  (0)
  156.      Partition Type         01  (1)  [FAT (12bit)]
  157.      Begin CHS       000,01,01  (0,1,1)
  158.      End CHS         009,3F,20  (9,63,32)
  159.      Rel Sectors      00000020  (32)
  160.      Sectors          00004FE0  (20448)
  161.      Begin RBA        00000020* (32)
  162.      End RBA          00004FFF* (20479)
  163.      Begin CHS       000,01,01* (0,1,1)
  164.      End CHS         009,3F,20* (9,63,32)
  165.      Logical Cylinders    000A  (10)
  166.      Heads (BPB)            40  (64)
  167.      Sectors/Track (BPB)    20  (32)
  168.      Sectors (BPB)    00004FE0  (20448)
  169.      Size (MB)           9.984* (10469376 bytes)
  170.    Partition 3:
  171.      Boot Indicator         80  (128)  [Bootable]
  172.      Partition Type         0A  (10)  [Boot Manager]
  173.      Begin CHS       12D,00,01  (301,0,1)
  174.      End CHS         12D,3F,20  (301,63,32)
  175.      Rel Sectors      00096800  (616448)
  176.      Sectors          00000800  (2048)
  177.      Begin RBA        00096800* (616448)
  178.      End RBA          00096FFF* (618495)
  179.      Begin CHS       12D,00,01* (301,0,1)
  180.      End CHS         12D,3F,20* (301,63,32)
  181.      Size (MB)           1.000* (1048576 bytes)
  182.    Partition 4:
  183.      [Empty]
  184.  ---------------------------------------------------------------------------
  185.  Here's a line-by-line description of what the numbers are, and how I got
  186.  them:
  187.  
  188.  Physical Drives Detected: 1
  189.  
  190.  This should be the number of PHYSICAL drive units.  If you have a RAID
  191.  system, the entire RAID will probably show up as one unit.  I get this
  192.  value by using the OS/2 API, DosPhysicalDisk, function
  193.  INFO_COUNT_PARTITIONABLE_DISKS.
  194.  
  195.  Drive Information for Physical Disk 1:
  196.    Cylinders            012E  (302)
  197.    Heads                  40  (64)
  198.    Sectors/Track          20  (32)
  199.  
  200.  This is the physical geometry for the disk.  I get these values by using
  201.  the OS/2 API DosDevIOCtl, CATEGORY_PHYSDISK, function GET_DEV_PARMS.
  202.  
  203.  
  204.    Total Sectors    00097000* (618496)
  205.  
  206.  This value is calculated by multiplying Cylinders * Heads * Sectors/Track.
  207.  
  208.    Drive Size (MB)   302.000* (316669952 bytes)
  209.  
  210.  This value is calculated by multiplying Total Sectors * 512.
  211.  
  212.    Partition 1:
  213.      Drive                  D:
  214.  
  215.  This indicates that a drive letter should be assigned to this partition.  I
  216.  use a similar algorithm to what OS/2 uses.  The first ACTIVE PRIMARY partition
  217.  on each drive gets drive letters starting with C:.  Then I scan each drive
  218.  looking for logical drives in extended partitions.  If they are a recognized
  219.  type (FAT, IFS), I assign a drive letter.  This does *not* mean that the drive
  220.  is currently assigned that letter - this value is not checked, it is just
  221.  an aid in figuring out what drive you are viewing.
  222.  
  223.      Boot Indicator         00  (0)
  224.  
  225.  This value is the first byte of an EBR/MBR partition record, and will be
  226.  0x80 if the partition is ACTIVE/STARTABLE.  I get this value by reading
  227.  the MBR/EBR from disk.
  228.  
  229.      Partition Type         05  (5)  [Extended]
  230.  
  231.  This value is the fifth byte of an MBR/EBR partition record.  It tells
  232.  us what kind of filesystem is in this partition.  An extended partition
  233.  points to an EBR, which contains one or more partitions.  This value
  234.  is read directly from the MBR/EBR.
  235.  
  236.      Begin CHS       00A,00,01  (10,0,1)
  237.      End CHS         12C,3F,20  (300,63,32)
  238.  
  239.  These values give the Cylinder/Head/Sector of the beginning and end of
  240.  this partition.  These are read directly from the MBR/EBR.
  241.  
  242.      Rel Sectors      00005000  (20480)
  243.  
  244.  This value is the number of sectors between the MBR/EBR and the start of
  245.  the partition.  It is read directly from the MBR/EBR.
  246.  
  247.      Sectors          00091800  (595968)
  248.  
  249.  This is the number of sectors in the partition.  This number does not include
  250.  those sectors between the MBR/EBR and the start of partition.  This value
  251.  is read directly from the MBR/EBR.
  252.  
  253.      Begin RBA        00005000* (20480)
  254.      End RBA          000967FF* (616447)
  255.  
  256.  This is the "Relative Block Address" of the beginning and end of the
  257.  partition.  An RBA is a way of representing sectors regardless of the
  258.  CHS geometry.  RBA 0 is the first sector on a disk, and is where the MBR
  259.  is stored.  I calculate the Begin RBA by adding Rel Sectors to the RBA of
  260.  the MBR or EBR where this partition is recorded.  I calculate End RBA by
  261.  adding Sectors to the Begin RBA.
  262.  
  263.      Begin CHS       00A,00,01* (10,0,1)
  264.      End CHS         12C,3F,20* (300,63,32)
  265.  
  266.  These numbers are calculated by CHKPART to verify the values stored in the
  267.  MBR/EBR.  I use the Begin and End RBA, convert them to CHS, and make
  268.  sure they match what is on disk.
  269.  
  270.      Logical Cylinders    00DD  (221)
  271.      Heads (BPB)            40  (64)
  272.      Sectors/Track (BPB)    20  (32)
  273.  
  274.  This is the LOGICAL geometry for the partition.  It only appears if the
  275.  partition has a BPB (BIOS Parameter Block).  It is legal to have a different
  276.  logical geometry in each partition, and it can be very confusing as well.
  277.  These values are read from the BPB.
  278.  
  279.      Sectors (BPB)    0006E7E0  (452576)
  280.  
  281.  If the partition has a BPB, the number of sectors in the partition is stored
  282.  in one of two places.  CHKPART looks in both places, and finds the valid one.
  283.  This should match the value from the MBR/EBR.
  284.  
  285.      Sectors (HPFS)   0006E7E0  (452576)
  286.  
  287.  If the partition is HPFS, CHKPART will look into the HPFS structure and get
  288.  the recorded partition size.  It may not match the other values, as HPFS
  289.  rounds all partitions down to the nearest multiple of 4.  This value is
  290.  read from the HPFS SuperBlock.
  291.  
  292.      Size (MB)         291.000* (305135616 bytes)
  293.  
  294.  This is the size of the partition, calculated by taking the Sectors value and
  295.  converting it to Megabytes.
  296.  
  297.  
  298.  
  299.  USING CHKPART TO DIAGNOSE GEOMETRY PROBLEMS
  300.  -------------------------------------------
  301.  
  302.        Often, MBR/EBR problems are caused by differences between BIOS
  303.        geometry and the geometry presented after loading a device driver.
  304.        To test this, use the following procedure:
  305.  
  306.        - Run CHKPART.EXE, using your normal CONFIG.SYS, and record the
  307.          results.
  308.  
  309.        - Create an OS/2 boot diskette that uses IBMINT13.I13 as the only disk
  310.          device driver.  Edit the CONFIG.SYS on the bootable diskette, and
  311.          REM out all other disk device drivers (IBM1S506.ADD for IDE drives).
  312.          If you do this properly, when you run RMVIEW /IRQ (the RMVIEW
  313.          utility comes with OS/2 Warp), you'll see that the driver on IRQ14
  314.          is the INT13 BIOS driver.
  315.  
  316.        - Run CHKPART.EXE against the INT 13 driver.  Compare the two results.
  317.          You should not see a change in geometry (HEADS and SECTORS/TRACK
  318.          should be the same in both reports).
  319.  
  320.  If your geometry figures change between INT 13 and your disk device driver,
  321.  you have a problem that must be fixed.  OS/2 uses BIOS to load the MBR and
  322.  EBR's, Boot Manager, and the first stages of OS/2 boot.  Once the OS2KRNL
  323.  file is loaded, the device driver can be loaded.  Why does this cause a
  324.  problem?  If you use FDISK while under the control of the device driver, and
  325.  change any partitions, when you reboot, the device driver won't be around,
  326.  and the partition table will look corrupted.
  327.  
  328.  How do you fix this problem?  It depends.  You must get your BIOS and your
  329.  device driver to agree on the geometry.  You may be able to change settings
  330.  to modify the BIOS geometry (some computers have user defined disk geometry
  331.  settings in CMOS), or you may be able to pass a parameter to your device
  332.  driver to modify the DD geometry.  If you are using the IBM1S506 device driver,
  333.  you can have it do automatic geometry translation for you.  For example, if
  334.  your drive is 8100 cylinders * 16 heads * 63 sectors/track, and BIOS used
  335.  translation to allow DOS to use the entire disk, it might have used the
  336.  translated geometry of 526 Cylinders * 255 heads * 63 sectors/track.  To have
  337.  IBM1S506 do the same thing, use the command:
  338.  
  339.  BASEDEV=IBM1S506 /A:0 /U:0 /GEO:(8100,16,63),(526,255,63)
  340.  
  341.  The switch /A:0 specifies the first IDE adapter
  342.  The switch /U:0 specifies the first IDE drive on that adapter.
  343.  
  344.