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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
|
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN//2.0">
<!--This file created 11/5/97 10:18 PM by Claris Home Page version 2.0-->
<HTML>
<HEAD>
<TITLE>pdisk for the Mac OS</TITLE>
<META NAME=GENERATOR CONTENT="Claris Home Page 2.0">
<X-SAS-WINDOW TOP=42 BOTTOM=477 LEFT=4 RIGHT=556>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<H2>Overview</H2>
<H3>What is pdisk?</H3>
<P>A simple editor for Apple disk partition format. There are two
main versions of pdisk: one for MkLinux and one for the Mac OS. This
document describes the Mac OS version of pdisk. Much of this document
is also relevant to the MkLinux version, but check the manual page
(pdisk.8) also.</P>
<H3>What is the Apple disk partition format?</H3>
<P>Most operating systems have ways to divide disks into several
pieces - so that an entire disk does not have to be devoted to one
filesystem, or even to one operating system. This division of the
disk is usually called partitioning. In some systems the partitioning
information is built into the operating system code, but that tends to
be restrictive. In the Mac OS the partitioning information is stored
on the first few blocks of the disk.</P>
<P>The Apple disk partition scheme was developed in 1986 by the A/UX
team with input from the Mac OS and Apple II teams. There was an
earlier partition scheme used in the first SCSI drives on the
MacPlus, but that was replaced by the current scheme in the Macintosh
II and subsequent machines and in subsequent operating system
releases. The current scheme is supported by Mac OS, A/UX, ProDos,
MkLinux, and "Rhapsody".</P>
<H3>What is MkLinux?</H3>
<P>Just in case you got pdisk not as part of an MkLinux release:
MkLinux is a version of the Linux operating system, converted to run
as a server process on top of the Mach microkernel. As with Linux,
all of the operating system source code is available for
<A HREF="http://www.mklinux.apple.com">download</A>, including the
Mach source. MkLinux runs on many of PowerPC based Macintosh
machines.</P>
<H3>Which Macintosh machines does pdisk run on?</H3>
<P>The Mac OS binary should run on any PowerPC based Macintosh. It
has been tested under System 7.6.1 and System 8, but should run on
older versions of the Mac OS as well. A Mac OS 68000 binary is also
distributed for those who may find it useful.</P>
<H3>Why would I want to use pdisk on the Mac OS?</H3>
<P>The main clients for the Mac OS version of pdisk are MkLinux
users. pdisk was originally developed for MkLinux. The command syntax
was originally identical to that for the 'fdisk' program. (fdisk is a
Linux program which edits the DOS/Windows disk partition format.) The
Mac OS version is a simple, crude port of the MkLinux version.</P>
<P>The advantages of pdisk over the various Mac OS disk partitioning
programs (such as SilverLining, the FWB toolkit, Apple HD SC Setup,
DriveSetup, etc) are:</P>
<UL>
<LI>unlike the Apple partitioners, it does not restrict the set of
drives it can operate on
<LI>it allows partitions to be reordered (helpful, as MkLinux
depends on the order)
<LI>it creates MkLinux partitions by default
<LI>it allows the size of the partition map to be changed
<LI>it allows the name of a partition to be changed
<LI>it allows you to edit the partition map of your boot disk
</UL>
<P>The disadvantages of pdisk are:</P>
<UL>
<LI>it doesn't automatically initialize HFS partitions
<LI>it can't install disk drivers
<LI>it allows you to edit the partition map of your boot disk
</UL>
<H3>Where can I get the source?</H3>
<P>The main site for MkLinux is
<<A HREF="http://www.mklinux.apple.com">http://www.mklinux.apple.com</A>>.
As of the time this document was written you could find the pdisk
distributions at
<<A HREF="ftp://ftp.mklinux.apple.com/pub/Other_tools/pdisk/">ftp://ftp.mklinux.apple.com/pub/Other_tools/pdisk/</A>>.
This includes binary distributions for MkLinux and the Mac OS, as
well as a source distribution.</P>
<H2>Description of the program (as of version 0.7)</H2>
<P>Though pdisk is a Macintosh program its interface is very
un-Macintosh. pdisk is what is called a line-oriented program. In a
line-oriented program you do things by typing on the keyboard and the
program does not pay attention to the typing until the return key has
been typed.</P>
<P>When you start up pdisk it brings up a window with some text in
it. The last line of this text should be something like " Top level
command (? for help): ". This is the prompt. If you type "?" followed
by a return character you should get a list like this:</P>
<PRE>Notes:
Disk have fake names of the form /dev/scsi<bus>.<id>
For example, /dev/scsi0.1, /dev/scsi1.3, and so on.
MkLinux style names are also allowed (i.e /dev/sda or /dev/hda),
and these names follow the MkLinux DR3 conventions.
Commands are:
h print help
v print the version number and release date
l list device's map
L list all devices' maps
e edit device's map
E (edit map with specified block size)
r toggle readonly flag
q quit the program</PRE>
<P>Some of these commands need what are called arguments - for
example <B>l</B> (list) and <B>e</B> (edit) need a single argument,
the name of the device to list or edit. Commands which take arguments
prompt for each argument in turn. You can also type any number of the
arguments separated by spaces and those prompts will be skipped.
Commands are case insensitive (e.g. <B>h</B> and <B>H</B>) except
when the upper case letter does a variant form of the operation.</P>
<DL>
<DT><B>h</B>
<DD>Prints just the command help. The difference between <B>h</B>
and <B>?</B> is the latter prints some helpful notes as well.
<DT><B>v</B>
<DD>Prints a version number and release date. Matches the
version in the GetInfo window for the application.
<DT><B>l</B>
<DD>Prompts for the name of the device and then lists the
partition map on that device.
<DT><B>L</B>
<DD>Lists all the devices.
<DT><B>e</B>
<DD>Prompts for the name of the device and then opens the partition
map for editing.
<DT><B>E</B>
<DD>Same as <B>e</B>, except also prompts for block size.
<DT><B>r</B>
<DD>Toggles read-only setting. When read-only is on pdisk will not
write a partition map.
<DT><B>q</B>
<DD>Quit pdisk.
</DL>
<H3>The form of the listing</H3>
<P>This is a good point to show what the partition map listing looks
like.</P>
<PRE>Partition map (with 512 byte blocks) on '/dev/scsi0.2' (/dev/sda)
#: type name length base ( size )
1: Apple_partition_map Apple 63 @ 1
2: Apple_Driver43*Macintosh 54 @ 64
3: Apple_Driver43*Macintosh 74 @ 118
4: Apple_Patches Patch Partition 512 @ 192
5: Apple_HFS untitled 2117430 @ 704 ( 1.0G)
6: Apple_Free Extra 10 @ 2118134
Device block size=512, Number of Blocks=2118143
DeviceType=0x0, DeviceId=0x0
Drivers-
1: @ 64 for 20, type=0x1
2: @ 118 for 32, type=0xffff</PRE>
<P>The first line indicates what device this is and what size blocks
the partition map is using. Most partition maps will use 512-byte
blocks, but partition maps can use 1024-byte (1K) or 2048-byte (2K)
blocks instead. If we are able to deduce an MkLinux name different
from the name the MkLinux name is given in parentheses.</P>
<P>Next is the partition list. Each partition (or piece) of the disk
takes one line of the list. The data describing the partition is
called the partition map entry. The entries are listed in order by
index. For each entry, the following information is displayed:</P>
<UL>
<LI>index - where the partition entry is in the map. This does not
correspond the relative order of the partition contents and can
change when the partition map is edited.
<LI>type - the sort of data expected to be in the partition. pdisk
doesn't put data into the contents of any partition except the
partition map partition. The type is a case-insensitive string.
<LI>name - the name is for the user's information.
<LI>length - the number of partition blocks the partition takes.
<LI>base - the first block of the partition, measured in partition
blocks, starting from zero.
<LI>size - this is the length in bytes. Only shown if the size is
at least one megabyte.
</UL>
<P>Following the partition list is information from block zero of the
device which describes the location of drivers.</P>
<H3>Editing Partition Tables</H3>
<P>The <B>e</B> command at the top level menu opens a partition map
for editing. The prompt is then changed to "Command (? for help):".
If you type "?" followed by a return character you should get a list
like this:</P>
<PRE>Notes:
Base and length fields are blocks, which vary in size between media.
The name of a partition is descriptive text.
Commands are:
h help
p print the partition table
P (print ordered by base address)
i initialize partition map
s change size of partition map
c create new partition (standard MkLinux type)
C (create with type also specified)
n (re)name a partition
d delete a partition
r reorder partition entry in map
w write the partition table
q quit editing (don't save changes)</PRE>
<P>Commands which take arguments prompt for each argument in turn.
You can also type any number of the arguments separated by spaces and
those prompts will be skipped. The only exception to typeahead are
the confirmation prompts on the <B>i</B> and <B>w</B> commands.
Commands can are case insensitive (e.g. <B>h</B> and <B>H</B>) except
when the upper case letter does a variant form of the operation.</P>
<P>Partitions are always specified by their number, which the index
of the partition entry in the partition map. Many of the commands
will change the index numbers of other partitions besides the
affected partition. You are advised to print the table as frequently
as necessary.</P>
<P>Creating more than fifteen partitions is not advised. There is
currently a bug in the some (all?) of the kernels which causes access
to the whole disk fail if more than fifteen partitions are in the
map.</P>
<DL>
<DT><B>h</B>
<DD>Prints just the command help. The difference between <B>h</B>
and <B>?</B> is the latter prints some helpful notes as well.
<DT><B>p</B>
<DD>Prints the partition table. The form is identical to the
listing described above.
<DT><B>P</B>
<DD>Identical to <B>p</B>, except the entries are listed in the
order of the partitions on the disk (i.e. by the increasing base
value) rather than in index order.
<DT><B>i</B>
<DD>Initializes the partition map (rarely used). This command
prompts for the size of the device. WARNING - if you write the map
after initializing it you will delete all the drivers on the device.
That makes the device invisible to the Mac OS. pdisk is not able
to install drivers.
<DT><B>s</B>
<DD>Change the size of the partition map partition. The partition
map's size must be less than or equal to the size of the partition
it is contained in. This is mostly useful when you want to do
tricky things like making a disk with multiple partitioning
schemes on it.
<DT><B>c</B>
<DD>Create a new partition takes three arguments.<BR>
The first argument is the base address (in partition blocks) of
the partition. Besides a raw number, you can also specify a
partition number followed by the letter 'p' to indicate that the
first block of the new partition should be the same as the first
block of that existing free space partition.<BR>
The second argument is the length of the partition in partition
blocks. This can be a raw number or can be a partition number
followed by the letter 'p' to use the size of that partition or
can be a number followed by 'k', 'm', or 'g' to indicate the size
in kilobytes, megabytes, or gigabytes respectively. (These are
powers of 1024, of course, not powers of 1000.)<BR>
The last argument is the name of the partition. This can be a
single word without quotes, or a string surrounded by single or
double quotes.<BR>
The type of the created partition is set to the correct type for
MkLinux ("Apple_UNIX_SVR2").
<DT><B>C</B>
<DD>Identical to the <B>c</B> command, with the addition of a
prompt for the partition type after the other arguments. The type
can be a single word without quotes, or a string surrounded by
single or double quotes.
<DT><B>n</B>
<DD>Rename a partition. Do not change the name of any partition
whose type starts with "Apple_Driver". The MacOS looks at the
names of those partitions. All other partitions should be okay
to change.
<DT><B>d</B>
<DD>Delete a partition. When a partition is deleted it's type is
changed to free ("Apple_Free") and then it is combined with any
adjacent free space.
<DT><B>r</B>
<DD>Reorder takes the current index and the desired new index. If
you give a new index which is greater than the last index the
entry will be moved to the last index.
<DT><B>w</B>
<DD>Write does write the partition map out, but pdisk does not yet
flush the appropriate caches and unmount volumes so the partition
map is not reinterpreted. In order to use the new partition map
you must reboot your machine. Sorry.
<DT><B>q</B>
<DD>Quit out of editing. Returns to the top level prompt. If you
have modified the partition map you are NOT asked if you want to
save the changes, instead the changes are quietly thrown away.
</DL>
<H3>Known problems</H3>
<DL>
<DD>This is an awful Mac OS application, it should be rewritten
to look the way a Mac OS app should look.
<DD>The code assumes a better understanding of the partitioning
scheme than most people care to acquire.
<DD>
<DD>Even more help should be available during user input.
</DL>
<P>
<HR>
</P>
<ADDRESS><A HREF="mailto:eryk@apple.com">eryk@apple.com</A>
</ADDRESS>
</BODY>
</HTML>
|