1<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN//2.0">
2<HTML>
3<HEAD>
4   <TITLE>pdisk for the Mac OS</TITLE>
5   <X-SAS-WINDOW TOP=42 BOTTOM=477 LEFT=4 RIGHT=556>
6</HEAD>
7<BODY BGCOLOR="#FFFFFF">
8
9<H2>Overview</H2>
10
11<H3>What is pdisk?</H3>
12
13<P>A simple editor for Apple disk partition format. There are two
14main versions of pdisk: one for Linux and one for the Mac OS. This
15document describes the Mac OS version of pdisk. Much of this document
16is also relevant to the Linux version, but check the manual page
17(pdisk.8) also.</P>
18
19<H3>What is the Apple disk partition format?</H3>
20
21<P>Most operating systems have ways to divide disks into several
22pieces - so that an entire disk does not have to be devoted to one
23filesystem, or even to one operating system. This division of the
24disk is usually called partitioning. In some systems the partitioning
25information is built into the operating system code, but that tends to
26be restrictive. In the Mac OS the partitioning information is stored
27on the first few blocks of the disk.</P>
28
29<P>The Apple disk partition scheme was developed in 1986 by the A/UX
30team with input from the Mac OS and Apple II teams. There was an
31earlier partition scheme used in the first SCSI drives on the
32MacPlus, but that was replaced by the current scheme in the Macintosh
33II and subsequent machines and in subsequent operating system
34releases. The current scheme is supported by Mac OS, A/UX, ProDos,
35MkLinux, LinuxPPC, and MacOS X.</P>
36
37<H3>What are LinuxPPC and MkLinux?</H3>
38
39<P>Just in case you got pdisk other than as part of a LinuxPPC or
40MkLinux release:</P>
41<P>LinuxPPC is a port of the true Linux operating system that runs
42on most of the Power Macintosh systems from Apple Computer. It also
43runs on several non-Apple PowerPC machines.</P>
44<P>MkLinux is a portion of the Linux operating system, converted to run
45as a server process on top of the Mach microkernel. As with Linux,
46all of the operating system source code is available for
47<A HREF="http://www.mklinux.org">download</A>, including the
48Mach source. MkLinux runs on some of PowerPC based Macintosh
49machines.</P>
50
51<H3>Which Macintosh machines does pdisk run on?</H3>
52
53<P>The Mac OS binary should run on any PowerPC based Macintosh. It
54has been tested under System 7.6.1 and System 8, but should run on
55older versions of the Mac OS as well. A Mac OS 68000 binary is also
56distributed for those who may find it useful. </P>
57
58<H3>Why would I want to use pdisk on the Mac OS?</H3>
59
60<P>The main clients for the Mac OS version of pdisk are Linux
61users. pdisk was originally developed for Linux. The command syntax
62was originally identical to that for the 'fdisk' program. (fdisk is a
63Linux program which edits the DOS/Windows disk partition format.) The
64Mac OS version is a simple, crude port of the Linux version.</P>
65
66<P>The advantages of pdisk over the various Mac OS disk partitioning
67programs (such as SilverLining, the FWB toolkit, Apple HD SC Setup,
68DriveSetup, etc) are:</P>
69
70<UL>
71   <LI>unlike the Apple partitioners, it does not restrict the set of
72   drives it can operate on
73   
74   <LI>it allows partitions to be reordered (helpful, as Linux
75   depends on the order)
76   
77   <LI>it creates Linux partitions by default
78   
79   <LI>it allows the size of the partition map to be changed
80   
81   <LI>it allows the name of a partition to be changed
82   
83   <LI>it allows you to edit the partition map of your boot disk
84</UL>
85
86<P>The disadvantages of pdisk are:</P>
87
88<UL>
89   <LI>it doesn't automatically initialize HFS partitions
90   
91   <LI>it can't install disk drivers
92   
93   <LI>it allows you to edit the partition map of your boot disk
94</UL>
95
96<H3>Where can I get the source?</H3>
97
98<P>The main site for LinuxPPC is 
99&lt;<A HREF="http://www.linuxppc.org">http://www.linuxppc.org</A>&gt;.
100The main site for MkLinux is
101&lt;<A HREF="http://www.mklinux.org">http://www.mklinux.org</A>&gt;.
102</P>
103
104<H2>Description of the program (as of version 0.8)</H2>
105
106<P>Though pdisk is a Macintosh program its interface is very
107un-Macintosh. pdisk is what is called a line-oriented program. In a
108line-oriented program you do things by typing on the keyboard and the
109program does not pay attention to the typing until the return key has
110been typed.</P>
111
112<P>When you start up pdisk it brings up a window with some text in
113it. The last line of this text should be something like " Top level
114command (? for help): ". This is the prompt. If you type "?" followed
115by a return character you should get a list like this:</P>
116
117<PRE>Notes:
118    Disk have fake names of the form /dev/scsi&lt;bus&gt;.&lt;id&gt;
119    For example, /dev/scsi0.1, /dev/scsi1.3, and so on.
120    Linux style names are also allowed (i.e /dev/sda or /dev/hda).
121    Due to some technical problems these names may not match
122    the 'real' linux names.
123&nbsp;
124Commands are:
125  h    print help
126  v    print the version number and release date
127  l    list device's map
128  L    list all devices' maps
129  e    edit device's map
130  E    (edit map with specified block size)
131  r    toggle readonly flag
132  f    toggle show filesystem name flag
133  q    quit the program</PRE>
134
135<P>Some of these commands need what are called arguments - for
136example <B>l</B> (list) and <B>e</B> (edit) need a single argument,
137the name of the device to list or edit. Commands which take arguments
138prompt for each argument in turn. You can also type any number of the
139arguments separated by spaces and those prompts will be skipped.
140Commands are case insensitive (e.g. <B>h</B> and <B>H</B>) except
141when the upper case letter does a variant form of the operation.</P>
142
143<DL>
144   <DT><B>h</B>
145   
146   <DD>Prints just the command help. The difference between <B>h</B>
147   and <B>?</B> is the latter prints some helpful notes as well.
148   
149   <DT><B>v</B>
150   
151   <DD>Prints a version number and release date. Matches the
152   version in the GetInfo window for the application.
153   
154   <DT><B>l</B>
155   
156   <DD>Prompts for the name of the device and then lists the
157   partition map on that device.
158   
159   <DT><B>L</B>
160   
161   <DD>Lists all the devices.
162   
163   <DT><B>e</B>
164   
165   <DD>Prompts for the name of the device and then opens the partition
166   map for editing.
167   
168   <DT><B>E</B>
169   
170   <DD>Same as <B>e</B>, except also prompts for block size.
171   
172   <DT><B>r</B>
173   
174   <DD>Toggles read-only setting. When read-only is on pdisk will not
175   write a partition map.
176   
177   <DT><B>f</B>
178   
179   <DD>Toggles show filesystem name flag between 'show fileystem name' and
180   'show partition name'. The default is to show the filesystem name.  Showing
181   the filesystem name is helpful when you have several equal sized Macintosh
182   partitions on the disk.
183   
184   <DT><B>q</B>
185   
186   <DD>Quit pdisk.
187</DL>
188
189<H3>The form of the listing</H3>
190
191<P>This is a good point to show what the partition map listing looks
192like.</P>
193
194<PRE>Partition map (with 512 byte blocks) on '/dev/scsi0.2' (/dev/sda)
195   #:                 type name                length   base    ( size )
196   1:  Apple_partition_map Apple                   63 @ 1      
197   2:       Apple_Driver43*Macintosh               54 @ 64     
198   3:       Apple_Driver43*Macintosh               74 @ 118    
199   4:        Apple_Patches Patch Partition        512 @ 192    
200   5:            Apple_HFS untitled           2117430 @ 704     (  1.0G)
201   6:           Apple_Free Extra                   10 @ 2118134
202&nbsp;
203Device block size=512, Number of Blocks=2118143
204DeviceType=0x0, DeviceId=0x0
205Drivers-
2061: @ 64 for 20, type=0x1
2072: @ 118 for 32, type=0xffff</PRE>
208
209<P>The first line indicates what device this is and what size blocks
210the partition map is using. Most partition maps will use 512-byte
211blocks, but partition maps can use 1024-byte (1K) or 2048-byte (2K)
212blocks instead. If we are able to deduce an Linux name different
213from the name then the Linux name is given in parentheses.</P>
214
215<P>Next is the partition list. Each partition (or piece) of the disk
216takes one line of the list. The data describing the partition is
217called the partition map entry. The entries are listed in order by
218index. For each entry, the following information is displayed:</P>
219
220<UL>
221   <LI>index - where the partition entry is in the map. This does not
222   correspond the relative order of the partition contents and can
223   change when the partition map is edited.
224   
225   <LI>type - the sort of data expected to be in the partition. pdisk
226   doesn't put data into the contents of any partition except the
227   partition map partition. The type is a case-insensitive string.
228   
229   <LI>name - the name is for the user's information.  If the name
230   is in quotes then it is the Mac volume name rather than actual
231   partition name.
232   
233   <LI>length - the number of partition blocks the partition takes.
234   
235   <LI>base - the first block of the partition, measured in partition
236   blocks, starting from zero.
237   
238   <LI>size - this is the length in bytes. Only shown if the size is
239   at least one megabyte.
240</UL>
241
242<P>Following the partition list is information from block zero of the
243device which describes the location of drivers.</P>
244
245<H3>Editing Partition Tables</H3>
246
247<P>The <B>e</B> command at the top level menu opens a partition map
248for editing. The prompt is then changed to "Command (? for help):".
249If you type "?" followed by a return character you should get a list
250like this:</P>
251
252<PRE>Notes:
253  Base and length fields are blocks, which vary in size between media.
254  The name of a partition is descriptive text.
255&nbsp;
256Commands are:
257  h    help
258  p    print the partition table
259  P    (print ordered by base address)
260  i    initialize partition map
261  s    change size of partition map
262  c    create new partition (standard Linux type)
263  C    (create with type also specified)
264  n    (re)name a partition
265  d    delete a partition
266  r    reorder partition entry in map
267  w    write the partition table
268  q    quit editing (don't save changes)</PRE>
269
270<P>Commands which take arguments prompt for each argument in turn.
271You can also type any number of the arguments separated by spaces and
272those prompts will be skipped. The only exception to typeahead are
273the confirmation prompts on the <B>i</B> and <B>w</B> commands.
274Commands can are case insensitive (e.g. <B>h</B> and <B>H</B>) except
275when the upper case letter does a variant form of the operation.</P>
276
277<P>Partitions are always specified by their number, which the index
278of the partition entry in the partition map. Many of the commands
279will change the index numbers of other partitions besides the
280affected partition. You are advised to print the table as frequently
281as necessary.</P>
282
283<P>Creating more than fifteen partitions is not advised. There is
284currently a bug in the some (all?) of the kernels which causes access
285to the whole disk fail if more than fifteen partitions are in the
286map.</P>
287
288<DL>
289   <DT><B>h</B>
290   
291   <DD>Prints just the command help. The difference between <B>h</B>
292   and <B>?</B> is the latter prints some helpful notes as well.
293   
294   <DT><B>p</B>
295   
296   <DD>Prints the partition table. The form is identical to the
297   listing described above.
298   
299   <DT><B>P</B>
300   
301   <DD>Identical to <B>p</B>, except the entries are listed in the
302   order of the partitions on the disk (i.e. by the increasing base
303   value) rather than in index order.
304   
305   <DT><B>i</B>
306   
307   <DD>Initializes the partition map (rarely used). This command
308   prompts for the size of the device. WARNING - if you write the map
309   after initializing it you will delete all the drivers on the device.
310   That makes the device invisible to the Mac OS. pdisk is not able
311   to install drivers.
312   
313   <DT><B>s</B>
314   
315   <DD>Change the size of the partition map partition. The partition
316   map's size must be less than or equal to the size of the partition
317   it is contained in. This is mostly useful when you want to do
318   tricky things like making a disk with multiple partitioning
319   schemes on it.
320   
321   <DT><B>c</B>
322   
323   <DD>Create a new partition takes three arguments.<BR>
324   
325   The first argument is the base address (in partition blocks) of
326   the partition. Besides a raw number, you can also specify a
327   partition number followed by the letter 'p' to indicate that the
328   first block of the new partition should be the same as the first
329   block of that existing free space partition.<BR>
330   
331   The second argument is the length of the partition in partition
332   blocks. This can be a raw number or can be a partition number
333   followed by the letter 'p' to use the size of that partition or
334   can be a number followed by 'k', 'm', or 'g' to indicate the size
335   in kilobytes, megabytes, or gigabytes respectively. (These are
336   powers of 1024, of course, not powers of 1000.)<BR>
337   
338   The last argument is the name of the partition. This can be a
339   single word without quotes, or a string surrounded by single or
340   double quotes.<BR>
341   
342   The type of the created partition is set to the correct type for
343   Linux ("Apple_UNIX_SVR2").
344   
345   <DT><B>C</B>
346   
347   <DD>Identical to the <B>c</B> command, with the addition of a
348   prompt for the partition type after the other arguments. The type
349   can be a single word without quotes, or a string surrounded by
350   single or double quotes.
351   
352   <DT><B>n</B>
353   
354   <DD>Rename a partition. Do not change the name of any partition
355   whose type starts with "Apple_Driver". The MacOS looks at the
356   names of those partitions. All other partitions should be okay
357   to change.
358
359   <DT><B>d</B>
360   
361   <DD>Delete a partition. When a partition is deleted it's type is
362   changed to free ("Apple_Free") and then it is combined with any
363   adjacent free space.
364   
365   <DT><B>r</B>
366   
367   <DD>Reorder takes the current index and the desired new index. If
368   you give a new index which is greater than the last index the
369   entry will be moved to the last index.
370   
371   <DT><B>w</B>
372   
373   <DD>Write does write the partition map out, but pdisk does not yet
374   flush the appropriate caches and unmount volumes so the partition
375   map is not reinterpreted. In order to use the new partition map
376   you must reboot your machine. Sorry.
377   
378   <DT><B>q</B>
379   
380   <DD>Quit out of editing. Returns to the top level prompt. If you
381   have modified the partition map you are NOT asked if you want to
382   save the changes, instead the changes are quietly thrown away.
383</DL>
384
385<H3>Known problems</H3>
386
387<DL>
388   <DD>This is an awful Mac OS application, it should be rewritten
389   to look the way a Mac OS app should look.
390   
391   <DD>The code assumes a better understanding of the partitioning
392   scheme than most people care to acquire.
393   
394   <DD>&nbsp;
395   
396   <DD>Even more help should be available during user input.
397</DL>
398
399<P>
400<HR>
401</P>
402
403<ADDRESS><A HREF="mailto:eryk@cfcl.com">eryk@cfcl.com</A>
404</ADDRESS>
405</BODY>
406</HTML>
407