457 lines
11 KiB
Groff
457 lines
11 KiB
Groff
.\" $NetBSD: fdisk.8,v 1.42 2003/06/03 12:35:54 joda Exp $
|
|
.\"
|
|
.Dd April 30, 2003
|
|
.Dt FDISK 8
|
|
.Os
|
|
.Sh NAME
|
|
.Nm fdisk
|
|
.Nd DOS partition maintenance program
|
|
.Sh SYNOPSIS
|
|
.Nm
|
|
.Op Fl afiuvBS
|
|
.Bk -words
|
|
.Op Fl 0 | 1 | 2 | 3
|
|
.Ek
|
|
.Bk -words
|
|
.Op Fl E Ar number
|
|
.Ek
|
|
.Bk -words
|
|
.Op Fl b Ar cylinders/heads/sectors
|
|
.Ek
|
|
.Bk -words
|
|
.Op Fl s Ar id/start/size Ns Bq Ar /bootmenu
|
|
.Ek
|
|
.Bk -words
|
|
.Op Fl c Ar bootcode
|
|
.Ek
|
|
.Bk -words
|
|
.Op Fl r|w Ar file
|
|
.Ek
|
|
.Bk -words
|
|
.Op Ar device
|
|
.Ek
|
|
.Nm
|
|
.Fl l
|
|
.Sh DESCRIPTION
|
|
The
|
|
.Nm
|
|
program is used to divide space on a disk into partitions and set
|
|
one active.
|
|
There can be at most 4 partitions defined in sector 0,
|
|
one of which can be an extended
|
|
partition which can be split into any number of sub-partitions.
|
|
.Pp
|
|
.Nx
|
|
does not use the partitioning done by
|
|
.Nm ,
|
|
instead it uses a
|
|
.Nx
|
|
disklabel saved in sector 1 of the
|
|
.Nx
|
|
partition.
|
|
.Pp
|
|
The standard MBR boot code will only boot the 'active' partition.
|
|
However
|
|
.Nx
|
|
contains two alternate boot programs which allow the user to
|
|
interactively select which of the partitions to boot.
|
|
The 'mbr_ext' code will boot
|
|
.Nx
|
|
from an extended partition but will not work on old systems that do not
|
|
support LBA reads.
|
|
.Pp
|
|
At the start the
|
|
.Nm
|
|
program will determine whether the disk sector 0 is valid as a boot sector.
|
|
(This is determined by checking the magic number.)
|
|
If not,
|
|
.Nm
|
|
will initialise the boot code as well as the partition table.
|
|
During this, all four partitions will be marked empty.
|
|
.Pp
|
|
The flags
|
|
.Fl a ,
|
|
.Fl i
|
|
or
|
|
.Fl u
|
|
are used to indicate that the partition data is to be updated.
|
|
The
|
|
.Nm
|
|
program will enter an interactive conversational mode.
|
|
This mode is designed not to change any data unless you explicitly tell it to;
|
|
.Nm
|
|
selects defaults for its questions to guarantee that behaviour.
|
|
.Pp
|
|
.Nm
|
|
will calculate the correct
|
|
.Em cylinder ,
|
|
.Em head ,
|
|
and
|
|
.Em sector
|
|
values for any partition you edit.
|
|
If you specify
|
|
.Fl v
|
|
you will be asked whether you want to specify them yourself.
|
|
.Pp
|
|
Finally, when all the data for the first sector has been accumulated,
|
|
.Nm
|
|
will ask if you really want to write the new partition table.
|
|
Only if you reply affirmatively to this question will
|
|
.Nm
|
|
write anything to the disk.
|
|
.Pp
|
|
Available options:
|
|
.Pp
|
|
.Bl -tag -width Ds
|
|
.It Fl 0
|
|
Update partition slot 0.
|
|
.It Fl 1
|
|
Update partition slot 1.
|
|
.It Fl 2
|
|
Update partition slot 2.
|
|
.It Fl 3
|
|
Update partition slot 3.
|
|
.It Fl a
|
|
Change the active partition.
|
|
In interactive mode this question will be asked after the partitions
|
|
have been processed.
|
|
.It Fl b Ar cylinders/heads/sectors
|
|
Specify the BIOS parameters for
|
|
.Ar cylinders ,
|
|
.Ar heads ,
|
|
and
|
|
.Ar sectors .
|
|
It is used only in conjunction with the
|
|
.Fl u
|
|
flag.
|
|
.It Fl B
|
|
On an i386 or amd64 system, interactively update the boot selector settings.
|
|
(The boot selector permits the user to interactively select the boot
|
|
partition, and thus which operating system is run, at system boot time.
|
|
See
|
|
.Xr mbr 8
|
|
for more information.)
|
|
.It Fl c Ar bootcode
|
|
Specify the filename that
|
|
.Nm
|
|
should read the bootcode from.
|
|
If the name of a directory is specified, then
|
|
.Nm
|
|
will look for files with the default names in that directory.
|
|
The default is to read from
|
|
.Pa /usr/mdec/mbr ,
|
|
.Pa /usr/mdec/mbr_bootsel
|
|
or
|
|
.Pa /usr/mdec/mbr_ext
|
|
depending on whether
|
|
.Ar bootmenu
|
|
was specified for any partitions
|
|
on an i386 machine, and leave the bootcode empty for other
|
|
machines.
|
|
.It Fl E Ar number
|
|
Update extended partition
|
|
.Ar number .
|
|
If the specified extended partition doesn't exist an additional extended
|
|
partition will be created.
|
|
.It Fl f
|
|
Run
|
|
.Nm
|
|
in a non-interactive mode.
|
|
In this mode, you can only change the disk parameters by using the
|
|
.Fl b
|
|
flag.
|
|
This is provided only so scripts or other programs may use
|
|
.Nm
|
|
as part of an automatic installation process.
|
|
Using the
|
|
.Fl f
|
|
flag with
|
|
.Fl u
|
|
makes it impossible to specify the starting and ending
|
|
.Ar cylinder ,
|
|
.Ar head ,
|
|
and
|
|
.Ar sector
|
|
fields.
|
|
They will be automatically computed using the BIOS geometry.
|
|
.br
|
|
If
|
|
.Fl u
|
|
and
|
|
.Fl s
|
|
are specified then the details of the specified partition will be changed.
|
|
Any other partitions which overlap the requested part of the disk will be
|
|
silently deleted.
|
|
.It Fl i
|
|
Explicitly request initialisation of the master boot code
|
|
(similar to what
|
|
.Nm fdisk /mbr
|
|
does under
|
|
.Tn MSDOS ) ,
|
|
even if the magic number in the first sector is ok.
|
|
The partition table is left alone by this (but see above).
|
|
.It Fl l
|
|
Lists known
|
|
.Em sysid
|
|
values and exit.
|
|
.It Fl r Ar file
|
|
Read the boot record from file
|
|
.Ar file
|
|
instead of the specified disk.
|
|
The geometry information used is still that of the disk volume.
|
|
Any changes are written back to the file.
|
|
.It Fl s Ar id/start/size Ns Bq Ar /bootmenu
|
|
Specify the partition
|
|
.Ar id ,
|
|
.Ar start ,
|
|
.Ar size ,
|
|
and optionally
|
|
.Ar bootmenu .
|
|
This flag requires the use of a partition selection flag
|
|
.Po
|
|
.Fl 0 ,
|
|
.Fl 1 ,
|
|
.Fl 2 ,
|
|
.Fl 3 ,
|
|
or
|
|
.Fl E Ar number
|
|
.Pc
|
|
.It Fl S
|
|
When used with no other flags print a series of
|
|
.Pa /bin/sh
|
|
commands for setting variables to the partition information.
|
|
This could be used by installation scripts.
|
|
.It Fl u
|
|
Display the partitions and interactively ask which one you want to edit.
|
|
.Nm
|
|
will step through each field showing the old value and asking for a new one.
|
|
The
|
|
.Em start
|
|
and
|
|
.Em size
|
|
can be specified in blocks (nn), cylinders (nnc) or megabytes (nnm), values
|
|
in megabytes will be rounded to the nearest cylinder boundary.
|
|
The
|
|
.Em size
|
|
may be specified as
|
|
.Em $
|
|
in which case the partition will extend to the end of the available free space.
|
|
.br
|
|
.Nm
|
|
will not allow you to create partitions which overlap.
|
|
.Pp
|
|
If
|
|
.Em bootmenu
|
|
is specified for any partition
|
|
.Nm
|
|
will determine whether the installed boot code supports the bootselect code,
|
|
if it doesn't you will be asked whether you want to install the required
|
|
boot code.
|
|
.It Fl v
|
|
Be more verbose, specifying
|
|
.Fl v
|
|
more than once may increase the amount of output.
|
|
.br
|
|
Specifying
|
|
.Fl v
|
|
with
|
|
.Fl u
|
|
allows the user to explicitly specify some values for with the default
|
|
ies usually correct.
|
|
.It Fl w Ar file
|
|
Write the modified partition table to file
|
|
.Ar file
|
|
instead of the disk.
|
|
.El
|
|
.Pp
|
|
When called with no arguments, it prints the partition table.
|
|
An example follows:
|
|
.Bd -literal
|
|
Disk: /dev/rwd0d
|
|
NetBSD disklabel disk geometry:
|
|
cylinders: 16383, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
|
|
total sectors: 40032696
|
|
|
|
BIOS disk geometry:
|
|
cylinders: 1023, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
|
|
total sectors: 40032696
|
|
|
|
Partition table:
|
|
0: NetBSD (sysid 169)
|
|
bootmenu: net 1.5.
|
|
start 4209030, size 8289540 (4048 MB, Cyls 262-778), Active
|
|
1: Primary DOS with 32 bit FAT (sysid 11)
|
|
bootmenu: win98
|
|
start 63, size 4208967 (2055 MB, Cyls 0-262)
|
|
2: NetBSD (sysid 169)
|
|
bootmenu: current
|
|
start 32515560, size 7517136 (3670 MB, Cyls 2024-2491/234/40)
|
|
3: Ext. partition - LBA (sysid 15)
|
|
start 12498570, size 20016990 (9774 MB, Cyls 778-2024)
|
|
Extended partition table:
|
|
E0: NetBSD (sysid 169)
|
|
bootmenu: test
|
|
start 12498633, size 12305727 (6009 MB, Cyls 778-1544)
|
|
E1: Primary DOS with 32 bit FAT (sysid 11)
|
|
start 24804423, size 4096512 (2000 MB, Cyls 1544-1799)
|
|
E2: Primary DOS with 32 bit FAT (sysid 11)
|
|
start 28900998, size 3614562 (1765 MB, Cyls 1799-2024)
|
|
Bootselector enabled, infinite timeout.
|
|
.Ed
|
|
.Pp
|
|
This example disk is divided into four partitions the last of which is
|
|
an extended partition.
|
|
The sub-partitions of the extended partition are also shown.
|
|
In this case there is no free space in either the disk or in the extended
|
|
partition.
|
|
.Pp
|
|
The various fields in each partition entry are:
|
|
.br
|
|
.in +4
|
|
.Em ptn_number : id_name
|
|
(sysid
|
|
.Em id_number )
|
|
.br
|
|
.in +4
|
|
bootmenu:
|
|
.Em bootmenu
|
|
.br
|
|
start
|
|
.Em start ,
|
|
size
|
|
.Em size ( MB
|
|
MB, Cyls
|
|
.Em first Ns No - Ns Em next )
|
|
.Op , Active
|
|
.in -4
|
|
.in -4
|
|
.Bl -tag -width "bootmenu"
|
|
.It Em ptn_number
|
|
is the number of the partition.
|
|
.It Em id_name
|
|
is the name of the filesystem type or operating system that uses this partition.
|
|
.It Em id_number
|
|
is the number that identifies the partition type.
|
|
169 decimal is used for
|
|
.Nx
|
|
partitions,
|
|
15 decimal to create an extended partition
|
|
and 0 to mark a partition as unused.
|
|
Use
|
|
.Nm
|
|
.Fl l
|
|
to list the known partition types.
|
|
.It Em bootmenu
|
|
is the menu prompt output by the interactive boot code for this partition.
|
|
This line is omitted if the prompt is not defined.
|
|
.It Xo
|
|
.Em start ,
|
|
.Em size
|
|
.Xc
|
|
are the start address and size of the partition in sectors.
|
|
.It Em MB
|
|
is the size of the partition in megabytes.
|
|
.It Xo
|
|
.Em first ,
|
|
.Em next
|
|
.Xc
|
|
are the bounds of this partition displayed as cylinder/head/sector.
|
|
If the partition starts (or ends) on a cylinder boundary the head and
|
|
sector values are omitted.
|
|
If
|
|
.Fl v
|
|
is not specified the start of extended partitions and the first partition
|
|
on the disk are rounded down to include the mandatory red tape in the
|
|
preceeding track.
|
|
.It Active
|
|
is output if this is the active partition.
|
|
.El
|
|
.Pp
|
|
If the
|
|
.Fl v
|
|
flag is given two additional lines are output for each partition:
|
|
.in +4
|
|
beg: cylinder
|
|
.Em cylinder ,
|
|
head
|
|
.Em head ,
|
|
sector
|
|
.Em sector
|
|
.br
|
|
end: cylinder
|
|
.Em cylinder ,
|
|
head
|
|
.Em head ,
|
|
sector
|
|
.Em sector
|
|
.in -4
|
|
.Bl -tag -width "bootmenu"
|
|
.It Xo
|
|
.Em "cylinder" ,
|
|
.Em "head" ,
|
|
.Em "sector"
|
|
.Xc
|
|
are the beginning or ending address of a partition.
|
|
.br
|
|
.Em "Note:"
|
|
these numbers are read from the bootblock, so are the values calculated
|
|
by a previous run of
|
|
.Nm .
|
|
.El
|
|
.Sh NOTES
|
|
Traditionally the partition boundaries should be on cylinder boundaries
|
|
using the BIOS geometry, all of the first track should be reserved
|
|
for use by the BIOS.
|
|
Although the BIOS geometry is typically different from the geometry
|
|
reported by the drive, neither will match the actual physical geometry
|
|
for modern disks (the actual geometry will vary across the disk).
|
|
Keeping the partition boundaries on cylinder boundaries makes partitioning
|
|
a driver easier as only relatively small numbers need be entered.
|
|
.Pp
|
|
The automatic calculation of the starting cylinder and
|
|
other parameters uses
|
|
a set of figures that represent what the BIOS thinks is the
|
|
geometry of the drive.
|
|
The default values should be correct for the system on which
|
|
.Nm
|
|
is run, however if you move the disk to a different system the
|
|
BIOS of that system might use a different geometry translation.
|
|
.Pp
|
|
If you run the equivalent of
|
|
.Nm
|
|
on a different operating system then the
|
|
.Ar bootmenu
|
|
strings associated with extended partitions may be lost.
|
|
.Pp
|
|
Editing an existing partition is risky, and may cause you to
|
|
lose all the data in that partition.
|
|
.Pp
|
|
You should run this program interactively once or twice to see how it works.
|
|
This is completely safe as long as you answer the last question in the negative.
|
|
You can also specify
|
|
.Fl w Ar file
|
|
to write the output to a file and later specify
|
|
.Fl r Ar file
|
|
to read back the updated information.
|
|
This can be done without having write access to the disk volume.
|
|
.Sh FILES
|
|
.Bl -tag -width /usr/mdec/mbrxxxxxxxx -compact
|
|
.It Pa /usr/mdec/mbr
|
|
Default location of i386 bootcode
|
|
.It Pa /usr/mdec/mbr_bootsel
|
|
Default location of i386 bootselect code
|
|
.It Pa /usr/mdec/mbr_ext
|
|
Default location of i386 bootselect for extended partitions
|
|
.El
|
|
.Sh SEE ALSO
|
|
.Xr disklabel 8 ,
|
|
.Xr mbr 8 ,
|
|
.Xr mbrlabel 8
|
|
.Sh BUGS
|
|
The word 'partition' is used to mean both an MBR partition and a
|
|
.Nx
|
|
partition, sometimes in the same sentence.
|
|
.Pp
|
|
There are subtleties that the program detects that are not explained in
|
|
this manual page.
|