freebsd-skq/sbin/geom/class/part/gpart.8

524 lines
13 KiB
Groff
Raw Normal View History

.\" Copyright (c) 2007, 2008 Marcel Moolenaar
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
2009-10-19 15:50:59 +00:00
.Dd November 18, 2008
.Dt GPART 8
.Os
.Sh NAME
.Nm gpart
.Nd "control utility for the disk partitioning GEOM class"
.Sh SYNOPSIS
To add support for the disk partitioning GEOM class,
place one or more of the following
lines in your kernel configuration file:
.Bd -ragged -offset indent
.Cd "options GEOM_PART_APM"
.Cd "options GEOM_PART_BSD"
.Cd "options GEOM_PART_GPT"
.Cd "options GEOM_PART_MBR"
.Cd "options GEOM_PART_PC98"
.Cd "options GEOM_PART_VTOC8"
.Ed
.Pp
2009-10-19 15:50:59 +00:00
The
.Dv GEOM_PART_APM
option adds support for the Apple Partition Map (APM)
found on Apple Macintosh computers.
2009-10-19 15:50:59 +00:00
The
.Dv GEOM_PART_BSD
option adds support for the traditional
.Bx
disklabel.
The
.Dv GEOM_PART_GPT
option adds support for the GUID Partition Table (GPT)
found on Intel Itanium computers and Intel-based Macintosh computers.
2009-10-19 15:50:59 +00:00
The
.Dv GEOM_PART_MBR
option adds support for the Master Boot Record (MBR)
found on PCs and used on many removable media.
2009-10-19 15:50:59 +00:00
The
.Dv GEOM_PART_PC98
option adds support for the MBR variant as used on
NEC PC-98 computers.
2009-10-19 15:50:59 +00:00
The
.Dv GEOM_PART_VTOC8
option adds support for Sun's SMI VTOC8 label as
found on UltraSPARC-based computers.
.Pp
Usage of the
2009-10-19 15:50:59 +00:00
.Ns Nm
utility:
.Pp
.\" ==== ADD ====
.Nm
.Cm add
.Fl b Ar start
.Fl s Ar size
.Fl t Ar type
.Op Fl i Ar index
.Op Fl l Ar label
.Op Fl f Ar flags
.Ar geom
.\" ==== BOOTCODE ====
.Nm
.Cm bootcode
.Op Fl b Ar bootcode
.Op Fl p Ar partcode Fl i Ar index
.Op Fl f Ar flags
.Ar geom
.\" ==== COMMIT ====
.Nm
.Cm commit
.Ar geom
.\" ==== CREATE ====
.Nm
.Cm create
.Fl s Ar scheme
.Op Fl n Ar entries
.Op Fl f Ar flags
.Ar provider
.\" ==== DELETE ====
.Nm
.Cm delete
.Fl i Ar index
.Op Fl f Ar flags
.Ar geom
.\" ==== DESTROY ====
.Nm
.Cm destroy
.Op Fl f Ar flags
.Ar geom
.\" ==== MODIFY ====
.Nm
.Cm modify
.Fl i Ar index
.Op Fl l Ar label
.Op Fl t Ar type
.Op Fl f Ar flags
.Ar geom
.\" ==== SET ====
.Nm
.Cm set
.Fl a Ar attrib
.Fl i Ar index
.Op Fl f Ar flags
.Ar geom
.\" ==== SHOW ====
.Nm
.Cm show
.Op Ar geom ...
.\" ==== UNDO ====
.Nm
.Cm undo
.Ar geom
.\" ==== UNSET ====
.Nm
2009-10-19 15:50:59 +00:00
.Cm unset
.Fl a Ar attrib
.Fl i Ar index
.Op Fl f Ar flags
.Ar geom
.\"
.Sh DESCRIPTION
The
.Nm
utility is used to partition GEOM providers, normally disks.
The first argument of which is the action to be taken:
2009-10-19 15:50:59 +00:00
.Bl -tag -width ".Cm bootcode"
.\" ==== ADD ====
.It Cm add
Add a new partition to the partitioning scheme given by
.Ar geom .
The partition begins on the logical block address given by the
.Fl b Ar start
option.
Its size is expressed in logical block numbers and given by the
.Fl s Ar size
option.
The type of the partition is given by the
.Fl t Ar type
option.
2009-10-19 15:50:59 +00:00
Partition types are discussed below in the section entitled
.Sx "PARTITION TYPES" .
.Pp
2009-10-19 15:50:59 +00:00
Additional options include:
.Bl -tag -width 10n
.It Fl i Ar index
The index in the partition table at which the new partition is to be
2009-10-19 15:50:59 +00:00
placed.
The index determines the name of the device special file used
to represent the partition.
.It Fl l Ar label
The label attached to the partition.
This option is only valid when used on partitioning schemes that support
partition labels.
.It Fl f Ar flags
Additional operational flags.
2009-10-19 15:50:59 +00:00
See the section entitled
.Sx "OPERATIONAL FLAGS"
below for a discussion
about its use.
.El
.\" ==== BOOTCODE ====
.It Cm bootcode
Embed bootstrap code into the partitioning scheme's metadata on the
.Ar geom
(using
.Fl b Ar bootcode )
or write bootstrap code into a partition (using
.Fl p Ar partcode
and
.Fl i Ar index ) .
Not all partitioning schemes have embedded bootstrap code, so the
.Fl b Ar bootcode
option is scheme-specific in nature.
For the GPT scheme, embedded bootstrap code is supported.
The bootstrap code is embedded in the protective MBR rather than the GPT.
The
.Fl b Ar bootcode
option specifies a file that contains the bootstrap code.
The contents and size of the file are determined by the partitioning
scheme.
2009-10-19 15:50:59 +00:00
For the MBR scheme, it is a 512 byte file of which the first 446 bytes
are installed as bootstrap code.
The
.Fl p Ar partcode
option specifies a file that contains the bootstrap code intended to be
written to a partition.
The partition is specified by the
.Fl i Ar index
option.
The size of the file must be smaller than the size of the partition.
.Pp
2009-10-19 15:50:59 +00:00
Additional options include:
.Bl -tag -width 10n
.It Fl f Ar flags
Additional operational flags.
2009-10-19 15:50:59 +00:00
See the section entitled
.Sx "OPERATIONAL FLAGS"
below for a discussion
about its use.
.El
.\" ==== COMMIT ====
.It Cm commit
Commit any pending changes for geom
.Ar geom .
All actions are being committed by default and will not result in
pending changes.
Actions can be modified with the
.Fl f Ar flags
option so that they are not being committed by default.
As such, they become pending.
Pending changes are reflected by the geom and the
.Nm
utility, but they are not actually written to disk.
The
.Cm commit
action will write any and all pending changes to disk.
.\" ==== CREATE ====
.It Cm create
Create a new partitioning scheme on a provider given by
.Ar provider .
The
.Fl s Ar scheme
option determines the scheme to use.
The kernel needs to have support for a particular scheme before
that scheme can be used to partition a disk.
.Pp
2009-10-19 15:50:59 +00:00
Additional options include:
.Bl -tag -width 10n
.It Fl n Ar entries
The number of entries in the partition table.
Every partitioning scheme has a minimum and a maximum number of entries
and this option allows tables to be created with the number of entries
that lies anywhere between the minimum and the maximum.
Some schemes have a maximum equal to the minimum and some schemes have
a maximum large enough to be considered unlimited.
By default, partition tables are created with the minimum number of
entries.
.It Fl f Ar flags
Additional operational flags.
2009-10-19 15:50:59 +00:00
See the section entitled
.Sx "OPERATIONAL FLAGS"
below for a discussion
about its use.
.El
.\" ==== DELETE ====
.It Cm delete
Delete a partition from geom
.Ar geom
and further identified by the
.Fl i Ar index
option.
The partition cannot be actively used by the kernel.
.Pp
2009-10-19 15:50:59 +00:00
Additional options include:
.Bl -tag -width 10n
.It Fl f Ar flags
Additional operational flags.
2009-10-19 15:50:59 +00:00
See the section entitled
.Sx "OPERATIONAL FLAGS"
below for a discussion
about its use.
.El
.\" ==== DESTROY ====
.It Cm destroy
Destroy the partitioning scheme as implemented by geom
.Ar geom .
.Pp
2009-10-19 15:50:59 +00:00
Additional options include:
.Bl -tag -width 10n
.It Fl f Ar flags
Additional operational flags.
2009-10-19 15:50:59 +00:00
See the section entitled
.Sx "OPERATIONAL FLAGS"
below for a discussion
about its use.
.El
.\" ==== MODIFY ====
.It Cm modify
Modify a partition from geom
.Ar geom
and further identified by the
.Fl i Ar index
option.
Only the the type and/or label of the partition can be modified.
To change the type of a partition, specify the new type with the
.Fl t Ar type
option.
To change the label of a partition, specify the new label with the
.Fl l Ar label
option.
Not all partitioning schemes support labels and it is invalid to
try to change a partition label in such cases.
.Pp
2009-10-19 15:50:59 +00:00
Additional options include:
.Bl -tag -width 10n
.It Fl f Ar flags
Additional operational flags.
2009-10-19 15:50:59 +00:00
See the section entitled
.Sx "OPERATIONAL FLAGS"
below for a discussion
about its use.
.El
.\" ==== SET ====
.It Cm set
Set the named attribute on the partition entry.
.Pp
2009-10-19 15:50:59 +00:00
Additional options include:
.Bl -tag -width 10n
.It Fl f Ar flags
Additional operational flags.
2009-10-19 15:50:59 +00:00
See the section entitled
.Sx "OPERATIONAL FLAGS"
below for a discussion
about its use.
.El
.\" ==== SHOW ====
.It Cm show
Show the current partition information of the specified geoms
or all geoms if none are specified.
.\" ==== UNDO ====
.It Cm undo
2009-10-19 15:50:59 +00:00
Revert any pending changes for geom
.Ar geom .
This action is the opposite of the
.Cm commit
action and can be used to undo any changes that have not been committed.
.\" ==== UNSET ====
.It Cm unset
Clear the named attribute on the partition entry.
.Pp
2009-10-19 15:50:59 +00:00
Additional options include:
.Bl -tag -width 10n
.It Fl f Ar flags
Additional operational flags.
2009-10-19 15:50:59 +00:00
See the section entitled
.Sx "OPERATIONAL FLAGS"
below for a discussion
about its use.
.El
.El
.\"
.Sh PARTITION TYPES
The
.Nm
utility uses symbolic names for common partition types to avoid that the
user needs to know what the partitioning scheme in question is and what
the actual number or identification needs to be used for a particular
type.
2009-10-19 15:50:59 +00:00
The
.Nm
utility also allows the user to specify scheme-specific partition types
2009-10-19 15:50:59 +00:00
for partition types that do not have symbol names.
The symbolic names currently understood are:
2009-10-19 15:50:59 +00:00
.Bl -tag -width ".Cm freebsd-vinum"
.It Cm efi
The system partition for computers that use the Extensible Firmware
Interface (EFI).
In such cases, the GPT partitioning scheme is being used and the
actual partition type for the system partition can also be specified as
2009-10-19 15:50:59 +00:00
.Qq Li "!c12a7328-f81f-11d2-ba4b-00a0c93ec93ab" .
.It Cm freebsd
A
.Fx
partition that uses the
.Bx
disklabel to sub-divide the
partition into file systems.
This is a legacy partition type and should not be used for the APM
or GPT schemes.
2009-10-19 15:50:59 +00:00
The scheme-specific types are
.Qq Li "!165"
for MBR,
.Qq Li "!FreeBSD"
for APM, and
.Qq Li "!516e7cb4-6ecf-11d6-8ff8-00022d09712b"
for GPT.
.It Cm freebsd-boot
A
.Fx
partition dedicated to bootstrap code.
The scheme-specific type is
.Qq Li "!83bd6b9d-7f41-11dc-be0b-001560b84f0f"
for GPT.
.It Cm freebsd-swap
A
.Fx
partition dedicated to swap space.
The scheme-specific types are
.Qq Li "!FreeBSD-swap"
for APM, and
.Qq Li "!516e7cb5-6ecf-11d6-8ff8-00022d09712b"
for GPT.
.It Cm freebsd-ufs
A
.Fx
partition that contains a UFS or UFS2 file system.
The scheme-specific types are
.Qq Li "!FreeBSD-UFS"
for APM, and
.Qq Li "!516e7cb6-6ecf-11d6-8ff8-00022d09712b"
for GPT.
.It Cm freebsd-vinum
A
.Fx
partition that contains a Vinum volume.
The scheme-specific types are
.Qq Li "!FreeBSD-Vinum"
for APM, and
.Qq Li "!516e7cb8-6ecf-11d6-8ff8-00022d09712b"
for GPT.
.It Cm freebsd-zfs
A
.Fx
partition that contains a ZFS volume.
The scheme-specific types are
.Qq Li "!FreeBSD-ZFS"
for APM, and
.Qq Li "!516e7cba-6ecf-11d6-8ff8-00022d09712b"
for GPT.
.It Cm mbr
A partition that is sub-partitioned by a master boot record (MBR).
2009-10-19 15:50:59 +00:00
This type is known as
.Qq Li "!024dee41-33e7-11d3-9d69-0008c781f39f"
by GPT.
.El
.Sh OPERATIONAL FLAGS
Actions other than the
.Cm commit
and
.Cm undo
actions take an optional
.Fl f Ar flags
option.
This option is used to specify action-specific operational flags.
By default, the
.Nm
2009-10-19 15:50:59 +00:00
utility defines the
.Ql C
flag so that the action is immediately
committed.
The user can specify
2009-10-19 15:50:59 +00:00
.Dq Fl f Cm x
to have the action result in a pending change that can later, with
other pending changes, be committed as a single compound change with
the
.Cm commit
action or reverted with the
.Cm undo
action.
.Sh EXIT STATUS
Exit status is 0 on success, and 1 if the command fails.
.Sh EXAMPLES
Create GPT scheme on
.Pa ad0 .
.Bd -literal -offset indent
/sbin/gpart create -s GPT ad0
.Ed
.Pp
Embed GPT bootstrap code into protective MBR.
.Bd -literal -offset indent
/sbin/gpart bootcode -b /boot/pmbr ad0
.Ed
.Pp
Create a dedicated
2009-10-19 15:50:59 +00:00
.Cm freebsd-boot
partition that can boot
.Fx
from a
.Cm freebsd-ufs
partition, and install bootstrap code into it.
This partition must be larger than
.Pa /boot/gptboot ,
or the GPT boot you are planning to write.
A size of 15 blocks (7680 bytes) would be sufficient for
2009-10-19 15:50:59 +00:00
booting from UFS but let's use 128 blocks (64 KB) here in
this example, in order to reserve some space for potential
2009-10-19 15:50:59 +00:00
future need (e.g.\& from a ZFS partition).
.Bd -literal -offset indent
/sbin/gpart add -b 34 -s 128 -t freebsd-boot ad0
/sbin/gpart bootcode -p /boot/gptboot -i 1 ad0
.Ed
.Pp
Create a 512MB-sized
2009-10-19 15:50:59 +00:00
.Cm freebsd-ufs
partition that would contain UFS where the system boot from.
.Bd -literal -offset indent
/sbin/gpart add -b 162 -s 1048576 -t freebsd-ufs ad0
.Ed
.Sh SEE ALSO
.Xr geom 4 ,
2009-10-19 15:50:59 +00:00
.Xr geom 8
.Sh HISTORY
The
.Nm
utility appeared in
.Fx 7.0 .
.Sh AUTHORS
.An Marcel Moolenaar Aq marcel@FreeBSD.org