.TH PREP 8.SH NAMEprep, fdisk, format, mbr \- prepare hard and floppy diskettes, flashes.SH SYNOPSIS.B disk/prep[.B -bcfnprw][.B -a.I name]...[.B -s .I sectorsize].I plan9partition.PP.B disk/fdisk[.B -abfprw][.B -s.I sectorsize].I disk.PP.B disk/format[.B -dfvx][.B -b .I bootblock][.B -c.I csize][.B -l.I label][.B -r.I nresrv][.B -t.I type].I disk[.IR file ...].PP.B disk/mbr[.B -9][.B -m.I mbrfile].SH DESCRIPTIONA partition table is stored on a hard disk to specify the division ofthe physical disk into a set of logical units.On PCs, the partition table is stored at the end of the master boot recordof the disk.Partitions of type.B 0x39are Plan 9 partitions.Inferno uses the same type and follows other Plan 9 conventions described here.The names of PC partitions are chosen by convention from the type:.BR dos ,.BR plan9 ,etc.Second and subsequent partitions of the same type on a given disk are givenunique names by appending a number (or a period and a number if the namealready ends in a number)..PPPlan 9 partitions (and Plan 9 disks on non-PCs) arethemselves divided, using a textual partition table, called the Plan 9 partition table, in the secondsector of the partition (the first is left for architecture-specific boot data, such as PC boot blocks).Inferno again uses the same conventions.The table is a sequence of lines of the format.BI part " name start end" \fR,where.I startand.I endname 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 10do not overlap..PPThe Plan 9 partition often contains a number ofconventionally named subpartitions.Only.BR 9fat ,.BR fsand.BR nvramare currently used by Inferno, but the others are included for reference.They include:.TF arenas.TP .B 9fatA small FAT file system used to holdconfiguration information (such as.B plan9.iniand.BR plan9.nvr )and kernels.This typically begins in the first sectorof the partition, and contains the partitiontable as a ``reserved'' sector.See the discussion of the.B -roption to.IR format ..TP.B arenasA Plan 9.IR ventiarenas partition..TP.B cacheA Plan 9.IR cfsfile system cache..TP.B fossilA Plan 9.IR fossilfile system..TP.B fsA.IR kfs (4)file system..TP.B fscfgA one-sector partition used to store a.IR ds (3)configuration..TP.B isectA Plan 9.IR ventiindex section..TP.B nvramA one-sector partition used to simulate non-volatile RAM on PCs..TP.B otherA non-archived Plan 9.IR fossilfile system..TP.B swapA Plan 9swap partition..PD.PP.I Fdiskedits the PC partition table and is usuallyinvoked with a disk like.B /dev/sdC0/data as its argument, while.I prepedits the Plan 9 partition tableand is usually invoked with a disk partitionlike.B /dev/sdC0/plan9as its argument..I Fdiskworks in units of disk ``cylinders'': the cylindersize in bytes is printed when.I fdiskstarts..I Prepworks in units of disk sectors, which are almost always 512 bytes..I Fdiskand.I prepshare most of their options:.TP.B -aAutomatically partition the disk..I Fdiskwill create a Plan 9partition in the largest unused area on the disk,doing nothing if aPlan 9 partition already exists.If no other partition on the disk is marked active (i.e. marked as the boot partition),.I fdiskwill mark the new partition active..IR Prep 's.B -aflag takes the name of a partition to create.(See the list above for partition names.)It can be repeated to specify a list of partitions to create.If the disk is currently unpartitioned, .I prepwill create the named partitions on the disk,attempting to use the entire disk in a sensible manner.The partition names must be from the list given above..TP.B -bStart with a blank disk, ignoring any extant partition table..TP.B -pPrint a sequence of commands that when sent to the disk device's.B ctl file will bring the partitiontable information kept bythe .IR sd (3) driver up to date.Then exit..I Prepwill check to see if it is being called with a disk partition(rather than an entire disk) as its argument; if so, itwill translate the printed sectors by the partition's offsetwithin the disk.Since .I fdiskoperates on a table of unnamed partitions,it assigns 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.(e.g.,.BR dos ,.BR dos1 ,.BR dos2 )..TP.B -rIn the absence of the .B -pand.B -wflags, .I prepand.I fdiskenter an interactive partition editor;the .B -rflag runs the editor in read-only mode..TP.BI -s " sectorsize"Specify the disk's sector size.In the absence of this flag,.I prepand.I fdisklook for a disk.B ctlfile and read it to find the disk's sector size.If the.B ctlfile cannot be found, a message is printed anda sector size of 512 bytes is assumed..TP.B -wWrite the partition table to the disk and exit.This is useful when used in conjunction with.B -aor.BR -b ..PPIf neither the.B -pflag nor the.B -wflag is given,.I prepand.I fdiskenter an interactive partition editor thatoperates on named partitions.The PC partition table distinguishes betweenprimary partitions, which can be listed in the bootsector at the beginning of the disk,and secondary (or extended) partitions, arbitrarilymany of which may be chained together in placeof a primary partition.Primary partitions are named.BR p \fIn\fR,secondary partitions.BR s \fIn\fR.The number of primary partitions plus number of contiguous chains ofsecondary partitions cannot exceed four..PPThe commands are as follows.In the descriptions, read ``sector'' as ``cylinder'' when using.IR fdisk ..TP.B "a\fR \fIname\fR [ \fIstart\fR [ \fIend\fR ] ]"Create a partition named.I namestarting at sector offset.I startand ending at offset.IR end .The new partition will not be created ifit overlaps an extant partition.If.I startor.I endare omitted,.I prepand.I fdiskwill prompt for them.In.IR fdisk ,the newly created partition has type.RB `` PLAN9 ;''to set a different type, use the.B tcommand (q.v.)..I Startand.I endmay be expressions using the operators.BR + ,.BR - ,.BR * ,and.BR / ,numeric constants, and thepseudovariables.B .and.BR $ .At the start of the program,.B .is set to zero; each time a partition iscreated, it is set to the end sectorof the new partition.It can also be explicitly set using the.B .command.When evaluating.IR start ,.B $is set to one past the last disk sector.When evaluating.IR end ,.B $is set to the maximum value that .I endcan take on without running off the diskor into another partition.Finally, the expression.IB n %evaluates to .RI ( n × disksize )/100.As an example, .B a.B ..B .+20%creates a new partition starting at.B .that takes up a fifth of the disk,and .B a.B 1000.B $creates a new partition starting atsector 1000 andextending as far as possible..TP.B ".\fR \fInewdot"Set the value of the variable.B .to.IR newdot ,which is an arithmetic expression as describedin the discussion of the.B acommand..TP.BI d " name"Delete the named partition..TP.B hPrint a help message listing command synopses..TP.B pPrint the disk partition table.Unpartitioned regions are also listed.The table consists of a number of lines containingpartition name, beginning and ending sectors,and total size.A .B 'is prefixed to the names of partitionswhose entries have been modified but not written to disk..I Fdiskadds to the end of each line a textual partition type,and places a .B *next to the name of the active partition(see the.B Acommand below)..TP.B PPrint the partition table in the format accepted by the disk's.B ctlfile, which is also the format of the output of the.B -poption..TP.B wWrite the partition table to disk..I Prepwill also inform the kernel of the changedpartition table.The write will fail if any programs have anyof the disk's partitions open.If the write fails (for this or any other reason),.I prepand.I fdiskwill attempt to restore the partition table toits former state..TP.B qQuit the program.If the partition table has been modified but not written,a warning is printed.Typing.B qagain will quit the program..PP.I Fdiskalso has the following commands..TP.BI A " nameSet the named partition active.The active partition is the one whose boot block is usedwhen booting a PC from disk..TP.B ePrint the names of empty slots in the partition table, i.e., thevalid names to use when creating a new partition..TP.BI t " \fR[\fI type \fR]Set the partition type. If it is not given, .I fdiskwill display a list of choices and then prompt for it..PD.PP.I Formatprepares for use the floppy diskette or hard disk partition in the file named.IR disk ,for example.B /dev/fd0disk or.BR /dev/sdC0/9fat .The options are:.TP.B -fDo not physically format the disc. Usedto install a FAT file system on apreviously formatted disc. If.I diskis not a floppy device, this flag is a no-op..TP.B -tspecify a density and type of disk to be prepared.The possible.I typesare:.RS.TP.B 3½DD3½" double density, 737280 bytes.TP.B 3½HD3½" high density, 1474560 bytes.TP.B 5¼DD5¼" double density, 368640 bytes.TPLines 1–500 of 710. Load more
.TH PREP 8 .SH NAME prep, fdisk, format, mbr \- prepare hard and floppy diskettes, flashes .SH SYNOPSIS .B disk/prep [ .B -bcfnprw ] [ .B -a .I name ]... [ .B -s .I sectorsize ] .I plan9partition .PP .B disk/fdisk [ .B -abfprw ] [ .B -s .I sectorsize ] .I disk .PP .B disk/format [ .B -dfvx ] [ .B -b .I bootblock ] [ .B -c .I csize ] [ .B -l .I label ] [ .B -r .I nresrv ] [ .B -t .I type ] .I disk [ .IR file ... ] .PP .B disk/mbr [ .B -9 ] [ .B -m .I mbrfile ] .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. Partitions of type .B 0x39 are Plan 9 partitions. Inferno uses the same type and follows other Plan 9 conventions described here. The names of PC partitions are chosen by convention from the type: .BR dos , .BR 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). .PP 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). Inferno again uses the same conventions. The table is a sequence of lines of the format .BI part " name start end" \fR, where .I start and .I 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. .PP The Plan 9 partition often contains a number of conventionally named subpartitions. Only .BR 9fat , .BR fs and .BR nvram are currently used by Inferno, but the others are included for reference. They include: .TF arenas .TP .B 9fat A small FAT file system used to hold configuration information (such as .B plan9.ini and .BR plan9.nvr ) and kernels. This typically begins in the first sector of the partition, and contains the partition table as a ``reserved'' sector. See the discussion of the .B -r option to .IR format . .TP .B arenas A Plan 9 .IR venti arenas partition. .TP .B cache A Plan 9 .IR cfs file system cache. .TP .B fossil A Plan 9 .IR fossil file system. .TP .B fs A .IR kfs (4) file system. .TP .B fscfg A one-sector partition used to store a .IR ds (3) configuration. .TP .B isect A Plan 9 .IR venti index section. .TP .B nvram A one-sector partition used to simulate non-volatile RAM on PCs. .TP .B other A non-archived Plan 9 .IR fossil file system. .TP .B swap A Plan 9 swap partition. .PD .PP .I Fdisk edits the PC partition table and is usually invoked with a disk like .B /dev/sdC0/data as its argument, while .I prep edits the Plan 9 partition table and is usually invoked with a disk partition like .B /dev/sdC0/plan9 as its argument. .I Fdisk works in units of disk ``cylinders'': the cylinder size in bytes is printed when .I fdisk starts. .I Prep works in units of disk sectors, which are almost always 512 bytes. .I Fdisk and .I prep share most of their options: .TP .B -a Automatically partition the disk. .I Fdisk will create a Plan 9 partition in the largest unused area on the disk, doing nothing if a Plan 9 partition 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. .IR Prep 's .B -a flag takes the name of a partition to create. (See the list above for partition names.) It can be repeated to specify a list of partitions to create. If the disk is currently unpartitioned, .I prep will create the named partitions on the disk, attempting to use the entire disk in a sensible manner. The partition names must be from the list given above. .TP .B -b Start with a blank disk, ignoring any extant partition table. .TP .B -p Print a sequence of commands that when sent to the disk device's .B ctl file will bring the partition table information kept by the .IR sd (3) driver up to date. Then exit. .I 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 the partition's offset within the disk. Since .I fdisk operates on a table of unnamed partitions, it assigns 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. (e.g., .BR dos , .BR dos1 , .BR dos2 ). .TP .B -r In the absence of the .B -p and .B -w flags, .I prep and .I fdisk enter an interactive partition editor; the .B -r flag runs the editor in read-only mode. .TP .BI -s " sectorsize" Specify the disk's sector size. In the absence of this flag, .I prep and .I fdisk look for a disk .B ctl file and read it to find the disk's sector size. If the .B ctl file cannot be found, a message is printed and a sector size of 512 bytes is assumed. .TP .B -w Write the partition table to the disk and exit. This is useful when used in conjunction with .B -a or .BR -b . .PP If neither the .B -p flag nor the .B -w flag is given, .I prep and .I 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 .BR p \fIn\fR, secondary partitions .BR s \fIn\fR. The number of primary partitions plus number of contiguous chains of secondary partitions cannot exceed four. .PP The commands are as follows. In the descriptions, read ``sector'' as ``cylinder'' when using .IR fdisk . .TP .B "a\fR \fIname\fR [ \fIstart\fR [ \fIend\fR ] ]" Create a partition named .I name starting at sector offset .I start and ending at offset .IR end . The new partition will not be created if it overlaps an extant partition. If .I start or .I end are omitted, .I prep and .I fdisk will prompt for them. In .IR fdisk , the newly created partition has type .RB `` PLAN9 ;'' to set a different type, use the .B t command (q.v.). .I Start and .I end may be expressions using the operators .BR + , .BR - , .BR * , and .BR / , numeric constants, and the pseudovariables .B . and .BR $ . At the start of the program, .B . is set to zero; each time a partition is created, it is set to the end sector of the new partition. It can also be explicitly set using the .B . command. When evaluating .IR start , .B $ is set to one past the last disk sector. When evaluating .IR end , .B $ is set to the maximum value that .I end can take on without running off the disk or into another partition. Finally, the expression .IB n % evaluates to .RI ( n × disksize )/100. As an example, .B a .B . .B .+20% creates a new partition starting at .B . that takes up a fifth of the disk, and .B a .B 1000 .B $ creates a new partition starting at sector 1000 and extending as far as possible. .TP .B ".\fR \fInewdot" Set the value of the variable .B . to .IR newdot , which is an arithmetic expression as described in the discussion of the .B a command. .TP .BI d " name" Delete the named partition. .TP .B h Print a help message listing command synopses. .TP .B 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 .B ' is prefixed to the names of partitions whose entries have been modified but not written to disk. .I Fdisk adds to the end of each line a textual partition type, and places a .B * next to the name of the active partition (see the .B A command below). .TP .B P Print the partition table in the format accepted by the disk's .B ctl file, which is also the format of the output of the .B -p option. .TP .B w Write the partition table to disk. .I 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), .I prep and .I fdisk will attempt to restore the partition table to its former state. .TP .B q Quit the program. If the partition table has been modified but not written, a warning is printed. Typing .B q again will quit the program. .PP .I Fdisk also has the following commands. .TP .BI A " name Set the named partition active. 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] 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 Format prepares for use the floppy diskette or hard disk partition in the file named .IR disk , for example .B /dev/fd0disk or .BR /dev/sdC0/9fat . The options are: .TP .B -f Do not physically format the disc. Used to install a FAT file system on a previously formatted disc. If .I disk is not a floppy device, this flag is a no-op. .TP .B -t specify a density and type of disk to be prepared. The possible .I types are: .RS .TP .B 3½DD 3½" double density, 737280 bytes .TP .B 3½HD 3½" high density, 1474560 bytes .TP .B 5¼DD 5¼" double density, 368640 bytes .TP