summaryrefslogtreecommitdiff
path: root/etc/etc.i386/INSTALL.pt
blob: 3918c992aa92bab613c716c819245b73615125c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
                How it Works -- Partition Tables

                           Version 1c

             by Hale Landis (landis@sugs.tware.com)


THE "HOW IT WORKS" SERIES

This is one of several How It Works documents.  The series
currently includes the following:

* How It Works -- CHS Translation
* How It Works -- Master Boot Record
* How It Works -- DOS Floppy Boot Sector
* How It Works -- OS2 Boot Sector
* How It Works -- Partition Tables


PARTITION SECTOR/RECORD/TABLE BASICS

FDISK creates all partition records (sectors).  The primary
purpose of a partition record is to hold a partition table.  The
rules for how FDISK works are unwritten but so far most FDISK
programs (DOS, OS/2, WinNT, etc) seem to follow the same basic
idea.

First, all partition table records (sectors) have the same
format.  This includes the partition table record at cylinder 0,
head 0, sector 1 -- what is known as the Master Boot Record
(MBR).  The last 66 bytes of a partition table record contain a
partition table and a 2 byte signature.  The first 446 bytes of
these sectors usually contain a program but only the program in
the MBR is ever executed (so extended partition table records
could contain something other than a program in the first 466
bytes).  See "How It Works -- The Master Boot Record".

Second, extended partitions are "nested" inside one another and
extended partition table records form a "linked list".  I will
attempt to show this in a diagram below.

PARTITION TABLE ENTRY FORMAT

Each partition table entry is 16 bytes and contains things like
the start and end location of a partition in CHS, the start in
LBA, the size in sectors, the partition "type" and the "active"
flag.  Warning:  older versions of FDISK may compute incorrect
LBA or size values.  And note:  When your computer boots itself,
only the CHS fields of the partition table entries are used
(another reason LBA doesn't solve the >528MB problem).  The CHS
fields in the partition tables are in L-CHS format -- see "How It
Works -- CHS Translation".

There is no central clearing house to assign the codes used in
the one byte "type" field.  But codes are assigned (or used) to
define most every type of file system that anyone has ever
implemented on the x86 PC:  12-bit FAT, 16-bit FAT, HPFS, NTFS,
etc.  Plus, an extended partition also has a unique type code.

Note:  I know of no complete list of all the type codes that have
been used to date.  However, I try to include such a list in a
future version of this document.

The 16 bytes of a partition table entry are used as follows:

    +--- Bit 7 is the active partition flag, bits 6-0 are zero.
    |
    |    +--- Starting CHS in INT 13 call format.
    |    |
    |    |      +--- Partition type byte.
    |    |      |
    |    |      |    +--- Ending CHS in INT 13 call format.
    |    |      |    |
    |    |      |    |        +-- Starting LBA.
    |    |      |    |        |
    |    |      |    |        |       +-- Size in sectors.
    |    |      |    |        |       |
    v <--+--->  v <--+-->     v       v

   0  1  2  3  4  5  6  7  8 9 A B  C D E F
   DH DL CH CL TB DL CH CL LBA..... SIZE....

   80 01 01 00 06 0e be 94 3e000000 0c610900  1st entry

   00 00 81 95 05 0e fe 7d 4a610900 724e0300  2nd entry

   00 00 00 00 00 00 00 00 00000000 00000000  3rd entry

   00 00 00 00 00 00 00 00 00000000 00000000  4th entry

Bytes 0-3 are used by the small program in the Master Boot Record
to read the first sector of an active partition into memory.  The
DH, DL, CH and CL above show which x86 register is loaded when
the MBR program calls INT 13H AH=02H to read the active
partition's boot sector.  See "How It Works -- Master Boot
Record".

These entries define the following partitions:

1) The first partition, a primary partition DOS FAT, starts at
   CHS 0H,1H,1H (LBA 3EH) and ends at CHS 294H,EH,3EH with a size
   of 9610CH sectors.

2) The second partition, an extended partition, starts at CHS
   295H,0H,1H (LBA 9614AH) and ends at CHS 37DH,EH,3EH with a
   size of 34E72H sectors.

3) The third and fourth table entries are unused.

PARTITION TABLE RULES

Keep in mind that there are NO written rules and NO industry
standards on how FDISK should work but here are some basic rules
that seem to be followed by most versions of FDISK:

1) In the MBR there can be 0-4 "primary" partitions, OR, 0-3
   primary partitions and 0-1 extended partition entry.

2) In an extended partition there can be 0-1 "secondary"
   partition entries and 0-1 extended partition entries.

3) Only 1 primary partition in the MBR can be marked "active" at
   any given time.

4) In most versions of FDISK, the first sector of a partition
   will be aligned such that it is at head 0, sector 1 of a
   cylinder.  This means that there may be unused sectors on the
   track(s) prior to the first sector of a partition and that
   there may be unused sectors following a partition table
   sector.

   For example, most new versions of FDISK start the first
   partition (primary or extended) at cylinder 0, head 1, sector
   1. This leaves the sectors at cylinder 0, head 0, sectors
   2...n as unused sectors.  This same layout may be seen on the
   first track of an extended partition.  See example 2 below.

   Also note that software drivers like Ontrack's Disk Manager
   depend on these unused sectors because these drivers will
   "hide" their code there (in cylinder 0, head 0, sectors
   2...n).  This is also a good place for boot sector virus
   programs to hang out.

5) The partition table entries (slots) can be used in any order.
   Some versions of FDISK fill the table from the bottom up and
   some versions of FDISK fill the table from the top down.
   Deleting a partition can leave an unused entry (slot) in the
   middle of a table.

6) And then there is the "hack" that some newer OS's (OS/2 and
   Linux) use in order to place a partition spanning or passed
   cylinder 1024 on a system that does not have a CHS translating
   BIOS.  These systems create a partition table entry with the
   partition's starting and ending CHS information set to all
   FFH.  The starting and ending LBA information is used to
   describe the location of the partition.  The LBA can be
   converted back to a CHS -- most likely a CHS with more than
   1024 cylinders.  Since such a CHS can't be used by the system
   BIOS, these partitions can not be booted or accessed until the
   OS's kernel and hard disk device drivers are loaded.  It is
   not known if the systems using this "hack" follow the same
   rules for the creation of these type of partitions.

There are NO written rules as to how an OS scans the partition
table entries so each OS can have a different method.  For DOS,
this means that different versions could assign different drive
letters to the same FAT file system partitions.

PARTITION NESTING

What do I mean when I say the partitions are "nested" within each
other?  Lets look at this example:

     M = Master Boot Record (and any unused sectors
         on the same track)
     E = Extended partition record (and any unused sectors
         on the same track)
   pri = a primary partition (first sector is a "boot" sector)
   sec = a secondary partition (first sector is a "boot" sector)


  |<----------------the entire disk-------------->|
  |                                               |
  |M<pri>                                         |
  |                                               |
  |      E<sec><---rest of 1st ext part---------->|
  |                                               |
  |            E<sec><---rest of 2nd ext part---->|


The first extended partition is described in the MBR and it
occupies the entire disk following the primary partition.  The
second extended partition is described in the first extended
partition record and it occupies the entire disk following the
first secondary partition.

PARTITION TABLE LINKING

What do I mean when I say the partition records (tables) form a
"linked" list?  This means that the MBR has an entry that
describes (points to) the first extended partition, the first
extended partition table has an entry that describes (points to)
the second extended partition table, and so on.  There is, in
theory, no limited to out long this linked list is.  When you ask
FDISK to show the DOS "logical drives" it scans the linked list
looking for all of the DOS FAT type partitions that may exist.
Remember that in an extended partition table, only two entries of
the four can be used (rule 2 above).

And one more thing...  Within a partition, the layout of the file
system data varies greatly.  However, the first sector of a
partition is expected to be a "boot" sector.  A DOS FAT file
system has:  a boot sector, first FAT sectors, second FAT
sectors, root directory sectors and finally the file data area.
See "How It Works -- OS2 Boot Sector".


EXAMPLE 1

A disk containing four DOS FAT partitions (C, D, E and F):


  |<---------------------the entire disk------------------->|
  |                                                         |
  |M<---C:--->                                              |
  |                                                         |
  |           E<---D:---><-rest of 1st ext part------------>|
  |                                                         |
  |                      E<---E:---><-rest of 2nd ext part->|
  |                                                         |
  |                                 E<---------F:---------->|


EXAMPLE 2

So here is an example of a disk with two primary partitions, one
DOS FAT and one OS/2 HPFS, plus an extended partition with
another DOS FAT:


  |<------------------the entire disk------------------>|
  |                                                     |
  |M<pri 1 - DOS FAT>                                   |
  |                                                     |
  |                  <pri 2 - OS/2 HPFS>                |
  |                                                     |
  |                                     E<sec - DOS FAT>|


Or in more detail ('n' is the highest cylinder, head or sector
number allowed in the indicated field of the CHS)...


            +-------------------------------------+
 CHS=0,0,1  | Master Boot Record containing       |
            | partition table search program and  |
            | a partition table                   |
            | +---------------------------------+ |
            | | DOS FAT partition description   | | points to CHS=0,1,1
            | +---------------------------------+ | points to CHS=a
            | | OS/2 HPFS partition description | |
            | +---------------------------------+ |
            | | unused table entry              | |
            | +---------------------------------+ |
            | | extended partition entry        | | points to CHS=b
            | +---------------------------------+ |
            +-------------------------------------+
CHS=0,0,2   | the rest of "track 0" -- this is    | :
to          | where the software drivers such as  | : normally
CHS=0,0,n   | Ontrack's Disk Manager or Micro     | : unused
            | House's EZ Drive are located.       | :
            +-------------------------------------+
CHS=0,1,1   | Boot sector for the DOS FAT         | :
            | partition                           | : a DOS FAT
            +-------------------------------------+ : file
CHS=0,1,2   | rest of the DOS FAT partition       | : system
to          | (FAT table, root directory and      | :
CHS=x-1,n,n | user data area)                     | :
            +-------------------------------------+
CHS=x,0,1   | Boot sector for the OS/2 HPFS       | :
            | file system partition               | : an OS/2
            +-------------------------------------+ : HPFS file
CHS=x,0,2   | rest of the OS/2 HPFS file system   | : system
to          | partition                           | :
CHS=y-1,n,n |                                     | :
            +-------------------------------------+
CHS=y,0,1   | Partition record for the extended   |
            | partition containing a partition    |
            | record program (never executed) and |
            | a partition table                   |
            | +---------------------------------+ |
            | | DOS FAT partition description   | | points to CHS=b+1
            | +---------------------------------+ |
            | | unused table entry              | |
            | +---------------------------------+ |
            | | unused table entry              | |
            | +---------------------------------+ |
            | | unused table entry              | |
            | +---------------------------------+ |
            +-------------------------------------+
CHS=y,0,2   | the rest of the first track of the  | : normally
to          | extended partition                  | : unused
CHS=y,0,n   |                                     | :
            +-------------------------------------+
CHS=y,1,1   | Boot sector for the DOS FAT         | :
            | partition                           | : a DOS FAT
            +-------------------------------------+ : file
CHS=y,1,2   | rest of the DOS FAT partition       | : system
to          | (FAT table, root directory and      | :
CHS=n,n,n   | user data area)                     | :
            +-------------------------------------+

EXAMPLE 3

Here is a partition record from an extended partition (the first
sector of an extended partition).  Note that it contains no
program code.  It contains only the partition table and the
signature data.

OFFSET 0 1 2 3  4 5 6 7  8 9 A B  C D E F  *0123456789ABCDEF*
000000 00000000 00000000 00000000 00000000 *................*
000010 TO 0001af SAME AS ABOVE
0001b0 00000000 00000000 00000000 00000001 *................*
0001c0 8195060e fe7d3e00 0000344e 03000000 *.....}>...4N....*
0001d0 00000000 00000000 00000000 00000000 *................*
0001e0 00000000 00000000 00000000 00000000 *................*
0001f0 00000000 00000000 00000000 000055aa *..............U.*

NOTES

Thanks to yue@heron.Stanford.EDU (Kenneth C. Yue) for pointing
out that in V0 of this document I did not properly describe the
unused sectors normally found around the partition table sectors.

/end/
--
\\===============\\=======================\\
 \\  Hale Landis  \\      303-548-0567     \\
 // Niwot, CO USA // landis@sugs.tware.com //
//===============//=======================//