NetBSD/dist/pdisk/pdisk.html

407 lines
14 KiB
HTML
Raw Normal View History

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN//2.0">
<HTML>
<HEAD>
<TITLE>pdisk for the Mac OS</TITLE>
<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 Linux and one for the Mac OS. This
document describes the Mac OS version of pdisk. Much of this document
is also relevant to the Linux 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, LinuxPPC, and MacOS X.</P>
<H3>What are LinuxPPC and MkLinux?</H3>
<P>Just in case you got pdisk other than as part of a LinuxPPC or
MkLinux release:</P>
<P>LinuxPPC is a port of the true Linux operating system that runs
on most of the Power Macintosh systems from Apple Computer. It also
runs on several non-Apple PowerPC machines.</P>
<P>MkLinux is a portion 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.org">download</A>, including the
Mach source. MkLinux runs on some 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 Linux
users. pdisk was originally developed for Linux. 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 Linux 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 Linux
depends on the order)
<LI>it creates Linux 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 LinuxPPC is
&lt;<A HREF="http://www.linuxppc.org">http://www.linuxppc.org</A>&gt;.
The main site for MkLinux is
&lt;<A HREF="http://www.mklinux.org">http://www.mklinux.org</A>&gt;.
</P>
<H2>Description of the program (as of version 0.8)</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&lt;bus&gt;.&lt;id&gt;
For example, /dev/scsi0.1, /dev/scsi1.3, and so on.
Linux style names are also allowed (i.e /dev/sda or /dev/hda).
Due to some technical problems these names may not match
the 'real' linux names.
&nbsp;
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
f toggle show filesystem name 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>f</B>
<DD>Toggles show filesystem name flag between 'show fileystem name' and
'show partition name'. The default is to show the filesystem name. Showing
the filesystem name is helpful when you have several equal sized Macintosh
partitions on the disk.
<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
&nbsp;
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 Linux name different
from the name then the Linux 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. If the name
is in quotes then it is the Mac volume name rather than actual
partition name.
<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.
&nbsp;
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 Linux 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
Linux ("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>&nbsp;
<DD>Even more help should be available during user input.
</DL>
<P>
<HR>
</P>
<ADDRESS><A HREF="mailto:eryk@cfcl.com">eryk@cfcl.com</A>
</ADDRESS>
</BODY>
</HTML>