[comp.sys.ibm.pc.hardware] Partition table

achilles@unixland.uucp (David Holland) (04/03/91)

Owing to some recent computer trouble I've been poking somewhat deeper into 
my system than usual, and I noticed the following interesting oddity about 
the partition table: there are only two partitions listed, one of which is 
twice as large as the other, and only one of them is marked DOS. The disk 
contains three equal-sized partitions, all of which are DOS; where is this 
information stored? Or does Norton's partition-table editor mislead me?
 
As might be expected it's the boot partition that is marked DOS in the 
partition table...
 
 ------------
 David A. Holland
 
 pro-angmar!achilles@alfalfa.com ... alphalpha!pro-angmar!achilles
 
 CAD/CAM: Computer Aided Disaster/Computer Assisted Mayhem :-)
 
p.s. Please don't mail to the account this was posted from.

berggren@eecs.cs.pdx.edu (Eric Berggren) (04/04/91)

achilles@unixland.uucp (David Holland) writes:

>Owing to some recent computer trouble I've been poking somewhat deeper into 
>my system than usual, and I noticed the following interesting oddity about 
>the partition table: there are only two partitions listed, 

  The partition table allows up to four physical partitions on a fixed disk.

>>one of which is 
>twice as large as the other, and only one of them is marked DOS. The disk 
>contains three equal-sized partitions, all of which are DOS; where is this 
>information stored? Or does Norton's partition-table editor mislead me?
> 
  This could be a result of several versions of DOS used, or a less than
32-meg partition (viewable) and a greater than 32-meg partition (which is
of a different type and may not be readable by older utilities) This, of
course, depends on your setup. (I never really cared for Norton. I'm
currently working on a disk partition-table editor myself, which recongnizes
all of the currently known partition types and allows the users to add,
modify, and delete partitions of any type. If you want a copy of it when
I finish it, lemme know and I'll swing you a copy.)
  Anyway, the partition table is stored in the first sector in the first
track of the harddrive starting at offset 0x1be. Reading in 4 entries from
that offset will be the partition table. Here's the structure I'm using:

#define MAXPARTITIONS 4

typedef struct {
            unsigned char   active;     /* 80h is active; 00h if not        */
            unsigned char   start_head; /* head of first sector             */
            unsigned char   start_sec;  /* first sector + 2 MSB's of cyl    */
            unsigned char   start_cyl;  /* cylinder of first sector         */
            unsigned char   type;       /* partition type (OS who owns it)  */
            unsigned char   end_head;   /* head of last sector              */
            unsigned char   end_sec;    /* last sector + 2 MSB'd of cyl     */
            unsigned char   end_cyl;    /* cylinder of last sector          */
            unsigned long   abs_sec;    /* absolute starting sector         */
            unsigned long   num_sec;    /* total sectors in partition       */
    } Part_Entry;
 
Part_Entry  PartTable[ MAXPARTITIONS ]; /* partition table for current drive*/
 
  Hope this helps...

-e.b.

==============================================================================
  Eric Berggren             |  "The force of the 'Dark Side' eminates from 
  Computer Science/Eng.     |    the ominous DeathStar looming overhead." 
  berggren@eecs.cs.pdx.edu  |            - Down with AT&T! -

tron@db.toronto.edu ("Carlos G. Mendioroz") (04/04/91)

berggren@eecs.cs.pdx.edu (Eric Berggren) writes:

>achilles@unixland.uucp (David Holland) writes:

>>Owing to some recent computer trouble I've been poking somewhat deeper into 
>>my system than usual, and I noticed the following interesting oddity about 
>>the partition table: there are only two partitions listed, 

>  The partition table allows up to four physical partitions on a fixed disk.

One of them is the Primary DOS part. and the other is the secondary DOS part.

>>>one of which is 
>>twice as large as the other, and only one of them is marked DOS. The disk 
>>contains three equal-sized partitions, all of which are DOS; where is this 
>>information stored? Or does Norton's partition-table editor mislead me?

The primary OSid is 4 (or 6, depending your OS version) That's the one that
is being listed as DOS. The secondary OSid is 5, and DOS (>3.something) 
supports many 'logical partitions' inside it. I'd bet you have two defined,
same size, what brings you 3 same size DOS volumes in only two 1:2 sized
partitions...

jcmorris@mwunix.mitre.org (Joe Morris) (04/04/91)

achilles@unixland.uucp (David Holland) writes:

>Owing to some recent computer trouble I've been poking somewhat deeper into 
>my system than usual, and I noticed the following interesting oddity about 
>the partition table: there are only two partitions listed, one of which is 
>twice as large as the other, and only one of them is marked DOS. The disk 
>contains three equal-sized partitions, all of which are DOS; where is this 
>information stored? Or does Norton's partition-table editor mislead me?

The documentation for Norton (at least at 4.5; I haven't had to look it up
in the 5.0 doc) isn't clear on the structure of a (physical) disk with
multiple partitions.  If you have a single physical disk with three DOS
partitions filling it, the partition table as shown by Norton will display
only the first DOS partition and a second partition marked "EXTENDED".
If you read the starting location of the EXTENDED partition from the
display and then display *that* record (using F6 to display it as a
partition table) you'll find that this partition table has one DOS
partition and one extended partition.  Chain to the start location
of this second extended partition and display it; you'll see a partition
table with only a DOS partition.  The three partition tables marked as
DOS partitions are the C, D, and E drives; the extended partitions cover
the space occupied by all lower partitions.

I don't recall ever seeing it documented but apparently you can't have two
DOS partitions in the same partition table.

Here's what your disk should look like:

  Master Partition                                  Real Disk Drive
  Table (cyl 0 head 0
  record 1):           < - - - - - - - - - - - -
        |                                        \
        V                                          \   Start real disk
                                                     \ C0:H0:R1
       DOS-16    - - - - - - - - - - - - - - - - - ->  Start C:
       EXTENDED                \ \ \ \ \ \ \ \ \ \ \      .
              \                  \ \ \ \ \ \ \ \ \ \      .
                \                  - - - - - - - - ->  End C:
                  \
                     - - - - - - - - - - - - - - - ->  Start First
                                                       Extended Partition

                Second Partition       - - - - - - ->  Start D:
                Table (-> by MPT)    / / / / / / / /
                       |            // / / / / / / /
                       V           / / / / / / / / /
                                  // / / / / / / / /
                    DOS-16 - - - - - - - - - - - - ->  End D:
                    EXTENDED - - - - - - - - - - - ->  Start Second
                                                       Extended Partition

                          Third Partition        - ->  Start E:
                          Table (-> by 2nd PT)  // /
                                    |          / / /
                                    V         // / /
                                             / / / /
                                  DOS-16 - - - - - ->  End E:
                                                       End second ext. part.
                                                       End first ext. part
                                                       End real disk

Note that the four last lines (the end of E:, the end of the two extended
partitions, and the end of the real disk) all occur at the last track of the
last cylinder of the physical disk.

Note also that the partition table in each partition is located at the
first record on the first track of the first cylinder in that partition.
In effect this is the same rule as is used for the master partition table,
which is always on the first record of the physical disk.  Also, note
that the master partition table occupies the same record (0/0/1) as the
master boot record.

Quiz on Friday.

Joe