Next: , Previous: Partitioning, Up: Using Parted


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 resize 1 52Mb 104Mb mkfs 2 fat16

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) resize 1 52.0005Mb 104.5Mb
     (parted) mkfs 2 fat16

Unambiguous abbreviations are allowed. For example, you can type “p” instead of “print”, and “resi” instead of “resize”. 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 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.

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

     (parted) resize 1
     Start? 0Gb
     End? 40Gb

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 mkfs). For example, if you attempt to shrink a partition “too much” (i.e., by more than the free space available), Parted will automatically reduce the shrinkage so that the partition is the smallest it can be without losing data. If this size is significantly different from the size requested, Parted will warn you. 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.