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