Next: , Previous: , Up: Using Parted   [Index]

2.2 Using GNU Parted

Parted has two modes: command line and interactive. Parted should always be started with:

# parted device

where device is the hard disk device to edit. (If you’re lazy and omit the DEVICE argument, Parted will attempt to guess which device you want.)

In command line mode, this is followed by one or more commands. For example:

# parted /dev/sda mklabel gpt mkpart P1 ext3 1MiB 8MiB 

Options (like --help) can only be specified on the command line.

In interactive mode, commands are entered one at a time at a prompt, and modify the disk immediately. For example:

(parted) mklabel gpt
(parted) mkpart P1 ext3 1MiB 8MiB 

Unambiguous abbreviations are allowed. For example, you can type “p” instead of “print”, and “u” instead of “units”. Commands can be typed either in English, or your native language (if your language has been translated). This may create ambiguities. Commands are case-insensitive.

Numbers indicating partition locations can be whole numbers or decimals. The suffix selects the unit, which may be one of those described in unit, except CHS and compact. If no suffix is given, then the default unit is assumed. Negative numbers count back from the end of the disk, with “-1s” indicating the sector at the end of the disk. Parted will compute sensible ranges for the locations you specify (e.g. a range of +/- 500 MB when you specify the location in “G”). Use the sector unit “s” to specify exact locations. With parted-2.4 and newer, IEC binary units like “MiB”, “GiB”, “TiB”, etc., specify exact locations as well. See IEC binary units.

If you don’t give a parameter to a command, Parted will prompt you for it. For example:

(parted) mklabel
New disk label type? gpt

Parted will always warn you before doing something that is potentially dangerous, unless the command is one of those that is inherently dangerous (viz., rm, mklabel and mkpart). Since many partitioning systems have complicated constraints, Parted will usually do something slightly different to what you asked. (For example, create a partition starting at 10.352Mb, not 10.4Mb) If the calculated values differ too much, Parted will ask you for confirmation.
