2010-04-07 13:40:58 +04:00
|
|
|
.\" $NetBSD: fdisk.8,v 1.70 2010/04/07 09:40:58 wiz Exp $
|
1995-03-18 17:54:19 +03:00
|
|
|
.\"
|
2010-04-07 13:40:58 +04:00
|
|
|
.Dd April 6, 2010
|
1993-04-09 23:23:56 +04:00
|
|
|
.Dt FDISK 8
|
2001-06-05 15:22:41 +04:00
|
|
|
.Os
|
1993-04-09 23:23:56 +04:00
|
|
|
.Sh NAME
|
|
|
|
.Nm fdisk
|
2003-10-06 16:02:52 +04:00
|
|
|
.Nd MS-DOS partition maintenance program
|
1993-04-09 23:23:56 +04:00
|
|
|
.Sh SYNOPSIS
|
2003-02-25 13:34:36 +03:00
|
|
|
.Nm
|
2010-04-07 13:40:58 +04:00
|
|
|
.Op Fl aBFfiSuv
|
1999-03-07 14:02:05 +03:00
|
|
|
.Bk -words
|
2010-04-07 13:40:58 +04:00
|
|
|
.Oo
|
|
|
|
.Fl 0 | 1 | 2 | 3 | E Ar number
|
|
|
|
.Op Fl s Ar id/start/size Ns Bq Ar /bootmenu
|
|
|
|
.Oc
|
2004-03-19 21:19:17 +03:00
|
|
|
.Ek
|
|
|
|
.Bk -words
|
2010-04-07 13:40:58 +04:00
|
|
|
.Op Fl r Ar file | Fl w Ar file
|
2004-03-19 21:19:17 +03:00
|
|
|
.Ek
|
|
|
|
.Bk -words
|
2009-12-23 23:56:18 +03:00
|
|
|
.Op Fl A Ar ptn_alignment Ns Bq Ar /ptn_0_offset
|
2003-04-30 23:47:10 +04:00
|
|
|
.Ek
|
|
|
|
.Bk -words
|
1997-09-06 01:26:57 +04:00
|
|
|
.Op Fl b Ar cylinders/heads/sectors
|
1999-03-07 14:02:05 +03:00
|
|
|
.Ek
|
|
|
|
.Bk -words
|
2010-04-07 13:40:58 +04:00
|
|
|
.Op Fl c Ar bootcode
|
1999-03-07 14:02:05 +03:00
|
|
|
.Ek
|
|
|
|
.Bk -words
|
2010-04-07 13:40:58 +04:00
|
|
|
.Op Fl T Ar disktype
|
1999-03-07 14:02:05 +03:00
|
|
|
.Ek
|
|
|
|
.Bk -words
|
2010-04-07 13:40:58 +04:00
|
|
|
.Op Fl t Ar disktab
|
2003-04-30 23:47:10 +04:00
|
|
|
.Ek
|
|
|
|
.Bk -words
|
1994-09-23 08:30:13 +04:00
|
|
|
.Op Ar device
|
1999-03-07 14:02:05 +03:00
|
|
|
.Ek
|
2003-04-30 23:47:10 +04:00
|
|
|
.Nm
|
|
|
|
.Fl l
|
2000-12-19 02:42:40 +03:00
|
|
|
.Sh DESCRIPTION
|
2003-04-30 23:47:10 +04:00
|
|
|
The
|
1993-04-09 23:23:56 +04:00
|
|
|
.Nm
|
2007-03-10 17:19:46 +03:00
|
|
|
program is used to display or update the
|
|
|
|
.Em "master boot record"
|
|
|
|
or
|
|
|
|
.Em MBR
|
|
|
|
in the first sector (sector 0)
|
|
|
|
of a disk that uses the MBR style of partitioning.
|
|
|
|
The following
|
|
|
|
.Nx
|
|
|
|
ports use this style of disk partitioning:
|
|
|
|
amd64, arc, bebox, cobalt, hpcarm, hpcmips, hpcsh, i386, macppc,
|
2009-12-05 19:29:10 +03:00
|
|
|
mvmeppc, netwinder, ofppc, and prep.
|
2007-03-10 17:19:46 +03:00
|
|
|
.Pp
|
|
|
|
The MBR contains bootable code, a partition table,
|
|
|
|
an indication of which partition is
|
|
|
|
.Sq active ,
|
|
|
|
and (optionally, depending on the boot code) a menu
|
|
|
|
for selecting a partition to be booted.
|
2003-04-30 23:47:10 +04:00
|
|
|
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.
|
1994-09-23 08:30:13 +04:00
|
|
|
.Pp
|
2007-03-10 17:19:46 +03:00
|
|
|
The boot code in the MBR is usually invoked by the BIOS or firmware,
|
|
|
|
and the MBR passes control to the next stage boot code
|
|
|
|
stored in the first sector of the partition to be booted
|
|
|
|
(the
|
|
|
|
.Em "partition boot record"
|
|
|
|
or
|
|
|
|
.Em PBR ) .
|
|
|
|
.Pp
|
|
|
|
After booting,
|
1998-02-06 08:54:12 +03:00
|
|
|
.Nx
|
2003-04-30 23:47:10 +04:00
|
|
|
does not use the partitioning done by
|
|
|
|
.Nm ,
|
|
|
|
instead it uses a
|
1998-02-06 08:54:12 +03:00
|
|
|
.Nx
|
2003-04-30 23:47:10 +04:00
|
|
|
disklabel saved in sector 1 of the
|
|
|
|
.Nx
|
|
|
|
partition.
|
2007-03-10 17:19:46 +03:00
|
|
|
See
|
|
|
|
.Xr mbrlabel 8
|
|
|
|
for a way of using information from the MBR
|
|
|
|
to construct a
|
|
|
|
.Nx
|
|
|
|
disklabel.
|
1997-09-14 18:05:34 +04:00
|
|
|
.Pp
|
2004-03-20 01:21:36 +03:00
|
|
|
The standard MBR boot code will only boot the
|
|
|
|
.Sq active
|
|
|
|
partition.
|
2010-04-07 13:40:58 +04:00
|
|
|
However,
|
2003-04-30 23:47:10 +04:00
|
|
|
.Nx
|
2008-01-20 18:04:09 +03:00
|
|
|
contains additional boot programs which allow the user to
|
2003-04-30 23:47:10 +04:00
|
|
|
interactively select which of the partitions to boot.
|
2004-03-20 01:21:36 +03:00
|
|
|
The
|
|
|
|
.Sq mbr_ext
|
2008-01-20 18:04:09 +03:00
|
|
|
code will also boot
|
2003-04-30 23:47:10 +04:00
|
|
|
.Nx
|
|
|
|
from an extended partition but will not work on old systems that do not
|
2008-01-20 18:04:09 +03:00
|
|
|
support LBA reads, the
|
|
|
|
.Sq mbr_com0
|
|
|
|
and
|
|
|
|
.Sq mbr_com0_9600
|
|
|
|
will read and write from a serial port.
|
1998-09-28 19:44:18 +04:00
|
|
|
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
|
2003-04-30 23:47:10 +04:00
|
|
|
will initialise the boot code as well as the partition table.
|
1998-09-28 19:44:18 +04:00
|
|
|
During this, all four partitions will be marked empty.
|
|
|
|
.Pp
|
2000-12-19 02:42:40 +03:00
|
|
|
The flags
|
|
|
|
.Fl a ,
|
2001-11-16 13:25:42 +03:00
|
|
|
.Fl i
|
2000-12-19 02:42:40 +03:00
|
|
|
or
|
1997-08-12 03:31:41 +04:00
|
|
|
.Fl u
|
2000-12-19 02:42:40 +03:00
|
|
|
are used to indicate that the partition data is to be updated.
|
|
|
|
The
|
1993-04-09 23:23:56 +04:00
|
|
|
.Nm
|
2000-12-19 02:42:40 +03:00
|
|
|
program will enter an interactive conversational mode.
|
|
|
|
This mode is designed not to change any data unless you explicitly tell it to;
|
1993-04-09 23:23:56 +04:00
|
|
|
.Nm
|
2003-04-30 23:47:10 +04:00
|
|
|
selects defaults for its questions to guarantee that behaviour.
|
2000-12-19 02:42:40 +03:00
|
|
|
.Pp
|
2009-07-02 04:49:58 +04:00
|
|
|
If partition data is going to be updated and the disk carries GUID Partition
|
|
|
|
Tables,
|
2009-06-01 23:57:33 +04:00
|
|
|
.Nm
|
|
|
|
will remove both primary and backup GPT headers from the disk.
|
|
|
|
See
|
|
|
|
.Xr gpt 8
|
|
|
|
for information on how to manipulate GUID Partition Tables.
|
|
|
|
.Pp
|
2003-04-30 23:47:10 +04:00
|
|
|
.Nm
|
|
|
|
will calculate the correct
|
1997-09-14 18:05:34 +04:00
|
|
|
.Em cylinder ,
|
|
|
|
.Em head ,
|
1993-04-09 23:23:56 +04:00
|
|
|
and
|
1997-09-14 18:05:34 +04:00
|
|
|
.Em sector
|
2003-05-01 16:55:52 +04:00
|
|
|
values for any partition you edit.
|
|
|
|
If you specify
|
2003-04-30 23:47:10 +04:00
|
|
|
.Fl v
|
|
|
|
you will be asked whether you want to specify them yourself.
|
1993-04-09 23:23:56 +04:00
|
|
|
.Pp
|
2003-04-30 23:47:10 +04:00
|
|
|
Finally, when all the data for the first sector has been accumulated,
|
1994-09-23 08:30:13 +04:00
|
|
|
.Nm
|
2003-04-30 23:47:10 +04:00
|
|
|
will ask if you really want to write the new partition table.
|
1994-09-23 08:30:13 +04:00
|
|
|
Only if you reply affirmatively to this question will
|
|
|
|
.Nm
|
|
|
|
write anything to the disk.
|
1993-04-09 23:23:56 +04:00
|
|
|
.Pp
|
2000-12-19 02:42:40 +03:00
|
|
|
Available options:
|
1999-04-17 05:38:00 +04:00
|
|
|
.Pp
|
2000-12-19 02:42:40 +03:00
|
|
|
.Bl -tag -width Ds
|
|
|
|
.It Fl 0
|
2009-11-28 19:45:20 +03:00
|
|
|
Specify partition slot 0 to be printed or updated.
|
2000-12-19 02:42:40 +03:00
|
|
|
.It Fl 1
|
2009-11-28 19:45:20 +03:00
|
|
|
Specify partition slot 1 to be printed or updated.
|
2000-12-19 02:42:40 +03:00
|
|
|
.It Fl 2
|
2009-11-28 19:45:20 +03:00
|
|
|
Specify partition slot 2 to be printed or updated.
|
2000-12-19 02:42:40 +03:00
|
|
|
.It Fl 3
|
2009-11-28 19:45:20 +03:00
|
|
|
Specify partition slot 3 to be printed or updated.
|
2009-12-23 23:56:18 +03:00
|
|
|
.It Fl A Ar ptn_alignment Ns Bq Ar /ptn_0_offset
|
|
|
|
Specify the alignment for all partitions and optionally the offset for the
|
|
|
|
first partition of the disk and of extended partitions.
|
|
|
|
If
|
|
|
|
.Ar ptn_alignment
|
|
|
|
is specified and
|
|
|
|
.Ar ptn_0_offset
|
|
|
|
is not specified, then the offset is set to the alignment.
|
|
|
|
If
|
|
|
|
.Fl A
|
|
|
|
isn't specified, then the alignment of the first partition is inspected.
|
|
|
|
If it ends on a 2048 sector boundary, then the alignment is set to 2048,
|
|
|
|
if the start is a power of 2 less than, or equal to 2048 then the offset
|
|
|
|
is set to the start sector.
|
|
|
|
If the first partition isn't defined then the alignment and offset for disks
|
|
|
|
larger than 128GB is set to 2048 (1MB).
|
|
|
|
In all other cases the alignment default to a cylinder
|
|
|
|
and the offset to a track (both using the BIOS geometry).
|
|
|
|
The 1MB alignment is the same as that used by recent windows versions.
|
2010-04-07 13:40:58 +04:00
|
|
|
.It Fl a
|
|
|
|
Change the active partition.
|
|
|
|
In interactive mode this question will be asked after the partitions
|
|
|
|
have been processed.
|
|
|
|
.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.)
|
2000-12-19 02:42:40 +03:00
|
|
|
.It Fl b Ar cylinders/heads/sectors
|
2009-12-23 23:56:18 +03:00
|
|
|
Specify the BIOS geometry parameters for
|
2000-12-19 02:42:40 +03:00
|
|
|
.Ar cylinders ,
|
2003-05-01 16:55:52 +04:00
|
|
|
.Ar heads ,
|
1997-09-06 01:26:57 +04:00
|
|
|
and
|
2000-12-19 02:42:40 +03:00
|
|
|
.Ar sectors .
|
|
|
|
It is used only in conjunction with the
|
1997-09-06 01:26:57 +04:00
|
|
|
.Fl u
|
1998-09-28 19:44:18 +04:00
|
|
|
flag.
|
2009-12-23 23:56:18 +03:00
|
|
|
If not specified the BIOS geometry will be obtained using sysctl (i386 and
|
|
|
|
amd64) or by solving the simultaenous equations from the existing partition
|
|
|
|
information.
|
|
|
|
If that fails then either the geometry from the disklabel or 63 sectors and
|
|
|
|
16 heads is used.
|
2000-12-19 02:42:40 +03:00
|
|
|
.It Fl c Ar bootcode
|
|
|
|
Specify the filename that
|
1997-08-12 03:31:41 +04:00
|
|
|
.Nm
|
2000-12-19 02:42:40 +03:00
|
|
|
should read the bootcode from.
|
2003-04-30 23:47:10 +04:00
|
|
|
If the name of a directory is specified, then
|
|
|
|
.Nm
|
|
|
|
will look for files with the default names in that directory.
|
2000-12-19 02:42:40 +03:00
|
|
|
The default is to read from
|
2003-04-30 23:47:10 +04:00
|
|
|
.Pa /usr/mdec/mbr ,
|
|
|
|
.Pa /usr/mdec/mbr_bootsel
|
|
|
|
or
|
|
|
|
.Pa /usr/mdec/mbr_ext
|
|
|
|
depending on whether
|
2003-05-01 17:36:25 +04:00
|
|
|
.Ar bootmenu
|
2003-04-30 23:47:10 +04:00
|
|
|
was specified for any partitions
|
|
|
|
on an i386 machine, and leave the bootcode empty for other
|
2000-12-19 02:42:40 +03:00
|
|
|
machines.
|
2003-04-30 23:47:10 +04:00
|
|
|
.It Fl E Ar number
|
2009-11-28 19:45:20 +03:00
|
|
|
Specify extended partition
|
|
|
|
.Ar number
|
|
|
|
to be printed or updated.
|
|
|
|
If the specified extended partition doesn't exist on updating partition data
|
|
|
|
an additional extended partition will be created.
|
2010-04-07 13:40:58 +04:00
|
|
|
.It Fl F
|
|
|
|
Indicate that
|
|
|
|
.Ar device
|
|
|
|
is a regular file.
|
|
|
|
Unless the geometry of
|
|
|
|
.Ar device
|
|
|
|
is told to
|
|
|
|
.Nm
|
|
|
|
by
|
|
|
|
.Fl T Ar disktype ,
|
|
|
|
.Nm
|
|
|
|
will count the 512-byte sectors in
|
|
|
|
.Ar device
|
|
|
|
and produce a fake geometry.
|
|
|
|
If
|
|
|
|
.Ar device
|
|
|
|
is a regular file,
|
|
|
|
.Fl F
|
|
|
|
will be used implicitly.
|
2000-12-19 02:42:40 +03:00
|
|
|
.It Fl f
|
|
|
|
Run
|
|
|
|
.Nm
|
|
|
|
in a non-interactive mode.
|
2001-11-16 13:25:42 +03:00
|
|
|
In this mode, you can only change the disk parameters by using the
|
1997-09-06 01:26:57 +04:00
|
|
|
.Fl b
|
2000-12-19 02:42:40 +03:00
|
|
|
flag.
|
|
|
|
This is provided only so scripts or other programs may use
|
|
|
|
.Nm
|
|
|
|
as part of an automatic installation process.
|
2004-03-22 08:07:56 +03:00
|
|
|
.Pp
|
2000-12-19 02:42:40 +03:00
|
|
|
Using the
|
1997-08-12 03:31:41 +04:00
|
|
|
.Fl f
|
1997-11-26 07:26:27 +03:00
|
|
|
flag with
|
1997-08-12 03:31:41 +04:00
|
|
|
.Fl u
|
1997-09-06 01:26:57 +04:00
|
|
|
makes it impossible to specify the starting and ending
|
2000-12-19 02:42:40 +03:00
|
|
|
.Ar cylinder ,
|
2003-05-01 16:55:52 +04:00
|
|
|
.Ar head ,
|
2001-11-16 13:25:42 +03:00
|
|
|
and
|
2000-12-19 02:42:40 +03:00
|
|
|
.Ar sector
|
2009-11-28 19:45:20 +03:00
|
|
|
fields
|
|
|
|
.Pq only Ar start No and Ar size No can be specified by Fl s No option .
|
2000-12-19 02:42:40 +03:00
|
|
|
They will be automatically computed using the BIOS geometry.
|
|
|
|
.It Fl i
|
2003-04-30 23:47:10 +04:00
|
|
|
Explicitly request initialisation of the master boot code
|
2000-12-19 02:42:40 +03:00
|
|
|
(similar to what
|
2004-03-20 21:49:33 +03:00
|
|
|
.Ic fdisk /mbr
|
2000-12-19 02:42:40 +03:00
|
|
|
does under
|
2003-10-06 16:02:52 +04:00
|
|
|
.Tn MS-DOS ) ,
|
2001-11-16 13:25:42 +03:00
|
|
|
even if the magic number in the first sector is ok.
|
2000-12-19 02:42:40 +03:00
|
|
|
The partition table is left alone by this (but see above).
|
2002-03-27 02:56:05 +03:00
|
|
|
.It Fl l
|
|
|
|
Lists known
|
|
|
|
.Em sysid
|
|
|
|
values and exit.
|
2003-04-30 23:47:10 +04:00
|
|
|
.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.
|
2010-04-07 13:40:58 +04:00
|
|
|
.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.
|
2003-05-01 16:55:52 +04:00
|
|
|
.It Fl s Ar id/start/size Ns Bq Ar /bootmenu
|
2000-12-19 02:42:40 +03:00
|
|
|
Specify the partition
|
|
|
|
.Ar id ,
|
2003-04-30 23:47:10 +04:00
|
|
|
.Ar start ,
|
2003-05-01 16:55:52 +04:00
|
|
|
.Ar size ,
|
2003-04-30 23:47:10 +04:00
|
|
|
and optionally
|
|
|
|
.Ar bootmenu .
|
2000-12-19 02:42:40 +03:00
|
|
|
This flag requires the use of a partition selection flag
|
2009-11-28 19:45:20 +03:00
|
|
|
.Pq Fl 0 , 1 , 2 , 3 , No or Fl E Ar number .
|
2010-04-07 13:40:58 +04:00
|
|
|
.It Fl T Ar disktype
|
|
|
|
Use the disklabel
|
|
|
|
.Ar disktype
|
|
|
|
instead of the disklabel on
|
|
|
|
.Ar device .
|
2004-03-19 21:19:17 +03:00
|
|
|
.It Fl t Ar disktab
|
2004-03-20 01:21:36 +03:00
|
|
|
Read
|
2004-03-19 21:19:17 +03:00
|
|
|
.Ar disktype
|
2004-03-20 01:21:36 +03:00
|
|
|
from the named
|
|
|
|
.Xr disktab 5
|
2004-03-19 21:19:17 +03:00
|
|
|
file instead of from
|
2004-03-20 01:21:36 +03:00
|
|
|
.Pa /etc/disktab .
|
2000-12-19 02:42:40 +03:00
|
|
|
.It Fl u
|
2009-11-28 19:45:20 +03:00
|
|
|
Update partition data, including
|
|
|
|
.Em id , start , No and Em size .
|
|
|
|
Unless
|
|
|
|
.Fl f
|
|
|
|
option
|
|
|
|
.Pq non-interactive mode
|
|
|
|
is specified,
|
|
|
|
.Nm
|
|
|
|
will display the partitions and interactively ask which one you want to edit.
|
2003-04-30 23:47:10 +04:00
|
|
|
.Nm
|
|
|
|
will step through each field showing the old value and asking for a new one.
|
|
|
|
The
|
|
|
|
.Em start
|
2003-05-01 13:50:12 +04:00
|
|
|
and
|
2003-04-30 23:47:10 +04:00
|
|
|
.Em size
|
2009-11-28 20:25:45 +03:00
|
|
|
can be specified in blocks (NN),
|
|
|
|
cylinders (NNc or NNcyl),
|
|
|
|
megabytes (NNm or NNMB),
|
|
|
|
or gigabytes (NNg or NNGB), values in megabytes and gigabytes
|
2005-04-08 00:23:13 +04:00
|
|
|
will be rounded to the nearest cylinder boundary.
|
2003-04-30 23:47:10 +04:00
|
|
|
The
|
|
|
|
.Em size
|
|
|
|
may be specified as
|
|
|
|
.Em $
|
|
|
|
in which case the partition will extend to the end of the available free space.
|
2004-03-22 08:07:56 +03:00
|
|
|
.Pp
|
2009-11-28 19:45:20 +03:00
|
|
|
In a non-interactive mode
|
|
|
|
.Pq specified by Fl f No option ,
|
|
|
|
partition data should be specified by
|
|
|
|
.Fl s
|
|
|
|
option.
|
|
|
|
A partition selection option
|
|
|
|
.Pq Fl 0 , 1 , 2 , 3 , No or Fl E Ar number
|
|
|
|
should also be specified to select a partition slot to be updated.
|
|
|
|
.Pp
|
2003-04-30 23:47:10 +04:00
|
|
|
.Nm
|
|
|
|
will not allow you to create partitions which overlap.
|
2009-11-28 19:45:20 +03:00
|
|
|
If
|
|
|
|
.Fl u
|
|
|
|
and
|
|
|
|
.Fl s
|
|
|
|
are specified in a non-interactive mode
|
|
|
|
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.
|
2003-04-30 23:47:10 +04:00
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Em bootmenu
|
|
|
|
is specified for any partition
|
2000-12-19 02:42:40 +03:00
|
|
|
.Nm
|
2003-04-30 23:47:10 +04:00
|
|
|
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
|
2006-09-24 19:52:12 +04:00
|
|
|
boot code.
|
|
|
|
To remove a
|
2006-09-24 19:22:01 +04:00
|
|
|
.Em bootmenu
|
2006-09-24 19:52:12 +04:00
|
|
|
label, simply press
|
|
|
|
.Aq space
|
|
|
|
followed by
|
|
|
|
.Aq return .
|
2003-04-30 23:47:10 +04:00
|
|
|
.It Fl v
|
|
|
|
Be more verbose, specifying
|
|
|
|
.Fl v
|
|
|
|
more than once may increase the amount of output.
|
2004-03-22 08:07:56 +03:00
|
|
|
.Pp
|
|
|
|
Using
|
2003-04-30 23:47:10 +04:00
|
|
|
.Fl v
|
|
|
|
with
|
|
|
|
.Fl u
|
2004-03-22 08:07:56 +03:00
|
|
|
allows the user to change more parameters than normally permitted.
|
2003-04-30 23:47:10 +04:00
|
|
|
.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.
|
2007-12-23 11:58:34 +03:00
|
|
|
First active partition: 0
|
2003-04-30 23:47:10 +04:00
|
|
|
.Ed
|
|
|
|
.Pp
|
2010-04-07 13:40:58 +04:00
|
|
|
This example disk is divided into four partitions, the last of which is
|
2003-04-30 23:47:10 +04:00
|
|
|
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
|
2003-05-01 17:01:17 +04:00
|
|
|
.Em size ( MB
|
2003-04-30 23:47:10 +04:00
|
|
|
MB, Cyls
|
2003-05-01 17:01:17 +04:00
|
|
|
.Em first Ns No - Ns Em next )
|
2003-04-30 23:47:10 +04:00
|
|
|
.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
|
2000-12-19 02:42:40 +03:00
|
|
|
.Nm
|
2003-04-30 23:47:10 +04:00
|
|
|
.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.
|
2009-10-15 02:00:55 +04:00
|
|
|
.It Em start , Em size
|
2003-04-30 23:47:10 +04:00
|
|
|
are the start address and size of the partition in sectors.
|
|
|
|
.It Em MB
|
|
|
|
is the size of the partition in megabytes.
|
2009-10-15 02:00:55 +04:00
|
|
|
.It Em first , Em next
|
2003-04-30 23:47:10 +04:00
|
|
|
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.
|
2003-05-01 13:50:12 +04:00
|
|
|
If
|
2003-04-30 23:47:10 +04:00
|
|
|
.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
|
2004-03-20 01:21:36 +03:00
|
|
|
preceding track.
|
2003-04-30 23:47:10 +04:00
|
|
|
.It Active
|
|
|
|
is output if this is the active partition.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
If the
|
|
|
|
.Fl v
|
2007-05-21 02:27:46 +04:00
|
|
|
flag is specified, the beginning and end of each partition are also
|
2007-03-10 17:19:46 +03:00
|
|
|
displayed as follows:
|
2003-04-30 23:47:10 +04:00
|
|
|
.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"
|
2009-10-15 02:00:55 +04:00
|
|
|
.It Em "cylinder" , Em "head" , Em "sector"
|
2003-04-30 23:47:10 +04:00
|
|
|
are the beginning or ending address of a partition.
|
2004-03-22 08:07:56 +03:00
|
|
|
.Pp
|
2003-04-30 23:47:10 +04:00
|
|
|
.Em "Note:"
|
|
|
|
these numbers are read from the bootblock, so are the values calculated
|
|
|
|
by a previous run of
|
|
|
|
.Nm .
|
2000-12-19 02:42:40 +03:00
|
|
|
.El
|
2007-03-10 17:19:46 +03:00
|
|
|
.Pp
|
|
|
|
.Nm
|
|
|
|
attempts to check whether each partition is bootable,
|
|
|
|
by checking the magic number and some other characteristics
|
|
|
|
of the first sector of each partition (the PBR).
|
2010-04-07 13:40:58 +04:00
|
|
|
If the partition does not appear to be bootable,
|
2007-03-10 17:19:46 +03:00
|
|
|
.Nm
|
|
|
|
will print a line containing
|
|
|
|
.Dq "PBR is not bootable"
|
|
|
|
followed by an error message.
|
|
|
|
If the partition is bootable, and if the
|
|
|
|
.Fl v
|
|
|
|
flag is specified,
|
|
|
|
.Nm
|
|
|
|
will print
|
|
|
|
.Dq "PBR appears to be bootable" .
|
|
|
|
If the
|
|
|
|
.Fl v
|
|
|
|
flag is specified more than once,
|
|
|
|
.Nm
|
|
|
|
will print the heading
|
|
|
|
.Dq "Information from PBR:"
|
|
|
|
followed by one or more lines of information gleaned from the PBR;
|
|
|
|
this additional information may be incorrect or misleading,
|
|
|
|
because different operating systems use different PBR formats.
|
|
|
|
Note that, even if no errors are reported, an attempt to boot
|
|
|
|
from the partition might fail.
|
|
|
|
.Nx
|
|
|
|
partitions may be made bootable using
|
|
|
|
.Xr installboot 8 .
|
1993-04-09 23:23:56 +04:00
|
|
|
.Sh NOTES
|
2004-07-13 14:45:49 +04:00
|
|
|
This program is only available (and useful) on systems with PC-platform-style
|
2004-07-13 17:38:39 +04:00
|
|
|
MBR partitioning.
|
2004-07-13 14:45:49 +04:00
|
|
|
.Pp
|
2003-04-30 23:47:10 +04:00
|
|
|
Traditionally the partition boundaries should be on cylinder boundaries
|
2007-12-23 13:47:42 +03:00
|
|
|
using the BIOS geometry, with the exception of the first partition,
|
|
|
|
which traditionally begins in the second track of the first cylinder
|
|
|
|
(cylinder 0, head 1, sector 1).
|
2003-04-30 23:47:10 +04:00
|
|
|
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
|
1997-11-26 07:26:27 +03:00
|
|
|
The automatic calculation of the starting cylinder and
|
|
|
|
other parameters uses
|
1993-04-09 23:23:56 +04:00
|
|
|
a set of figures that represent what the BIOS thinks is the
|
|
|
|
geometry of the drive.
|
2003-04-30 23:47:10 +04:00
|
|
|
The default values should be correct for the system on which
|
|
|
|
.Nm
|
2010-04-07 13:40:58 +04:00
|
|
|
is run; however, if you move the disk to a different system, the
|
2003-04-30 23:47:10 +04:00
|
|
|
BIOS of that system might use a different geometry translation.
|
|
|
|
.Pp
|
|
|
|
If you run the equivalent of
|
1994-09-23 08:30:13 +04:00
|
|
|
.Nm
|
2003-04-30 23:47:10 +04:00
|
|
|
on a different operating system then the
|
2003-05-01 17:36:25 +04:00
|
|
|
.Ar bootmenu
|
2003-04-30 23:47:10 +04:00
|
|
|
strings associated with extended partitions may be lost.
|
1993-04-09 23:23:56 +04:00
|
|
|
.Pp
|
1994-09-23 08:30:13 +04:00
|
|
|
Editing an existing partition is risky, and may cause you to
|
1993-04-09 23:23:56 +04:00
|
|
|
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.
|
2003-04-30 23:47:10 +04:00
|
|
|
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.
|
1998-10-15 19:23:23 +04:00
|
|
|
.Sh FILES
|
1999-04-17 05:38:00 +04:00
|
|
|
.Bl -tag -width /usr/mdec/mbrxxxxxxxx -compact
|
1998-10-15 19:23:23 +04:00
|
|
|
.It Pa /usr/mdec/mbr
|
|
|
|
Default location of i386 bootcode
|
1999-04-17 05:38:00 +04:00
|
|
|
.It Pa /usr/mdec/mbr_bootsel
|
|
|
|
Default location of i386 bootselect code
|
2003-04-30 23:47:10 +04:00
|
|
|
.It Pa /usr/mdec/mbr_ext
|
|
|
|
Default location of i386 bootselect for extended partitions
|
1998-10-15 19:23:23 +04:00
|
|
|
.El
|
2009-08-10 06:56:23 +04:00
|
|
|
.Sh EXAMPLES
|
2009-11-29 07:19:55 +03:00
|
|
|
Update MBR partition data of
|
|
|
|
.Pa /dev/rwd0d
|
|
|
|
in interactive mode:
|
|
|
|
.Pp
|
|
|
|
.Dl Ic fdisk -u /dev/rwd0d
|
|
|
|
.Pp
|
|
|
|
Change active MBR partition of
|
|
|
|
.Pa /dev/rwd0d
|
|
|
|
in interactive mode:
|
|
|
|
.Pp
|
|
|
|
.Dl Ic fdisk -a /dev/rwd0d
|
|
|
|
.Pp
|
|
|
|
Install MBR bootcode
|
|
|
|
.Pa /usr/mdec/mbr_bootsel
|
|
|
|
into
|
|
|
|
.Pa /dev/rwd0d :
|
|
|
|
.Pp
|
|
|
|
.Dl Ic fdisk -c /usr/mdec/mbr_bootsel /dev/rwd0d
|
|
|
|
.Pp
|
|
|
|
Set MBR partition data for slot 0 of
|
|
|
|
.Pa /dev/rwd0d
|
|
|
|
specifying values without prompt:
|
|
|
|
.Pp
|
|
|
|
.Dl Ic fdisk -f -u -0 -s 169/63/2097089 /dev/rwd0d
|
|
|
|
.Pp
|
|
|
|
Make partition slot 0 of
|
|
|
|
.Pa /dev/rwd0d
|
|
|
|
active without prompt:
|
|
|
|
.Pp
|
|
|
|
.Dl Ic fdisk -f -a -0 /dev/rwd0d
|
|
|
|
.Pp
|
|
|
|
Initialize and create MBR partition data using bootcode
|
|
|
|
.Pa destdir/usr/mdec/mbr
|
|
|
|
without prompt against 1GB disk image file
|
|
|
|
.Pa diskimg :
|
|
|
|
.Pp
|
|
|
|
.Dl Ic fdisk -f -i -b 130/255/63 -c destdir/usr/mdec/mbr -F diskimg
|
|
|
|
.Pp
|
|
|
|
Create MBR partition data for slot 0 which has an active NetBSD partition
|
|
|
|
using whole disk without prompt against 1GB disk image file
|
|
|
|
.Pa diskimg :
|
|
|
|
.Pp
|
|
|
|
.Dl Ic fdisk -f -a -u -0 -s 169/63/2097089 -F diskimg
|
1993-04-09 23:23:56 +04:00
|
|
|
.Sh SEE ALSO
|
2004-03-19 21:19:17 +03:00
|
|
|
.Xr disktab 5 ,
|
2007-03-10 17:19:46 +03:00
|
|
|
.Xr boot 8 ,
|
2004-03-20 01:21:36 +03:00
|
|
|
.Xr disklabel 8 ,
|
2009-06-01 23:57:33 +04:00
|
|
|
.Xr gpt 8 ,
|
2007-03-10 17:19:46 +03:00
|
|
|
.Xr installboot 8 ,
|
2002-01-13 11:02:14 +03:00
|
|
|
.Xr mbr 8 ,
|
2000-11-14 14:06:19 +03:00
|
|
|
.Xr mbrlabel 8
|
1993-04-09 23:23:56 +04:00
|
|
|
.Sh BUGS
|
2004-03-20 01:21:36 +03:00
|
|
|
The word
|
|
|
|
.Sq partition
|
|
|
|
is used to mean both an MBR partition and a
|
2003-04-30 23:47:10 +04:00
|
|
|
.Nx
|
|
|
|
partition, sometimes in the same sentence.
|
|
|
|
.Pp
|
1994-09-23 08:30:13 +04:00
|
|
|
There are subtleties that the program detects that are not explained in
|
|
|
|
this manual page.
|