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.
146 A one-sector partition used to store an
156 A one-sector partition used to simulate non-volatile RAM on PCs.
170 edits the PC partition table and is usually
171 invoked with a disk like
173 as its argument, while
175 edits the Plan 9 partition table
176 and is usually invoked with a disk partition
181 works in units of disk ``cylinders'': the cylinder
182 size in bytes is printed when
186 works in units of disk sectors, which are almost always 512 bytes.
190 share most of their options:
195 Automatically partition the disk.
198 partition in the largest unused area on the disk,
200 Plan 9 partition already exists.
201 If no other partition on the disk is marked active (i.e. marked as the boot partition),
203 will mark the new partition active.
206 flag takes the name of a partition to create.
207 (See the list above for partition names.)
208 It can be repeated to specify a list of partitions to create.
209 If the disk is currently unpartitioned,
211 will create the named partitions on the disk,
212 attempting to use the entire disk in a sensible manner.
213 The partition names must be from the list given above.
216 Start with a blank disk, ignoring any extant partition table.
219 Print a sequence of commands that when sent to the disk device's
222 will bring the partition
223 table information kept by
229 will check to see if it is being called with a disk partition
230 (rather than an entire disk) as its argument; if so, it
231 will translate the printed sectors by the partition's offset
235 operates on a table of unnamed partitions,
236 it assigns names based on the partition type
243 and resolves collisions by appending a numbered suffix.
250 In the absence of the
258 enter an interactive partition editor;
261 flag runs the editor in read-only mode.
264 Specify the disk's sector size.
265 In the absence of this flag,
271 file and read it to find the disk's sector size.
274 file cannot be found, a message is printed and
275 a sector size of 512 bytes is assumed.
278 Write the partition table to the disk and exit.
279 This is useful when used in conjunction with
292 enter an interactive partition editor that
293 operates on named partitions.
294 The PC partition table distinguishes between
295 primary partitions, which can be listed in the boot
296 sector at the beginning of the disk,
297 and secondary (or extended) partitions, arbitrarily
298 many of which may be chained together in place
299 of a primary partition.
300 Primary partitions are named
304 The number of primary partitions plus number of contiguous chains of
305 secondary partitions cannot exceed four.
307 The commands are as follows.
308 In the descriptions, read ``sector'' as ``cylinder'' when using
313 .B "a\fR \fIname\fR [ \fIstart\fR [ \fIend\fR ] ]"
314 Create a partition named
316 starting at sector offset
320 The new partition will not be created if
321 it overlaps an extant partition.
330 will prompt for them.
333 the newly created partition has type
335 to set a different type, use the
341 may be expressions using the operators
347 numeric constants, and the
352 At the start of the program,
354 is set to zero; each time a partition is
355 created, it is set to the end sector
356 of the new partition.
357 It can also be explicitly set using the
363 is set to one past the last disk sector.
367 is set to the maximum value that
369 can take on without running off the disk
370 or into another partition.
371 Numeric constants followed by
377 (or upper-case equivalents)
378 are scaled to the respective size in kilo-, mega-, giga-, or tera-bytes.
379 Finally, the expression
382 .RI ( n × disksize )/100.
385 creates a new partition starting at
387 that takes up a fifth of the disk,
389 creates a new partition starting at
391 that takes up 21 gigabytes (21×2\u\s-130\s0\d bytes),
394 creates a new partition starting at
396 extending as far as possible.
399 Set the value of the variable
403 which is an arithmetic expression as described
404 in the discussion of the
409 Delete the named partition.
412 Print a help message listing command synopses.
415 Print the disk partition table.
416 Unpartitioned regions are also listed.
417 The table consists of a number of lines containing
418 partition name, beginning and ending sectors,
422 is prefixed to the names of partitions
423 whose entries have been modified but not written to disk.
425 adds to the end of each line a textual partition type,
428 next to the name of the active partition
434 Print the partition table in the format accepted by the disk's
436 file, which is also the format of the output of the
441 Write the partition table to disk.
443 will also inform the kernel of the changed
445 The write will fail if any programs have any
446 of the disk's partitions open.
447 If the write fails (for this or any other reason),
451 will attempt to restore the partition table to
456 If the partition table has been modified but not written,
457 a warning is printed.
460 again will quit the program.
463 also has the following commands.
464 .TF "t \fR[\fI type \fR]
468 Set the named partition active.
469 The active partition is the one whose boot block is used
470 when booting a PC from disk.
473 Print the names of empty slots in the partition table, i.e., the
474 valid names to use when creating a new partition.
476 .BI t " \fR[\fI type \fR]
477 Set the partition type. If it is not given,
479 will display a list of choices and then prompt for it.
483 prepares for use the floppy diskette or hard disk partition in the file named
492 Do not physically format the disc. Used
493 to install a FAT file system on a
494 previously formatted disc. If
496 is not a floppy device, this flag is a no-op.
499 specify a density and type of disk to be prepared.
506 3½" double density, 737280 bytes
509 3½" high density, 1474560 bytes
512 5¼" double density, 368640 bytes
515 5¼" high density, 1146880 bytes
523 is a floppy drive is the highest possible on the device.
526 is a regular file, the default is
532 device, the default is
537 initialize a FAT file system on the
544 to be installed in sector 0.
547 The remaining options have effect only when
552 use a FAT cluster size of
554 sectors when creating the FAT.
559 when creating the FAT file system.
564 sectors of the partition as ``reserved''.
565 Since the first sector always contains the
566 FAT parameter block, this really marks
569 sectors starting at sector 1 as ``reserved''.
575 should be used to jump over the partition table sector.
582 listed are added, in order,
584 directory of the FAT file system. The files are
585 contiguously allocated.
588 it will be created with the
590 attribute set so that
592 keeps it contiguous when modifying it.
595 checks for a number of common mistakes; in particular,
596 it will refuse to format a
603 It also refuses to format a raw
605 partition that begins at offset zero in the disk.
606 (The beginning of the disk should contain an
608 partition table with master boot record,
609 not a FAT file system or boot block.)
610 Both checks are disabled by the
615 option prints debugging information.
619 is an example of a suitable
621 to make the disk a boot disk.
622 It gets loaded by the BIOS at 0x7C00,
623 reads the first sector of the
624 root directory into address 0x7E00, and looks for
625 a directory entry named
627 If it finds such an entry,
629 single sector reads to load the file into address 0x10000 and then
630 jumps to the loaded file image.
633 is similar, but because it uses LBA addressing (not supported
634 by older BIOSes), it can access more than the first 8.5GB of the disk.
637 installs a new boot block in sector 0 (the master boot record)
642 contains more than one sector of `boot block',
643 the rest will be copied into the first track of the
645 This boot block should not be confused with the
648 which goes in sector 0 of a partition.
649 Typically, the boot block in the master boot record
650 scans the PC partition table to find an active
651 partition and then executes the boot block for
653 The partition boot block then loads a bootstrap
656 which then loads the operating system.
657 If MS-DOS or Windows 9[58] is already installed
658 on your hard disk, the master boot record
659 already has a suitable boot block.
664 It detects and uses LBA addressing when available
665 from the BIOS (the same could not
666 be done in the case of
668 due to space considerations).
671 is not specified, a boot block is installed that
672 prints a message explaining that the disk is not bootable.
675 option initialises the partition table to consist of one
677 partition which spans the entire disc starting at the end of the
680 Initialize the kernel disk driver with the partition information
681 from the FAT boot sectors.
682 If Plan 9 partitions exist, pass that partition information as well.
685 for(disk in /dev/sd??) {
686 if(test -f $disk/data && test -f $disk/ctl)
687 disk/fdisk -p $disk/data >$disk/ctl
688 for(part in $disk/plan9*)
690 disk/prep -p $part >$disk/ctl
694 Create a Plan 9 boot floppy on a previously formatted diskette.
697 disk/format -b /386/pbs -df /dev/fd0disk \e
698 /386/9load /tmp/plan9.ini /386/9pcf.gz
701 Initialize the blank hard disk
705 disk/mbr -m /386/mbr /dev/sdC0/data
706 disk/fdisk -baw /dev/sdC0/data
707 disk/prep -bw -a^(9fat nvram fossil cache swap) /dev/sdC0/plan9
708 disk/format -b /386/pbslba -d -r 2 /dev/sdC0/9fat \e
709 /386/9load /386/9pcf /tmp/plan9.ini
712 Create a bootable USB disk or flash-memory device to be booted
713 via the BIOS and containing only a FAT Plan 9 partition.
716 mount /srv/usb /n/usb
717 ls -d /n/usb/sdU* # note the name, normally sdU0.0
718 disk/partfs /n/usb/sdU0.0/data
720 disk/mbr -m /386/mbr data
722 disk/prep -bw -a^(9fat nvram fossil) plan9
723 cp /386/9loadusb /tmp/9load # force format to use the name `9load'
724 disk/format -b /386/pbslba -d -r 2 9fat /tmp/9load \e
725 /386/9pccpuf /tmp/plan9.ini
733 self-configuring `smart boot manager'
735 .TF /sys/src/cmd/disk/prep
737 .B /sys/src/cmd/disk/prep
741 .B /n/sources/extra/bootmgr.tgz
743 .BR /386/mbr.bootmgr ;
744 compilable on (l)unix
753 can create FAT12 and FAT16
754 file systems, but not FAT32 file systems.
755 The boot block can only read from
756 FAT12 and FAT16 file systems.
760 doesn't find a Plan 9 partition table,
761 it will emit commands to delete
766 will delete all partitions,
769 if there are no partitions defined in the MBR.