A partition table is stored on a hard disk to specify the division of
the physical disk into a set of logical units.
On PCs, the partition table is stored at the end of the master boot record
of the disk.
Partitions of type
are Plan 9 partitions.
Inferno uses the same type and follows other Plan 9 conventions described here.
The names of PC partitions are chosen by convention from the type:
Second and subsequent partitions of the same type on a given disk are given
unique names by appending a number (or a period and a number if the name
already ends in a number).
Plan 9 partitions (and Plan 9 disks on non-PCs) are
themselves divided, using a textual partition table, called the Plan 9 partition table, in the second
sector of the partition (the first is left for architecture-specific boot data, such as PC boot blocks).
Inferno again uses the same conventions.
The table is a sequence of lines of the format
part name start end,
name the starting and ending sector.
Sector 0 is the first sector of the Plan 9 partition or disk,
regardless of its position in a larger disk.
Partition extents do not contain the ending sector,
so a partition from 0 to 5 and a partition from 5 to 10
do not overlap.
The Plan 9 partition often contains a number of
conventionally named subpartitions.
are currently used by Inferno, but the others are included for reference.
- A small FAT file system used to hold
This typically begins in the first sector
of the partition, and contains the partition
table as a ``reserved'' sector.
See the discussion of the
- A Plan 9
- A Plan 9
file system cache.
- A Plan 9
- A one-sector partition used to store a
- A Plan 9
- A one-sector partition used to simulate non-volatile RAM on PCs.
- A non-archived Plan 9
- A Plan 9
edits the PC partition table and is usually
invoked with a disk like
as its argument, while
edits the Plan 9 partition table
and is usually invoked with a disk partition
as its argument.
works in units of disk ``cylinders'': the cylinder
size in bytes is printed when
works in units of disk sectors, which are almost always 512 bytes.
share most of their options:
- Automatically partition the disk.
will create a Plan 9
partition in the largest unused area on the disk,
doing nothing if a
Plan 9 partition already exists.
If no other partition on the disk is marked active (i.e. marked as the boot partition),
will mark the new partition active.
flag takes the name of a partition to create.
(See the list above for partition names.)
It can be repeated to specify a list of partitions to create.
If the disk is currently unpartitioned,
will create the named partitions on the disk,
attempting to use the entire disk in a sensible manner.
The partition names must be from the list given above.
- Start with a blank disk, ignoring any extant partition table.
- Print a sequence of commands that when sent to the disk device's
will bring the partition
table information kept by
driver up to date.
will check to see if it is being called with a disk partition
(rather than an entire disk) as its argument; if so, it
will translate the printed sectors by the partition's offset
within the disk.
operates on a table of unnamed partitions,
it assigns names based on the partition type
and resolves collisions by appending a numbered suffix.
- In the absence of the
enter an interactive partition editor;
flag runs the editor in read-only mode.
- -s sectorsize
- Specify the disk's sector size.
In the absence of this flag,
look for a disk
file and read it to find the disk's sector size.
file cannot be found, a message is printed and
a sector size of 512 bytes is assumed.
- Write the partition table to the disk and exit.
This is useful when used in conjunction with
If neither the
flag nor the
flag is given,
enter an interactive partition editor that
operates on named partitions.
The PC partition table distinguishes between
primary partitions, which can be listed in the boot
sector at the beginning of the disk,
and secondary (or extended) partitions, arbitrarily
many of which may be chained together in place
of a primary partition.
Primary partitions are named
The number of primary partitions plus number of contiguous chains of
secondary partitions cannot exceed four.
The commands are as follows.
In the descriptions, read ``sector'' as ``cylinder'' when using
- a name [ start [ end ] ]
- Create a partition named
starting at sector offset
and ending at offset
The new partition will not be created if
it overlaps an extant partition.
will prompt for them.
the newly created partition has type
to set a different type, use the
may be expressions using the operators
numeric constants, and the
At the start of the program,
is set to zero; each time a partition is
created, it is set to the end sector
of the new partition.
It can also be explicitly set using the
is set to one past the last disk sector.
is set to the maximum value that
can take on without running off the disk
or into another partition.
Finally, the expression
As an example,
creates a new partition starting at
that takes up a fifth of the disk,
creates a new partition starting at
sector 1000 and
extending as far as possible.
- . newdot
- Set the value of the variable
which is an arithmetic expression as described
in the discussion of the
- d name
- Delete the named partition.
- Print a help message listing command synopses.
- Print the disk partition table.
Unpartitioned regions are also listed.
The table consists of a number of lines containing
partition name, beginning and ending sectors,
and total size.
is prefixed to the names of partitions
whose entries have been modified but not written to disk.
adds to the end of each line a textual partition type,
and places a
next to the name of the active partition
- Print the partition table in the format accepted by the disk's
file, which is also the format of the output of the
- Write the partition table to disk.
will also inform the kernel of the changed
The write will fail if any programs have any
of the disk's partitions open.
If the write fails (for this or any other reason),
will attempt to restore the partition table to
its former state.
- Quit the program.
If the partition table has been modified but not written,
a warning is printed.
again will quit the program.
also has the following commands.
- A name
- Set the named partition active.
The active partition is the one whose boot block is used
when booting a PC from disk.
- Print the names of empty slots in the partition table, i.e., the
valid names to use when creating a new partition.
- t [ type ]
- Set the partition type. If it is not given,
will display a list of choices and then prompt for it.
prepares for use the floppy diskette or hard disk partition in the file named
The options are:
- Do not physically format the disc. Used
to install a FAT file system on a
previously formatted disc. If
is not a floppy device, this flag is a no-op.
- specify a density and type of disk to be prepared.
- 3½" double density, 737280 bytes
- 3½" high density, 1474560 bytes
- 5¼" double density, 368640 bytes
- 5¼" high density, 1146880 bytes
- fixed disk
The default when
is a floppy drive is the highest possible on the device.
is a regular file, the default is
device, the default is
- initialize a FAT file system on the
- use the contents of
as a bootstrap block
to be installed in sector 0.
The remaining options have effect only when
- use a FAT cluster size of
sectors when creating the FAT.
- add a
when creating the FAT file system.
- mark the first
sectors of the partition as ``reserved''.
Since the first sector always contains the
FAT parameter block, this really marks
sectors starting at sector 1 as ``reserved''.
When formatting the
should be used to jump over the partition table sector.
listed are added, in order,
to the root
directory of the FAT file system. The files are
If a file is named
it will be created with the
attribute set so that
keeps it contiguous when modifying it.
checks for a number of common mistakes; in particular,
it will refuse to format a
is specified with
larger than two.
It also refuses to format a raw
partition that begins at offset zero in the disk.
(The beginning of the disk should contain an
partition table with master boot record,
not a FAT file system or boot block.)
Both checks are disabled by the
option prints debugging information.
is an example of a suitable
to make the disk a boot disk.
It gets loaded by the BIOS at 0x7C00,
reads the root directory into address 0x7E00, and looks at
the first root directory entry.
If that file is called
single sector reads to load the file into address 0x10000 and then
jumps to the loaded file image.
is similar, but because it uses LBA addressing (not supported
by all BIOSes), it can access more than the first 8.5GB of the disk.
installs a new boot block in sector 0 (the master boot record)
of a disk such as
This boot block should not be confused with the
boot block used by
which goes in sector 0 of a partition.
Typically, the boot block in the master boot record
scans the PC partition table to find an active
partition and then executes the boot block for
The partition boot block then loads a bootstrap
program such as
which then loads the operating system.
If MS-DOS or Windows 9 is already installed
on your hard disk, the master boot record
already has a suitable boot block.
is an appropriate
It detects and uses LBA addressing when available
from the BIOS (the same could not
be done in the case of
due to space considerations).
is not specified, a boot block is installed that
prints a message explaining that the disk is not bootable.
option initialises the partition table to consist of one
partition which spans the entire disc starting at the end of the