Linux "parted" Command Line Options and Examples

parted is a program to manipulate disk partitions. It supports multiple partition table formats, including MS-DOS and GPT. It is useful for creating space for new operating systems, reorganising disk usage, and copy‐ ing data to new hard disks.


Usage:

parted [options] [device [command [options...]...]]






Command Line Options:

-h
displays a help message
parted -h ...
-l
lists partition layout on all block devices
parted -l ...
-m
displays machine parseable output
parted -m ...
-s
never prompts for user intervention
parted -s ...
-v
displays the version
parted -v ...
-a
Set alignment for newly created partitions, valid alignment types are:none Use the minimum alignment allowed by the disk type.cylinderAlign partitions to cylinders.minimalUse minimum alignment as given by the disk topology information. This and the opt value will uselayout information provided by the disk to align the logical partition table addresses to actualphysical blocks on the disks. The min value is the minimum alignment needed to align the parti‐tion properly to physical blocks, which avoids performance degradation.optimalUse optimum alignment as given by the disk topology information. This aligns to a multiple ofthe physical block size in a way that guarantees optimal performance.COMMANDS[device]The block device to be used. When none is given, parted will use the first block device it finds.[command [options]]Specifies the command to be executed. If no command is given, parted will present a command prompt.Possible commands are:help [command]Print general help, or help on command if specified.align-check type partitionCheck if partition satisfies the alignment constraint of type. type must be "minimal" or "opti‐mal".mklabel label-typeCreate a new disklabel (partition table) of label-type. label-type should be one of "aix","amiga", "bsd", "dvh", "gpt", "loop", "mac", "msdos", "pc98", or "sun".mkpart part-type [fs-type] start endMake a part-type partition for filesystem fs-type (if specified), beginning at start and endingat end (by default in megabytes). part-type should be one of "primary", "logical", or"extended".name partition nameSet the name of partition to name. This option works only on Mac, PC98, and GPT disklabels. Thename can be placed in quotes, if necessary.print Display the partition table.quit Exit from parted.rescue start endRescue a lost partition that was located somewhere between start and end. If a partition isfound, parted will ask if you want to create an entry for it in the partition table.resizepart partition endChange the end position of partition. Note that this does not modify any filesystem present inthe partition.rm partitionDelete partition.select deviceChoose device as the current device to edit. device should usually be a Linux hard disk device,but it can be a partition, software raid device, or an LVM logical volume if necessary.set partition flag stateChange the state of the flag on partition to state. Supported flags are: "boot", "root","swap", "hidden", "raid", "lvm", "lba", "legacy_boot", "irst", "esp" and "palo". state shouldbe either "on" or "off".unit unitSet unit as the unit to use when displaying locations and sizes, and for interpreting thosegiven by the user when not suffixed with an explicit unit. unit can be one of "s" (sectors),"B" (bytes), "kB", "MB", "MiB", "GB", "GiB", "TB", "TiB", "%" (percentage of device size), "cyl"(cylinders), "chs" (cylinders, heads, sectors), or "compact" (megabytes for input, and a human-friendly form for output).toggle partition flagToggle the state of flag on partition.versionDisplay version information and a copyright message.REPORTING BUGSReport bugs to <bug-parted@gnu.org>
parted -a ...