.\" Copyright (c) 2002 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 AUTHOR ``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 AUTHOR 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: src/sbin/gpt/gpt.8,v 1.17 2006/06/22 22:22:32 marcel Exp $ .\" .Dd March 2, 2019 .Dt GPT 8 .Os .Sh NAME .Nm gpt .Nd "GUID partition table maintenance utility" .Sh SYNOPSIS .Nm .Op Ar general_options .Ar command .Op Ar command_options .Ar device ... .Sh DESCRIPTION The .Nm utility provides the necessary functionality to manipulate GUID partition tables (GPTs), but see .Sx BUGS below for how and where functionality is missing. GPT partitions are accessed as .Dx disk slices, with same number as GPT partition, 127 slices per disk device are supported. The basic usage model of the .Nm tool follows that of the .Xr cvs 1 tool. The general options are described in the following paragraph. The remaining paragraphs describe the individual commands with their options. Here we conclude by mentioning that a .Ar device is either a special file corresponding to a disk-like device or a regular file. The command is applied to each .Ar device listed on the command line. .Ss General Options The general options allow the user to change default settings or otherwise change the behaviour that is applicable to all commands. Not all commands use all default settings, so some general options may not have an effect on all commands. .Pp The .Fl p Ar count option allows the user to change the number of partitions the GPT can accommodate. This is used whenever a new GPT is created. By default, the .Nm utility will create space for 128 partitions (or 32 sectors of 512 bytes). .Pp The .Fl r option causes the .Nm utility to open the device for reading only. Currently this option is primarily useful for the .Ic show command, but the intent is to use it to implement dry-run behaviour. .Pp The .Fl v option controls the verbosity level. The level increases with every occurrence of this option. There is no formalized definition of the different levels yet. .Ss Commands .Bl -tag -width indent .\" ==== add ==== .It Xo .Nm .Ic add .Op Fl b Ar number .Op Fl i Ar index .Op Fl s Ar count .Op Fl t Ar type .Ar device ... .Xc The .Ic add command allows the user to add a new partition to an existing table, the name of the disk slice for the added partition is printed. By default, it will create a .Cm dfly partition covering the first available block of an unused disk space. The command-specific options can be used to control this behaviour. .Pp The .Fl b Ar number option allows the user to specify the starting (beginning) sector number of the partition. The minimum sector number is 1, but has to fall inside an unused region of disk space that is covered by the GPT. .Pp The .Fl i Ar index option allows the user to specify which (free) entry in the GPT table is to be used for the new partition. By default, the first free entry is selected. Entries start at index 0 representing partition 0 of the GPT. .Pp The .Fl s Ar count option allows the user to specify the size of the partition in sectors. The minimum size is 1. .Pp The .Fl t Ar type option allows the user to specify the partition type. The type is given as an UUID, but .Nm accepts .Cm efi , swap , ufs , hfs , linux , dfly , hammer, hammer2 and .Cm windows as aliases for the most commonly used partition types. .Cm ufs is a .Fx UFS UUID. .Cm dfly has the alias .Cm dragonfly and is a .Dx .Xr disklabel64 5 UUID. You may also specify any symbolic name in the system .Xr uuids 5 files. .Pp .Em NOTE! If you don't specify a beginning sector with .Fl b Ar number , the new partition will be aligned to 1MiB in size and position (in case of 512 byte sector sizes). .\" ==== boot ==== .It Nm Ic boot Ar device ... The .Ic boot command allows the user to create a small boot partition in a freshly created GPT. .Pp This command creates a small, 1GB boot partition as partition #0 and hacks in a special .Sq slice 1 in the PMBR which aliases it. The PMBR is further modified to add the necessary boot code. You can then disklabel GPT partition #0 and mount it, placing the contents of .Pa /boot directory within. You must add a line to .Pa loader.conf , like .Bd -literal -offset indent vfs.root.mountfrom="ufs:da1s1a" .Ed .Pp which point to the actual root mount. .Pp Your root partition may be another GPT partition and you may use a 64 bit disklabel within that partition if you desire. .Pp The .Sq boot0 boot manager is used, it can be manipulated with the .Xr boot0cfg 8 command, .Sq packet option usually needs to be set. .Pp .Em NOTE! A disk setup with the .Ar boot command may not be shared with another OS, as it doesn't use a fully standard GPT. .Pp .Em WARNING! Some BIOSes may not be able to deal with this hack, your mileage may vary. .\" ==== create ==== .It Nm Ic create Oo Fl fp Oc Ar device ... The .Ic create command allows the user to create a new (empty) GPT. By default, one cannot create a GPT when the device contains a MBR, however this can be overridden with the .Fl f option. If the .Fl f option is specified, an existing MBR is destroyed and any partitions described by the MBR are lost. .Pp The .Fl p option tells .Nm to create only the primary table and not the backup table. This option is only useful for debugging and should not be used otherwise. .\" ==== destroy ==== .It Nm Ic destroy Oo Fl r Oc Ar device ... The .Ic destroy command allows the user to destroy an existing, possibly not empty GPT. .Pp The .Fl r option instructs .Nm to destroy the table in a way that it can be recovered. .\" ==== expand ==== .It Nm Ic expand Ar device The .Ic expand command will expand an existing gpt label to cover a device which has grown in size, and will also expand the size of the last GPT partition to fit. This is typically the first step when expanding a hammer2 filesystem, after which disklabel -x and hammer2 growfs are run. .\" ==== init ==== .It Nm Ic init Fl f Oo Fl B Oc Oo Fl E Oc Ar device ... The .Ic init command allows the user to create a new GPT similar to the create command, but will also populate it with a boot slice (s0) and a .Dx slice (s1). The boot slice will be dos-formatted. The disklabel will be left empty and ready to edit. .Pp Due to the destructive nature of this directive, the .Fl f option must also be specified. .Pp If the .Fl B option is specified, /boot/bootx64.efi will be copied into the msdos slice (s0), and the disklabel will be initialized with -B in addition to the normal -r -w. .Pp If the .Fl E option is specified, the drive is TRIMed prior to the installation of the new label, if supported. The operation will continue if not supported. Note that this will complete destroy the contents of the drive. .\" ==== label ==== .It Xo .Nm .Ic label .Op Fl a .Aq Fl f Ar file | Fl l Ar label .Ar device ... .Xc .It Xo .Nm .Ic label .Op Fl b Ar number .Op Fl i Ar index .Op Fl s Ar count .Op Fl t Ar type .Aq Fl f Ar file | Fl l Ar label .Ar device ... .Xc The .Ic label command allows the user to label any partitions that match the selection. At least one of the following selection options must be specified. .Pp The .Fl a option specifies that all partitions should be labeled. It is mutually exclusive with all other selection options. .Pp The .Fl b Ar number option selects the partition that starts at the given block number. .Pp The .Fl i Ar index option selects the partition with the given partition number. Partition numbers start at 0. .Pp The .Fl s Ar count option selects all partitions that have the given size. This can cause multiple partitions to be removed. .Pp The .Fl t Ar type option selects all partitions that have the given type. The type is given as an UUID or by the aliases that the .Ic add command accepts. This can cause multiple partitions to be removed. .Pp The .Fl f Ar file or .Fl l Ar label options specify the new label to be assigned to the selected partitions. The .Fl f Ar file option is used to read the label from the specified file. Only the first line is read from the file and the trailing newline character is stripped. If the file name is the dash or minus sign .Pq Fl , the label is read from the standard input. The .Fl l Ar label option is used to specify the label in the command line. The label is assumed to be encoded in UTF-8. .\" ==== migrate ==== .It Nm Ic migrate Oo Fl fs Oc Ar device ... The .Ic migrate command allows the user to migrate an MBR-based disk partitioning into a GPT-based partitioning. By default, the MBR is not migrated when it contains partitions of an unknown type. This can be overridden with the .Fl f option. Specifying the .Fl f option will cause unknown partitions to be ignored and any data in it to be lost. .Pp The .Fl s option prevents migrating .Bx disk labels into GPT partitions by creating the GPT equivalent of a slice. .\" ==== remove ==== .It Nm Ic remove Oo Fl a Oc Ar device ... .It Xo .Nm .Ic remove .Op Fl b Ar number .Op Fl i Ar index .Op Fl s Ar count .Op Fl t Ar type .Ar device ... .Xc The .Ic remove command allows the user to remove any and all partitions that match the selection. It uses the same selection options as the .Ic label command. See above for a description of these options. Partitions are removed by clearing the partition type. No other information is changed. .\" ==== show ==== .It Nm Ic show Oo Fl glu Oc Ar device ... The .Ic show command displays the current partitioning on the listed devices and gives an overall view of the disk contents. By default, the GPT partition type is displayed in a user-friendly form. If the .Fl u option is specified, the GPT partition type is displayed as a UUID. With the .Fl l option, the GPT partition label will be displayed instead of the GPT partition type. With the .Fl g option, the GPT partition GUID will be displayed instead of the GPT partition type. None of the options has any effect on non-GPT partitions. The order of precedence of the options are: .Fl l , .Fl g , .Fl u . .El .Sh FILES .Bl -tag -width ".Pa /etc/defaults/uuids" .It Pa /boot/boot0 The default .Sq boot0 image. .It Pa /etc/defaults/uuids A list of UUIDs and their symbolic names provided by the OS vendor. .It Pa /etc/uuids A list of UUIDs and their symbolic names provided by the system administrator. .El .Sh EXAMPLES To install an empty GPT on .Pa ad6 : .Pp .Dl "gpt create ad6" .Pp GPT partitions are defined in number of sectors, the sector size is usually 512B, which is assumed in the examples below, it can be found using: .Pp .Dl "gpt -v show ad6" .Pp To add a dummy GPT partition 0: .Pp .Dl "gpt add -i0 -s16 ad6" .Pp You might want to do this to not use slice 0 for data; when GPT is not used on a disk, slice 0 is the compatibility slice, which is used for .Dq dangerously dedicated disks. For GPT slice 0 has no special meaning, it is just the first slice on the disk. .Pp To add a GPT partition of size approx. 100GB: .Pp .Dl "gpt add -s200000000 ad6" .Pp This will be GPT partition 1 as it is the first one free, it will be accessible as .Pa ad6s1 , which is also printed by the command. The type will be .Dq DragonFly Label64 , it will have to be set up by .Xr disklabel64 8 . .Pp To add GPT partition 5 with type .Dq DragonFly HAMMER using the remaining free space: .Bd -literal -offset indent gpt add -i5 -t "DragonFly HAMMER" ad6 .Ed .Pp To print the contents of the GPT: .Pp .Dl "gpt show ad6" .Ss Boot Setup To setup a disk using GPT for booting, the steps below can be used. System is copied from an already installed disk, e.g.\& a hard disk or an install CD. This example will setup disk .Pa da1 with GPT for booting, using the .Ic boot command. .Pp .Em WARNING! Any previous data on disk installed to will be deleted. .Bd -literal -offset indent gpt create -f da1 gpt boot da1 boot0cfg -s 2 da1 disklabel -B -r -w da1s0 auto disklabel -e da1s0 # add `a: * * 4.2BSD', to add `a' partition # with fstype `4.2BSD' covering whole slice gpt add da1 disklabel64 -r -w da1s1 auto disklabel64 -e da1s1 # add `b: 4G * swap', to add `b' partition # with fstype `swap' and size 4GB, # add `a: * * HAMMER', to add `a' partition # with fstype `HAMMER' covering rest of slice newfs_hammer -L ROOT /dev/da1s1a mount_hammer /dev/da1s1a /mnt newfs /dev/da1s0a mkdir /mnt/boot mount /dev/da1s0a /mnt/boot cpdup / /mnt # copy each file system you need, e.g. cpdup /boot /mnt/boot cpdup /var /mnt/var cpdup /var/tmp /mnt/var/tmp cpdup /usr /mnt/usr cd /mnt vi etc/fstab # add `/dev/da1s1a / hammer rw', # add `/dev/da1s1b none swap sw', # add `/dev/da1s0a /boot ufs rw 1 1', # delete lines for file systems cpdup'ed above vi boot/loader.conf # add `vfs.root.mountfrom="hammer:da1s1a"' cd umount /mnt/boot umount /mnt .Ed .Sh COMPATIBILITY The GPT that .Nm manipulates is part of the EFI standard and is supported by many OSs. GPT uses 64 bits to store number of sectors, this supports very large disks. With the prevalent sector size of 512B this is 8 billion TB. .Sh SEE ALSO .Xr uuid 3 , .Xr disklabel64 5 , .Xr uuids 5 , .Xr boot0cfg 8 , .Xr disklabel 8 , .Xr disklabel64 8 , .Xr fdisk 8 , .Xr mount 8 , .Xr newfs 8 , .Xr newfs_hammer 8 , .Xr swapon 8 .Sh HISTORY The .Nm utility appeared in .Fx 5.0 for ia64. It was imported to .Dx 1.9 . .Sh BUGS The development of the .Nm utility is still work in progress. Many necessary features are missing or partially implemented. In practice this means that the manual page, supposed to describe these features, is farther removed from being complete or useful. As such, missing functionality is not even documented as missing. However, it is believed that the currently present functionality is reliable and stable enough that this tool can be used without bullet-proof footware if one thinks one does not make mistakes. .Pp It is expected that the basic usage model does not change, but it is possible that future versions will not be compatible in the strictest sense of the word. For example, the .Fl p Ar count option may be changed to a command option rather than a generic option. There are only two commands that use it so there is a chance that the natural tendency for people is to use it as a command option. Also, options primarily intended for diagnostic or debug purposes may be removed in future versions. .Pp Another possibility is that the current usage model is accompanied by other interfaces to make the tool usable as a back-end. This all depends on demand and thus feedback. .Pp The .Ic migrate command doesn't support .Dx partition types.