NAME
prep, fdisk, format, mbr – prepare disks, floppies and flashes |
SYNOPSIS
disk/prep [ –bcfnprw ] [ –a name ]... [ –s sectorsize ] plan9partition
disk/fdisk [ –abfprw ] [ –s sectorsize ] disk disk/format [ –dfvx ] [ –b bootblock ] [ –c csize ] [ –l label ] [ –r nresrv ] [ –t type ] disk [ file... ]
disk/mbr [ –9 ] [ –m mbrfile ] disk |
DESCRIPTION
A partition table is stored on a non–floppy 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 0x39 are Plan 9 partitions.
The names of PC partitions are chosen by convention from the type:
dos, plan9, etc. 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). The table is a sequence of lines of the format part name start end, where start and 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. They include: fdisk and prep
–p Print a sequence of commands that when sent to the disk device's ctl file will bring the partition table information kept by the sd(3) driver up to date. Then exit. Prep 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
–s sectorsize
If neither the –p flag nor the –w flag is given, prep and fdisk 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 pn, secondary partitions sn. 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 fdisk.
d name Delete the named partition. h Print a help message listing command synopses. p 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. A ' is prefixed to the names of partitions whose entries have been modified but not written to disk. Fdisk adds to the end of
w Write the partition table to disk. Prep will also inform the kernel of the changed partition table. 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), prep and fdisk will attempt to restore the partition table to its former state. q Quit the program. If the partition table has been modified but not written, a warning is printed. Typing q again will quit the program.
Fdisk also has the following commands. format and pbs
–b use the contents of bootblock as a bootstrap block to be installed in sector 0.
The remaining options have effect only when –d is specified: Again under –d, any files listed are added, in order, to the root directory of the FAT file system. The files are contiguously allocated. If a file is named 9load, it will be created with the SYSTEM attribute set so that dossrv(4) keeps it contiguous when modifying it. Format checks for a number of common mistakes; in particular, it will refuse to format a 9fat partition unless –r is specified with nresrv larger than two. It also refuses to format a raw sd(3) partition that begins at offset zero in the disk. (The beginning of the disk should contain an fdisk partition table with master boot record, not a FAT file system or boot block.) Both checks are disabled by the –x option. The –v option prints debugging information.
The file /386/pbs is an example of a suitable bootblock to make
the disk a boot disk. It gets loaded by the BIOS at 0x7C00, reads
the first sector of the root directory into address 0x7E00, and
looks for a directory entry named 9LOAD. If it finds such an entry,
it uses single sector reads to load the file into address
0x10000 and then jumps to the loaded file image. The file /386/pbslba
is similar, but because it uses LBA addressing (not supported
by older BIOSes), it can access more than the first 8.5GB of the
disk. /386/pbsraw is suitable for CDs. mbr |
EXAMPLES
Initialize the kernel disk driver with the partition information
from the FAT boot sectors. If Plan 9 partitions exist, pass that
partition information as well.
|
FILES
/386/mbr /386/mbr.bootmgr self–configuring `smart boot manager' |
SOURCE
/sys/src/cmd/disk/prep /sys/src/boot/pc /n/sources/extra/bootmgr.tgz nasm assembler source for /386/mbr.bootmgr |
SEE ALSO
floppy(3), sd(3), usb(4), 9boot(8), mk9660(8), mkusbboot(8), partfs(8) |
BUGS
Format can create FAT12 and FAT16 file systems, but not FAT32
file systems. The boot block can only read from FAT12 and FAT16
file systems.
If prep –p doesn't find a Plan 9 partition table, it will emit
commands to delete all extant partitions. Similarly, fdisk –p will
delete all partitions, including data, if there are no partitions
defined in the MBR. |