3 prep, edisk, fdisk, format, mbr \- prepare disks, floppies and flashes
78 A partition table is stored on a hard disk to specify the division of
79 the physical disk into a set of logical units.
80 On PCs using traditional DOS partition table, the partition entries are stored
81 at the end of the master boot record of the disk.
84 are Plan 9 partitions.
85 EFI systems use GUID partition table (GPT) format where partition types
86 are identied by a 128-bit long identifiers. The randomly
88 .B C91818F9-8025-47AF-89D2-F030D7000C2C
89 is used to identify the Plan 9 partition type in this scheme.
90 The names of DOS and GPT partitions are chosen by convention from the type:
94 Second and subsequent partitions of the same type on a given disk are given
95 unique names by appending a number (or a period and a number if the name
96 already ends in a number).
98 Plan 9 partitions (and Plan 9 disks on non-PCs) are
99 themselves divided, using a textual partition table, called the Plan 9 partition table, in the second
100 sector of the partition (the first is left for architecture-specific boot data, such as PC boot blocks).
101 The table is a sequence of lines of the format
102 .BI part " name start end" \fR,
107 name the starting and ending sector.
108 Sector 0 is the first sector of the Plan 9 partition or disk,
109 regardless of its position in a larger disk.
110 Partition extents do not contain the ending sector,
111 so a partition from 0 to 5 and a partition from 5 to 10
114 The Plan 9 partition often contains a number of
115 conventionally named subpartitions.
120 A small FAT file system used to hold
121 configuration information
127 This typically begins in the first sector
128 of the partition, and contains the partition
129 table as a ``reserved'' sector.
130 See the discussion of the
143 bloom-filter partition.
153 worm cache partition.
164 A one-sector partition used to store an
174 A one-sector partition used to simulate non-volatile RAM on PCs.
188 edits the DOS partition table and is usually
189 invoked with a disk like
191 as its argument, while
193 edits the Plan 9 partition table
194 and is usually invoked with a disk partition
201 but edits the GPT partition table on EFI systems.
203 works in units of disk ``cylinders'': the cylinder
204 size in bytes is printed when
210 works in units of disk sectors, which are almost always 512 bytes.
215 share most of their options:
220 Automatically partition the disk.
225 partition in the largest unused area on the disk,
227 Plan 9 partition already exists.
229 also adds a EFI system partition (esp) when not already exists.
230 If no other partition on the disk is marked active (i.e. marked as the boot partition),
232 will mark the new partition active.
235 flag takes the name of a partition to create.
236 (See the list above for partition names.)
237 It can be repeated to specify a list of partitions to create.
238 If the disk is currently unpartitioned,
240 will create the named partitions on the disk,
241 attempting to use the entire disk in a sensible manner.
242 The partition names must be from the list given above.
245 Start with a blank disk, ignoring any extant partition table.
248 Print a sequence of commands that when sent to the disk device's
251 will bring the partition
252 table information kept by
258 will check to see if it is being called with a disk partition
259 (rather than an entire disk) as its argument; if so, it
260 will translate the printed sectors by the partition's offset
266 operate on a table of unnamed partitions,
267 they assign names based on the partition type
274 and resolve collisions by appending a numbered suffix.
281 In the absence of the
290 enter an interactive partition editor;
293 flag runs the editor in read-only mode.
296 Specify the disk's sector size.
297 In the absence of this flag,
304 file and read it to find the disk's sector size.
307 file cannot be found, a message is printed and
308 a sector size of 512 bytes is assumed.
311 Write the partition table to the disk and exit.
312 This is useful when used in conjunction with
326 enter an interactive partition editor that
327 operates on named partitions.
328 The DOS partition table distinguishes between
329 primary partitions, which can be listed in the boot
330 sector at the beginning of the disk,
331 and secondary (or extended) partitions, arbitrarily
332 many of which may be chained together in place
333 of a primary partition.
334 Primary partitions are named
338 The number of primary partitions plus number of contiguous chains of
339 secondary partitions cannot exceed four.
340 The GPT partition table is a fixed array of partition
341 entries (usually 128). Partitions are named
345 indexes the entry in array starting from 1 for the first entry.
347 The commands are as follows.
348 In the descriptions, read ``sector'' as ``cylinder'' when using
353 .B "a\fR \fIname\fR [ \fIstart\fR [ \fIend\fR ] ]"
354 Create a partition named
356 starting at sector offset
360 The new partition will not be created if
361 it overlaps an extant partition.
366 are omitted, the editor will prompt for them.
371 the newly created partition is of the
373 type; to set a different type, use the
379 may be expressions using the operators
385 numeric constants, and the
390 At the start of the program,
392 is set to zero; each time a partition is
393 created, it is set to the end sector
394 of the new partition.
395 It can also be explicitly set using the
401 is set to one past the last disk sector.
405 is set to the maximum value that
407 can take on without running off the disk
408 or into another partition.
409 Numeric constants followed by
415 (or upper-case equivalents)
416 are scaled to the respective size in kilo-, mega-, giga-, or tera-bytes.
417 Finally, the expression
420 .RI ( n × disksize )/100.
423 creates a new partition starting at
425 that takes up a fifth of the disk,
427 creates a new partition starting at
429 that takes up 21 gigabytes (21×2\u\s-130\s0\d bytes),
432 creates a new partition starting at
434 extending as far as possible.
437 Set the value of the variable
441 which is an arithmetic expression as described
442 in the discussion of the
447 Delete the named partition.
450 Print a help message listing command synopses.
453 Print the disk partition table.
454 Unpartitioned regions are also listed.
455 The table consists of a number of lines containing
456 partition name, beginning and ending sectors,
460 is prefixed to the names of partitions
461 whose entries have been modified but not written to disk.
463 adds to the end of each line a textual partition type,
466 next to the name of the active partition
472 Print the partition table in the format accepted by the disk's
474 file, which is also the format of the output of the
479 Write the partition table to disk.
481 will also inform the kernel of the changed
483 The write will fail if any programs have any
484 of the disk's partitions open.
485 If the write fails (for this or any other reason),
486 the program will attempt to restore the partition table to
491 If the partition table has been modified but not written,
492 a warning is printed.
495 again will quit the program.
498 also has the following commands.
499 .TF "t \fR[\fI type \fR]
503 Set the named partition active.
504 The active partition is the one whose boot block is used
505 when booting a PC from disk.
507 .BI t " name \fR[\fI type \fR]
508 Set the partition type. If it is not given,
510 will display a list of choices and then prompt for it.
514 also has the following commands.
515 .TF "t \fR[\fI type \fR]
518 .BI t " name \fR[\fI type \fR]
519 Set the partition type; like
524 .BI f " name \fR[\fI +-attr \fR]
525 Set or clear partition attributes.
528 .BI l " name \fR[\fI label \fR]
529 Set the partition label.
532 prepares for use the floppy diskette or hard disk partition in the file named
541 Do not physically format the disc. Used
542 to install a FAT file system on a
543 previously formatted disc. If
545 is not a floppy device, this flag is a no-op.
548 specify a density and type of disk to be prepared.
555 3½" double density, 737280 bytes
558 3½" high density, 1474560 bytes
561 5¼" double density, 368640 bytes
564 5¼" high density, 1146880 bytes
572 is a floppy drive is the highest possible on the device.
575 is a regular file, the default is
581 device, the default is
586 initialize a FAT file system on the
593 to be installed in sector 0.
596 The remaining options have effect only when
601 use a FAT cluster size of
603 sectors when creating the FAT.
608 when creating the FAT file system.
613 sectors of the partition as ``reserved''.
614 Since the first sector always contains the
615 FAT parameter block, this really marks
618 sectors starting at sector 1 as ``reserved''.
624 should be used to jump over the partition table sector.
631 listed are added, in order,
633 directory of the FAT file system. The files are
634 contiguously allocated.
637 checks for a number of common mistakes; in particular,
638 it will refuse to format a
645 It also refuses to format a raw
647 partition that begins at offset zero in the disk.
648 (The beginning of the disk should contain an
650 partition table with master boot record,
651 not a FAT file system or boot block.)
652 Both checks are disabled by the
657 option prints debugging information.
661 is an example of a suitable
663 to make the disk a boot disk.
664 It gets loaded by the BIOS at 0x7C00,
665 reads the first sector of the
666 root directory into address 0x7E00, and looks for
667 a directory entry named
669 If it finds such an entry,
671 single sector reads to load the file into address 0x7C00 and then
672 jumps to the loaded file image.
675 installs a new boot block in sector 0 (the master boot record)
680 contains more than one sector of `boot block',
681 the rest will be copied into the first track of the
683 This boot block should not be confused with the
686 which goes in sector 0 of a partition.
687 Typically, the boot block in the master boot record
688 scans the PC partition table to find an active
689 partition and then executes the boot block for
691 The partition boot block then loads a bootstrap
694 which then loads the operating system.
695 If MS-DOS or Windows 9[58] is already installed
696 on your hard disk, the master boot record
697 already has a suitable boot block.
702 It detects and uses LBA addressing when available
703 from the BIOS (the same could not
704 be done in the case of
706 due to space considerations).
709 is not specified, a boot block is installed that
710 prints a message explaining that the disk is not bootable.
713 option initialises the partition table to consist of one
715 partition which spans the entire disc starting at the end of the
718 Initialize the kernel disk driver with the partition information
719 from the FAT boot sectors.
720 If Plan 9 partitions exist, pass that partition information as well.
723 for(disk in /dev/sd??) {
724 if(test -f $disk/data && test -f $disk/ctl)
725 disk/fdisk -p $disk/data >$disk/ctl
726 for(part in $disk/plan9*)
728 disk/prep -p $part >$disk/ctl
732 Initialize the blank hard disk
736 disk/mbr -m /386/mbr /dev/sdC0/data
737 disk/fdisk -baw /dev/sdC0/data
738 disk/prep -bw -a^(9fat nvram fscache fsworm other swap) /dev/sdC0/plan9
739 disk/format -b /386/pbs -d -r 2 /dev/sdC0/9fat \e
740 /386/9bootfat /386/9pc /tmp/plan9.ini
748 .TF /sys/src/cmd/disk/prep
750 .B /sys/src/cmd/disk/prep
763 doesn't find a Plan 9 partition table,
764 it will emit commands to delete
769 will delete all partitions,
772 if there are no partitions defined in the MBR.