.TH PREP 8
.SH NAME
-prep, fdisk, format, mbr \- prepare disks, floppies and flashes
+prep, edisk, fdisk, format, mbr \- prepare disks, floppies and flashes
.SH SYNOPSIS
.B disk/prep
[
]
.I plan9partition
.PP
+.B disk/edisk
+[
+.B -abfprw
+]
+[
+.B -s
+.I sectorsize
+]
+.I disk
+.PP
.B disk/fdisk
[
.B -abfprw
.SH DESCRIPTION
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.
+On PCs using traditional DOS partition table, the partition entries are stored
+at the end of the master boot record of the disk.
Partitions of type
.B 0x39
are Plan 9 partitions.
-The names of PC partitions are chosen by convention from the type:
+EFI systems use GUID partition table (GPT) format where partition types
+are identied by a 128-bit long identifiers. The randomly
+generated GUID
+.B C91818F9-8025-47AF-89D2-F030D7000C2C
+is used to identify the Plan 9 partition type in this scheme.
+The names of DOS and GPT partitions are chosen by convention from the type:
.BR dos ,
.BR plan9 ,
etc.
.IR cfs (4)
file system cache.
.TP
-.B fossil
+.B fscache
A
-.IR fossil (4)
-file system.
+.IR cwfs (4)
+worm cache partition.
.TP
-.B fs
+.B fsworm
A
-.IR kfs (4)
-file system.
+.IR cwfs (4)
+worm filesystem.
+.TP
+.B fs
+A kfs file system.
.TP
.B fscfg
A one-sector partition used to store an
.TP
.B other
A non-archived
-.IR fossil (4)
+.IR cwfs (4)
file system.
.TP
.B swap
.PD
.PP
.I Fdisk
-edits the PC partition table and is usually
+edits the DOS partition table and is usually
invoked with a disk like
.B /dev/sdC0/data
as its argument, while
like
.B /dev/sdC0/plan9
as its argument.
+.I Edisk
+is similar to
+.I fdisk
+but edits the GPT partition table on EFI systems.
.I Fdisk
works in units of disk ``cylinders'': the cylinder
size in bytes is printed when
.I fdisk
starts.
.I Prep
+and
+.I edisk
works in units of disk sectors, which are almost always 512 bytes.
-.I Fdisk
+.IR Fdisk ,
+.I edisk
and
.I prep
share most of their options:
.B -a
Automatically partition the disk.
.I Fdisk
+and
+.I edisk
will create a Plan 9
partition in the largest unused area on the disk,
doing nothing if a
Plan 9 partition already exists.
+.I Edisk
+also adds a EFI system partition (esp) when not already exists.
If no other partition on the disk is marked active (i.e. marked as the boot partition),
.I fdisk
will mark the new partition active.
within the disk.
Since
.I fdisk
-operates on a table of unnamed partitions,
-it assigns names based on the partition type
+and
+.I edisk
+operate on a table of unnamed partitions,
+they assign names based on the partition type
(e.g.,
.BR plan9 ,
.BR dos ,
.BR ntfs ,
.BR linux ,
.BR linuxswap )
-and resolves collisions by appending a numbered suffix.
+and resolve collisions by appending a numbered suffix.
(e.g.,
.BR dos ,
.BR dos.1 ,
and
.B -w
flags,
-.I prep
+.IR prep ,
+.I edisk
and
.I fdisk
enter an interactive partition editor;
.BI -s " sectorsize"
Specify the disk's sector size.
In the absence of this flag,
-.I prep
+.IR prep ,
+.I edisk
and
.I fdisk
look for a disk
flag nor the
.B -w
flag is given,
-.I prep
+.IR prep ,
+.I edisk
and
.I fdisk
enter an interactive partition editor that
operates on named partitions.
-The PC partition table distinguishes between
+The DOS 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
.BR s \fIn\fR.
The number of primary partitions plus number of contiguous chains of
secondary partitions cannot exceed four.
+The GPT partition table is a fixed array of partition
+entries (usually 128). Partitions are named
+.BR p \fIn\fR,
+where
+.I n
+indexes the entry in array starting from 1 for the first entry.
.PP
The commands are as follows.
In the descriptions, read ``sector'' as ``cylinder'' when using
.I start
or
.I end
-are omitted,
-.I prep
-and
-.I fdisk
-will prompt for them.
+are omitted, the editor will prompt for them.
In
-.IR fdisk ,
-the newly created partition has type
-.RB `` PLAN9 ;''
-to set a different type, use the
+.I fdisk
+and
+.I edisk
+the newly created partition is of the
+.B Plan 9
+type; to set a different type, use the
.B t
command (q.v.).
.I Start
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),
-.I prep
-and
-.I fdisk
-will attempt to restore the partition table to
+the program will attempt to restore the partition table to
its former state.
.TP
.B q
The active partition is the one whose boot block is used
when booting a PC from disk.
.TP
-.B e
-Print the names of empty slots in the partition table, i.e., the
-valid names to use when creating a new partition.
-.TP
-.BI t " \fR[\fI type \fR]
+.BI t " name \fR[\fI type \fR]
Set the partition type. If it is not given,
.I fdisk
will display a list of choices and then prompt for it.
.PD
.PP
+.I Edisk
+also has the following commands.
+.TF "t \fR[\fI type \fR]
+.PD
+.TP
+.BI t " name \fR[\fI type \fR]
+Set the partition type; like
+.I fdisk
+above.
+.PD
+.TP
+.BI f " name \fR[\fI +-attr \fR]
+Set or clear partition attributes.
+.PD
+.TP
+.BI l " name \fR[\fI label \fR]
+Set the partition label.
+.PP
.I Format
prepares for use the floppy diskette or hard disk partition in the file named
.IR disk ,
to the root
directory of the FAT file system. The files are
contiguously allocated.
-If a file is named
-.BR 9load ,
-it will be created with the
-.B SYSTEM
-attribute set so that
-.IR dossrv (4)
-keeps it contiguous when modifying it.
.PP
.I Format
checks for a number of common mistakes; in particular,
reads the first sector of the
root directory into address 0x7E00, and looks for
a directory entry named
-.BR 9LOAD .
+.BR 9BOOTFAT .
If it finds such an entry,
it uses
-single sector reads to load the file into address 0x10000 and then
+single sector reads to load the file into address 0x7C00 and then
jumps to the loaded file image.
-The file
-.B /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.
.PP
.I Mbr
installs a new boot block in sector 0 (the master boot record)
that partition.
The partition boot block then loads a bootstrap
program such as
-.IR 9load (8),
+.IR 9boot (8),
which then loads the operating system.
If MS-DOS or Windows 9[58] is already installed
on your hard disk, the master boot record
}
.EE
.PP
-Create a Plan 9 boot floppy on a previously formatted diskette.
-.IP
-.EX
-disk/format -b /386/pbs -df /dev/fd0disk \e
- /386/9load /tmp/plan9.ini /386/9pcf.gz
-.EE
-.PP
Initialize the blank hard disk
.BR /dev/sdC0/data .
.IP
.EX
disk/mbr -m /386/mbr /dev/sdC0/data
disk/fdisk -baw /dev/sdC0/data
-disk/prep -bw -a^(9fat nvram fossil cache swap) /dev/sdC0/plan9
-disk/format -b /386/pbslba -d -r 2 /dev/sdC0/9fat \e
- /386/9load /386/9pcf /tmp/plan9.ini
-.EE
-.PP
-Create a bootable USB disk or flash-memory device to be booted
-via the BIOS and containing only a FAT Plan 9 partition.
-.IP
-.EX
-mount /srv/usb /n/usb
-ls -d /n/usb/sdU* # note the name, normally sdU0.0
-disk/partfs /n/usb/sdU0.0/data
-cd /dev/sdXX
-disk/mbr -m /386/mbr data
-disk/fdisk -baw data
-disk/prep -bw -a^(9fat nvram fossil) plan9
-cp /386/9loadusb /tmp/9load # force format to use the name `9load'
-disk/format -b /386/pbslba -d -r 2 9fat /tmp/9load \e
- /386/9pccpuf /tmp/plan9.ini
+disk/prep -bw -a^(9fat nvram fscache fsworm other swap) /dev/sdC0/plan9
+disk/format -b /386/pbs -d -r 2 /dev/sdC0/9fat \e
+ /386/9bootfat /386/9pc /tmp/plan9.ini
.EE
.SH FILES
-.TF /386/mbr.bootmgr
.TP
.B /386/mbr
.TP
-.B /386/mbr.bootmgr
-self-configuring `smart boot manager'
+.B /386/pbs
.SH SOURCE
.TF /sys/src/cmd/disk/prep
.TP
.B /sys/src/cmd/disk/prep
.TP
.B /sys/src/boot/pc
-.TP
-.B /n/sources/extra/bootmgr.tgz
-source for
-.BR /386/mbr.bootmgr ;
-compilable on (l)unix
.SH SEE ALSO
.IR floppy (3),
.IR sd (3),
-.IR usb (4),
-.IR 9load (8),
-.IR partfs (8)
+.IR nusb (4),
+.IR 9boot (8),
+.IR partfs (8),
+.IR diskparts (8)
.SH BUGS
-.I 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.
-.PP
If
.L "prep -p"
doesn't find a Plan 9 partition table,