3 prep, fdisk, format, mbr \- prepare disks, floppies and flashes
68 A partition table is stored on a hard disk to specify the division of
69 the physical disk into a set of logical units.
70 On PCs, the partition table is stored at the end of the master boot record
74 are Plan 9 partitions.
75 The names of PC partitions are chosen by convention from the type:
79 Second and subsequent partitions of the same type on a given disk are given
80 unique names by appending a number (or a period and a number if the name
81 already ends in a number).
83 Plan 9 partitions (and Plan 9 disks on non-PCs) are
84 themselves divided, using a textual partition table, called the Plan 9 partition table, in the second
85 sector of the partition (the first is left for architecture-specific boot data, such as PC boot blocks).
86 The table is a sequence of lines of the format
87 .BI part " name start end" \fR,
92 name the starting and ending sector.
93 Sector 0 is the first sector of the Plan 9 partition or disk,
94 regardless of its position in a larger disk.
95 Partition extents do not contain the ending sector,
96 so a partition from 0 to 5 and a partition from 5 to 10
99 The Plan 9 partition often contains a number of
100 conventionally named subpartitions.
105 A small FAT file system used to hold
106 configuration information
112 This typically begins in the first sector
113 of the partition, and contains the partition
114 table as a ``reserved'' sector.
115 See the discussion of the
128 bloom-filter partition.
138 worm cache partition.
151 A one-sector partition used to store an
161 A one-sector partition used to simulate non-volatile RAM on PCs.
175 edits the PC partition table and is usually
176 invoked with a disk like
178 as its argument, while
180 edits the Plan 9 partition table
181 and is usually invoked with a disk partition
186 works in units of disk ``cylinders'': the cylinder
187 size in bytes is printed when
191 works in units of disk sectors, which are almost always 512 bytes.
195 share most of their options:
200 Automatically partition the disk.
203 partition in the largest unused area on the disk,
205 Plan 9 partition already exists.
206 If no other partition on the disk is marked active (i.e. marked as the boot partition),
208 will mark the new partition active.
211 flag takes the name of a partition to create.
212 (See the list above for partition names.)
213 It can be repeated to specify a list of partitions to create.
214 If the disk is currently unpartitioned,
216 will create the named partitions on the disk,
217 attempting to use the entire disk in a sensible manner.
218 The partition names must be from the list given above.
221 Start with a blank disk, ignoring any extant partition table.
224 Print a sequence of commands that when sent to the disk device's
227 will bring the partition
228 table information kept by
234 will check to see if it is being called with a disk partition
235 (rather than an entire disk) as its argument; if so, it
236 will translate the printed sectors by the partition's offset
240 operates on a table of unnamed partitions,
241 it assigns names based on the partition type
248 and resolves collisions by appending a numbered suffix.
255 In the absence of the
263 enter an interactive partition editor;
266 flag runs the editor in read-only mode.
269 Specify the disk's sector size.
270 In the absence of this flag,
276 file and read it to find the disk's sector size.
279 file cannot be found, a message is printed and
280 a sector size of 512 bytes is assumed.
283 Write the partition table to the disk and exit.
284 This is useful when used in conjunction with
297 enter an interactive partition editor that
298 operates on named partitions.
299 The PC partition table distinguishes between
300 primary partitions, which can be listed in the boot
301 sector at the beginning of the disk,
302 and secondary (or extended) partitions, arbitrarily
303 many of which may be chained together in place
304 of a primary partition.
305 Primary partitions are named
309 The number of primary partitions plus number of contiguous chains of
310 secondary partitions cannot exceed four.
312 The commands are as follows.
313 In the descriptions, read ``sector'' as ``cylinder'' when using
318 .B "a\fR \fIname\fR [ \fIstart\fR [ \fIend\fR ] ]"
319 Create a partition named
321 starting at sector offset
325 The new partition will not be created if
326 it overlaps an extant partition.
335 will prompt for them.
338 the newly created partition has type
340 to set a different type, use the
346 may be expressions using the operators
352 numeric constants, and the
357 At the start of the program,
359 is set to zero; each time a partition is
360 created, it is set to the end sector
361 of the new partition.
362 It can also be explicitly set using the
368 is set to one past the last disk sector.
372 is set to the maximum value that
374 can take on without running off the disk
375 or into another partition.
376 Numeric constants followed by
382 (or upper-case equivalents)
383 are scaled to the respective size in kilo-, mega-, giga-, or tera-bytes.
384 Finally, the expression
387 .RI ( n × disksize )/100.
390 creates a new partition starting at
392 that takes up a fifth of the disk,
394 creates a new partition starting at
396 that takes up 21 gigabytes (21×2\u\s-130\s0\d bytes),
399 creates a new partition starting at
401 extending as far as possible.
404 Set the value of the variable
408 which is an arithmetic expression as described
409 in the discussion of the
414 Delete the named partition.
417 Print a help message listing command synopses.
420 Print the disk partition table.
421 Unpartitioned regions are also listed.
422 The table consists of a number of lines containing
423 partition name, beginning and ending sectors,
427 is prefixed to the names of partitions
428 whose entries have been modified but not written to disk.
430 adds to the end of each line a textual partition type,
433 next to the name of the active partition
439 Print the partition table in the format accepted by the disk's
441 file, which is also the format of the output of the
446 Write the partition table to disk.
448 will also inform the kernel of the changed
450 The write will fail if any programs have any
451 of the disk's partitions open.
452 If the write fails (for this or any other reason),
456 will attempt to restore the partition table to
461 If the partition table has been modified but not written,
462 a warning is printed.
465 again will quit the program.
468 also has the following commands.
469 .TF "t \fR[\fI type \fR]
473 Set the named partition active.
474 The active partition is the one whose boot block is used
475 when booting a PC from disk.
478 Print the names of empty slots in the partition table, i.e., the
479 valid names to use when creating a new partition.
481 .BI t " \fR[\fI type \fR]
482 Set the partition type. If it is not given,
484 will display a list of choices and then prompt for it.
488 prepares for use the floppy diskette or hard disk partition in the file named
497 Do not physically format the disc. Used
498 to install a FAT file system on a
499 previously formatted disc. If
501 is not a floppy device, this flag is a no-op.
504 specify a density and type of disk to be prepared.
511 3½" double density, 737280 bytes
514 3½" high density, 1474560 bytes
517 5¼" double density, 368640 bytes
520 5¼" high density, 1146880 bytes
528 is a floppy drive is the highest possible on the device.
531 is a regular file, the default is
537 device, the default is
542 initialize a FAT file system on the
549 to be installed in sector 0.
552 The remaining options have effect only when
557 use a FAT cluster size of
559 sectors when creating the FAT.
564 when creating the FAT file system.
569 sectors of the partition as ``reserved''.
570 Since the first sector always contains the
571 FAT parameter block, this really marks
574 sectors starting at sector 1 as ``reserved''.
580 should be used to jump over the partition table sector.
587 listed are added, in order,
589 directory of the FAT file system. The files are
590 contiguously allocated.
593 checks for a number of common mistakes; in particular,
594 it will refuse to format a
601 It also refuses to format a raw
603 partition that begins at offset zero in the disk.
604 (The beginning of the disk should contain an
606 partition table with master boot record,
607 not a FAT file system or boot block.)
608 Both checks are disabled by the
613 option prints debugging information.
617 is an example of a suitable
619 to make the disk a boot disk.
620 It gets loaded by the BIOS at 0x7C00,
621 reads the first sector of the
622 root directory into address 0x7E00, and looks for
623 a directory entry named
625 If it finds such an entry,
627 single sector reads to load the file into address 0x7C00 and then
628 jumps to the loaded file image.
631 installs a new boot block in sector 0 (the master boot record)
636 contains more than one sector of `boot block',
637 the rest will be copied into the first track of the
639 This boot block should not be confused with the
642 which goes in sector 0 of a partition.
643 Typically, the boot block in the master boot record
644 scans the PC partition table to find an active
645 partition and then executes the boot block for
647 The partition boot block then loads a bootstrap
650 which then loads the operating system.
651 If MS-DOS or Windows 9[58] is already installed
652 on your hard disk, the master boot record
653 already has a suitable boot block.
658 It detects and uses LBA addressing when available
659 from the BIOS (the same could not
660 be done in the case of
662 due to space considerations).
665 is not specified, a boot block is installed that
666 prints a message explaining that the disk is not bootable.
669 option initialises the partition table to consist of one
671 partition which spans the entire disc starting at the end of the
674 Initialize the kernel disk driver with the partition information
675 from the FAT boot sectors.
676 If Plan 9 partitions exist, pass that partition information as well.
679 for(disk in /dev/sd??) {
680 if(test -f $disk/data && test -f $disk/ctl)
681 disk/fdisk -p $disk/data >$disk/ctl
682 for(part in $disk/plan9*)
684 disk/prep -p $part >$disk/ctl
688 Initialize the blank hard disk
692 disk/mbr -m /386/mbr /dev/sdC0/data
693 disk/fdisk -baw /dev/sdC0/data
694 disk/prep -bw -a^(9fat nvram fscache fsworm other swap) /dev/sdC0/plan9
695 disk/format -b /386/pbs -d -r 2 /dev/sdC0/9fat \e
696 /386/9bootfat /386/9pcf /tmp/plan9.ini
704 self-configuring `smart boot manager'
706 .TF /sys/src/cmd/disk/prep
708 .B /sys/src/cmd/disk/prep
712 .B /n/sources/extra/bootmgr.tgz
714 .BR /386/mbr.bootmgr ;
715 compilable on (l)unix
724 can create FAT12 and FAT16
725 file systems, but not FAT32 file systems.
726 The boot block can only read from
727 FAT12 and FAT16 file systems.
731 doesn't find a Plan 9 partition table,
732 it will emit commands to delete
737 will delete all partitions,
740 if there are no partitions defined in the MBR.