gpt(8) - NetBSD Manual Pages

GPT(8)                  NetBSD System Manager's Manual                  GPT(8)


NAME
gpt -- GUID partition table maintenance utility
SYNOPSIS
gpt [general_options] command [command_options] device ...
DESCRIPTION
The gpt utility provides the necessary functionality to manipulate GUID partition tables (GPTs), but see BUGS below for how and where functional- ity is missing. The basic usage model of the gpt tool follows that of the 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 device is either a special file corresponding to a disk-like device or a regular file. The command is applied to each device listed on the command line. General Options The general options allow the user to change default settings or other- wise 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. The -m mediasize option overrides the default media size for the device (obtained from the kernel if possible) or defaulting to the file size for plain files. The -p partitions option allows the user to change the number of parti- tions the GPT can accommodate. This is used whenever a new GPT is cre- ated. By default, the gpt utility will create space for 128 partitions (or 32 sectors of 512 bytes). The -r option causes the gpt utility to open the device for reading only. Currently this option is primarily useful for the show command, but the intent is to use it to implement dry-run behaviour. The -s sectorsize option overrides the default sector size for the device (obtained from the kernel if possible) or 512 for plain files. The -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. Commands gpt add [-a alignment] [-b blocknr] [-i index] [-l label] [-s size] [-t type] device ... The add command allows the user to add a new partition to an existing table. By default, it will create a UFS partition cov- ering the first available block of an unused disk space. The command-specific options can be used to control this behaviour. The -a alignment option allows the user to specify an alignment for the start and size. The alignment may have a suffix to indi- cate its magnitude. gpt will attempt to align the partition. The -b blocknr 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. The -i 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. The -l label option allows the user to specify a label for the partition. The -s size option allows the user to specify the size of the partition. If there is no suffix, or the suffix is `s' or `S' then size is in sectors, otherwise size is in bytes which must be a multiple of the device's sector size. The minimum size is 1 sector. The -t type option allows the user to specify the partition type. The type is given as an UUID, but gpt accepts apple Apple HFS apple-ufs Apple UFS bios BIOS Boot efi EFI System fbsd-legacy FreeBSD legacy fbsd-swap FreeBSD swap fbsd-ufs FreeBSD UFS/UFS2 fbsd-vinum FreeBSD vinum fbsd-zfs FreeBSD ZFS linux-data Linux data linux-raid Linux RAID linux-swap Linux swap linux-lvm Linux LVM windows Windows basic data windows-reserved Windows reserved ccd NetBSD ccd component cgd NetBSD Cryptographic Disk ffs NetBSD FFSv1/FFSv2 lfs NetBSD LFS raid NetBSD RAIDFrame component swap NetBSD swap as aliases for the most commonly used partition types. gpt backup device ... The backup command dumps the MBR or (PMBR) and GPT partition tables to standard output in a format to be used by the restore command. The format is a plist. It should not be modified. gpt biosboot [-c bootcode] [-i index] [-L label] device ... The biosboot command allows the user to configure the partition that contains the primary bootstrap program, used during boot(8). The -c option allows the user to specify the filename that gpt should read the bootcode from. The default is to read from /usr/mdec/gptmbr.bin. The -i option selects the partition that should contain the pri- mary bootstrap code, as installed via installboot(8). The -L option selects the partition by label. If there are multiple partitions with the same label, it will use the first one found. gpt create [-fp] device ... The 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 -f option. If the -f option is specified, an existing MBR is destroyed and any par- titions described by the MBR are lost. The -p option tells gpt to create only the primary table and not the backup table. This option is only useful for debugging and should not be used otherwise. gpt destroy [-r] device ... The destroy command allows the user to destroy an existing, pos- sibly not empty GPT. The -r option instructs gpt to destroy the table in a way that it can be recovered. gpt label [-a] <-f file | -l label> device ... gpt label [-b blocknr] [-i index] [-L label] [-s sectors] [-t type] <-f file | -l label> device ... The label command allows the user to label any partitions that match the selection. At least one of the following selection options must be specified. The -a option specifies that all partitions should be labeled. It is mutually exclusive with all other selection options. The -b blocknr option selects the partition that starts at the given block number. The -i index option selects the partition with the given parti- tion number. The -L label option selects all partitions that have the given label. This can cause multiple partitions to be relabeled. The -s sectors option selects all partitions that have the given size. This can cause multiple partitions to be labeled. The -t type option selects all partitions that have the given type. The type is given as an UUID or by the aliases that the add command accepts. This can cause multiple partitions to be labeled. The -f file or -l label options specify the new label to be assigned to the selected partitions. The -f 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 (-), the label is read from the standard input. The -l label option is used to specify the label in the command line. The label is assumed to be encoded in UTF-8. gpt migrate [-fs] device ... The 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 -f option. Specifying the -f option will cause unknown partitions to be ignored and any data in it to be lost. The -s option prevents migrating BSD disk labels into GPT parti- tions by creating the GPT equivalent of a slice. Note that the -s option isn't applicable to NetBSD partitions. The migrate command requires space at the beginning and the end of the device outside any partitions to store the GPTs. Space is required for the GPT header (which takes one sector) and the GPT partition table. See the -p option for the size of the GPT par- tition table. By default, just about all devices have a minimum of 62 sectors free at the beginning of the device, but don't have any free space at the end. For the default GPT partition table size on a 512 byte sector size device, 33 sectors at the end of the device would need to be freed. gpt recover device ... The recover command tries to restore the GPT partition label from the backup near the end of the disk. It is very useful in case the primary label was deleted. gpt remove [-a] device ... gpt remove [-b blocknr] [-i index] [-L label] [-s sectors] [-t type] device ... The remove command allows the user to remove any and all parti- tions that match the selection. It uses the same selection options as the label command. See above for a description of these options. Partitions are removed by clearing the partition type. No other information is changed. gpt resize -i index [-a alignment] [-s size] device ... The resize command allows the user to resize a partition. The partition may be shrunk and if there is sufficient free space immediately after it then it may be expanded. The -s option allows the new size to be specified, otherwise the partition will be increased to the maximum available size. If there is no suf- fix, or the suffix is `s' or `S' then size is in sectors, other- wise size is in bytes which must be a multiple of the device's sector size. The minimum size is 1 sector. If the -a option is specified then the size will be adjusted to be a multiple of alignment if possible. gpt resizedisk [-s size] device ... The resizedisk command allows the user to resize a disk. With GPTs, a backup copy is stored at the end of the disk. If the underlying medium changes size (or is going to change size), then the backup copy needs to be moved to the new end of the disk, and the last sector available for data storage needs to be adjusted. This command does that. If the backup copy no longer exists due to the medium shrinking, then a new backup copy will be created using the primary copy. The -s option allows the new size to be specified, otherwise the backup copy will automatically be placed at the current end of the disk. If there is no suffix, or the suffix is `s' or `S' then size is in sectors, otherwise size is in bytes which must be a multiple of the device's sector size. Using the -s option allows you to move the backup copy prior to resizing the medium. This is primarily useful when shrinking the medium. gpt restore [-F] device ... The restore command restores a partition table that was previ- ously saved using the backup command. The partition table is read from standard input and is expected to be in the format of a plist. It assumes an empty disk. The -F option can be used to blank the disk. The new disk does not have to be the same size as the old disk as long as all the partitions fit, as restore will automatically adjust. However, the new disk must use the same sector size as the old disk. gpt set -a attribute -i index device ... The set command sets various partition attributes. The -a option specifies which attributes to set and may be specified more than once. The -i option specifies which entry to update. The possi- ble attributes are ``biosboot'', ``bootme'', ``bootonce'', and ``bootfailed''. The biosboot flag is used to indicate which par- tition should be booted by legacy BIOS boot code. See the biosboot command for more information. The other three attributes are for compatibility with FreeBSD and are not cur- rently used by any NetBSD code. They may be used by NetBSD code in the future. gpt show [-glu] [-i index] device ... The show command displays the current partitioning on the listed devices and gives an overall view of the disk contents. With the -g option the GPT partition GUID will be displayed instead of the GPT partition type. With the -l option the GPT partition label will be displayed instead of the GPT partition type. With the -u option the GPT partition type is displayed as an UUID instead of in a user friendly form. With the -i option, all the details of a particular GPT partition will be displayed. The format of this display is subject to change. None of the options have any effect on non-GPT partitions. The order of precedence for the options are: -i, -l, -g, -u. gpt type [-a] -T newtype device ... gpt type [-b blocknr] [-i index] [-L label] [-s sectors] [-t type] -T newtype device ... The type command allows the user to change the type of any and all partitions that match the selection. It uses the same selec- tion options as the label command. See above for a description of these options. gpt unset -a attribute -i index device ... The unset command unsets various partition attributes. The -a option specifies which attributes to unset and may be specified more than once. The -i option specifies which entry to update. The possible attributes are ``biosboot'', ``bootme'', ``bootonce'', and ``bootfailed''. The biosboot flag is used to indicate which partition should be booted by legacy BIOS boot code. See the biosboot command for more information. The other three attributes are for compatibility with FreeBSD and are not currently used by any NetBSD code. They may be used by NetBSD code in the future.
EXAMPLES
nas# gpt show wd3 start size index contents 0 1 PMBR 1 3907029167 nas# gpt create wd3 nas# gpt show wd3 start size index contents 0 1 PMBR 1 1 Pri GPT header 2 32 Pri GPT table 34 3907029101 3907029135 32 Sec GPT table 3907029167 1 Sec GPT header nas# gpt add -s 10486224 -t swap -i 1 wd3 Partition added, use: dkctl rwd3d addwedge dk<N> 34 10486224 <type> to create a wedge for it nas# gpt label -i 1 -l swap_1 wd3 parition 1 on rwd3d labeled swap_1 nas# gpt show wd3 start size index contents 0 1 PMBR 1 1 Pri GPT header 2 32 Pri GPT table 34 10486224 1 GPT part - NetBSD swap 10486258 3896542877 3907029135 32 Sec GPT table 3907029167 1 Sec GPT header nas# gpt show -l wd3 start size index contents 0 1 PMBR 1 1 Pri GPT header 2 32 Pri GPT table 34 10486224 1 GPT part - "swap_1" 10486258 3896542877 3907029135 32 Sec GPT table 3907029167 1 Sec GPT header nas#
SEE ALSO
boot(8), fdisk(8), installboot(8), mount(8), newfs(8), swapon(8)
HISTORY
The gpt utility appeared in FreeBSD 5.0 for ia64.
BUGS
The development of the gpt utility is still work in progress. Many nec- essary features are missing or partially implemented. In practice this means that the manual page, supposed to describe these features, is far- ther removed from being complete or useful. As such, missing functional- ity 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. It is expected that the basic usage model does not change, but it is pos- sible that future versions will not be compatible in the strictest sense of the word. For example, the -p partitions 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. 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. NetBSD 7.0 December 6, 2014 NetBSD 7.0

Powered by man-cgi (2024-08-26). Maintained for NetBSD by Kimmo Suominen. Based on man-cgi by Panagiotis Christias.