     [file version.texi not included]

This file documents the use of GNU Parted, a program for creating and manipulating partition tables.

Copyright © 1999-2014, 2019 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts.  A copy of the license is included in the section entitled ``GNU Free Documentation License''.

GNU Parted User Manual
**********************

This file documents the use of GNU Parted, a program for creating and manipulating partition tables.

This document applies roughly to version VERSION of GNU Parted.

The original version was written by Andrew Clausen in text format. Richard M. Kreuter translated it into Texinfo format in 2002, to be heavily edited by Leslie P. Polzer in 2006.

Introduction
************

Overview of GNU Parted
======================

GNU Parted is a program for creating and manipulating partition tables.

This documentation is written with the assumption that the reader has some understanding of partitioning and file systems.

GNU Parted was designed to minimize the chance of data loss.  For example, it was designed to avoid data loss during interruptions (like power failure) and performs many safety checks.  However, there could be bugs in GNU Parted, so you should back up your important files before running Parted.

The GNU Parted homepage is http://www.gnu.org/software/parted.  The library and frontend themselves can be downloaded from ftp://ftp.gnu.org/gnu/parted. You can also find a listing of mailing lists, notes for contributing and more useful information on the web site.

Please send bug reports to bug-parted@gnu.org.  When sending bug reports, please include the version of GNU Parted. Please include the output from these commands (for disk /dev/hda):

     # parted /dev/hda print unit s print unit chs print

Feel free to ask for help on this list --- just check that your question isn't answered here first.  If you don't understand the documentation, please tell us, so we can explain it better.  General philosophy is: if you need to ask for help, then something needs to be fixed so you (and others) don't need to ask for help.

Also, we'd love to hear your ideas :-)

Software Required for the use of Parted
=======================================

If you're installing or compiling Parted yourself, you'll need to have some other programs installed.  If you are compiling Parted, you will need both the normal and devel packages of these programs installed:

  * libuuid, part of the e2fsprogs package.  If you don't have this, you can get it from:

     http://web.mit.edu/tytso/www/linux/e2fsprogs.html

     If you want to compile Parted and e2fsprogs, note that you will need to make install and make install-libs e2fsprogs.

  * GNU Readline (optional), available from

     ftp://ftp.gnu.org/gnu/readline

     If you are compiling Parted, and you don't have readline, you can disable Parted's readline support with the --disable-readline option for configure.

  * GNU gettext (or compatible software) for compilation, if internationalisation support is desired.

     ftp://ftp.gnu.org/gnu/gettext

Platforms on which GNU Parted runs
==================================

Hopefully, this list will grow a lot.  If you do not have one of these platforms, then you can use a rescue disk and a static binary of GNU Parted.

GNU/Linux
     Linux versions 2.0 and up, on Alpha, x86 PCs, PC98, Macintosh PowerPC, Sun hardware.

GNU/Hurd

Terms of distribution for GNU Parted
====================================

GNU Parted is free software, covered by the GNU General Public License Version 3, or (at your option) any later version.  This should have been included with the Parted distribution, in the COPYING file.  If not, see <http://www.gnu.org/licenses/>.

Libparted is considered part of GNU Parted.  It is covered by the GNU General Public License.  It is NOT released under the GNU Lesser General Public License (LGPL).

Building GNU Parted
===================

If you want to compile GNU Parted, this is generally done with:

     $ ./configure
     $ make

However, there are a few options for configure:

--without-readline
     turns off use of readline.  This is useful for making rescue disks, etc., where few libraries are available.

--disable-debug
     don't include assertions

--disable-nls
     turns off native language support.  This is useful for use with old versions of glibc, or a trimmed down version of glibc suitable for rescue disks.

--disable-shared
     turns off shared libraries.  This may be necessary for use with old versions of GNU libc, if you get a compile error about a ``spilled register''.  Also useful for boot/rescue disks.

--enable-discover-only
     support only reading/probing (reduces size considerably)

--enable-mtrace
     enable malloc() debugging

--enable-read-only
     disable writing (for debugging)

Introduction
------------

If you want to run GNU Parted on a machine without GNU/Linux installed, or you want to modify a root or boot partition, use GParted Live: http://gparted.sourceforge.net/livecd.php.

Using Parted
************

Introduction to Partitioning
============================

Partitioning is the process of dividing a storage device into local sections, called partitions, which help organize multiple filesystems and their associated operating systems.

A storage device presents itself as a sequence of bytes, numbered starting from zero and increasing until the maximum capacity of the device is reached. Bytes are normally read and written a sector at a time, rather than individually. Each sector contains a fixed number of bytes, with the number determined by the device.

     +------------------------------------------------------------+
     |            storage device with no partitions               |
     +------------------------------------------------------------+
     0 start                                                    end

In order to store multiple filesystems, a storage device can be divided up in to multiple partitions. Each partition can be thought of as an area which contains a real filesystem inside of it. To show where these partitions are on the device a small table is written at the start, shown as PT in the diagram below. This table is called a partition table, or disklabel, and also stores the type of each partition and some flags.

     +--+---------------+----------------+------------------------+
     |PT|  Partition 1  |  Partition 2   |  Partition 3           |
     +--+---------------+----------------+------------------------+
     0 start                                                    end

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.

Command Line Options
====================

When invoked from the command line, Parted supports the following syntax:

     # parted [OPTION] DEVICE [COMMAND [ARGUMENT]]

Available options and commands follow.  For detailed explanations of the use of Parted commands, see Command explanations. Options begin with a hyphen, commands do not:

Options:

-h
--help
     display a help message

-s
--script
     never prompt the user

-a alignment-type
--align alignment-type
     Set alignment for newly created partitions, valid alignment types are: none, cylinder, minimal and optimal.

-v
--version
     display the version

Parted Session Commands
=======================

GNU Parted provides the following commands:

Note that after version 2.4, the following commands were removed: check, cp, mkfs, mkpartfs, move, resize.

align-check
-----------

 -- Command: align-check ALIGN-TYPE N

     Determine whether the starting sector of partition N meets the disk's selected alignment criteria. ALIGN-TYPE must be minimal, optimal or an abbreviation. When in script mode, if the partition does not meet the alignment requirement, exit with status 1;  otherwise (including on older kernels for which alignment data is not available), continue processing any remaining commands. Without --script, print either N aligned or N not aligned.

     Example:

          (parted) align-check minimal 1
          1 aligned

disk_set
--------

 -- Command: disk_set FLAG STATE

     Changes a flag on the disk.  A flag can be either ``on'' or ``off''. Some or all of these flags will be available, depending on what disk label you are using:

     pmbr_boot
          (GPT) - this flag enables the boot flag on the GPT's protective MBR partition.

     The disk's flags are displayed by the print command on the "Disk Flags:" line.  They are also output as the last field of the disk information in machine mode.

          (parted) disk_set pmbr_boot on

     Set the PMBR's boot flag.

help
----

 -- Command: help [COMMAND]

     Prints general help, or help on COMMAND.

     Example:

          (parted) help mklabel

     Print help for the mklabel command.

mklabel
-------

 -- Command: mklabel LABEL-TYPE

     Creates a new disk label, of type LABEL-TYPE.  The new disk label will have no partitions.  This command (normally) won't technically destroy your data, but it will make it basically unusable, and you will need to use the rescue command (see Related information) to recover any partitions. Parted works on all partition tables.   (Everyone seems to have a different word for ``disk label'' --- these are all the same thing: partition table, partition map.)

     LABEL-TYPE must be one of these supported disk labels:

       * bsd

       * loop (raw disk access)

       * gpt

       * mac

       * msdos

       * pc98

       * sun

     Example:

          (parted) mklabel msdos

     Create an MS-DOS disk label.  This is still the most common disk label for PCs.

mkpart
------

 -- Command: mkpart [PART-TYPE NAME FS-TYPE] START END

     Creates a new partition, without creating a new file system on that partition.  This is useful for creating partitions for file systems (or LVM, etc.) that Parted doesn't support.  You may specify a file system type, to set the appropriate partition code in the partition table for the new partition.  FS-TYPE is required for data partitions (i.e., non-extended partitions).  START and END are the offset from the beginning of the disk, that is, the ``distance'' from the start of the disk.

     PART-TYPE is one of primary, extended or logical, and may be specified only with msdos or dvh partition tables. A NAME must be specified for a gpt partition table. Neither PART-TYPE nor NAME may be used with a sun partition table.

     FS-TYPE must be one of these supported file systems:

       * ext2

       * fat16, fat32

       * hfs, hfs+, hfsx

       * linux-swap

       * NTFS

       * reiserfs

       * ufs

       * btrfs

     For example, the following creates a logical partition that will contain an ext2 file system.  The partition will start at the beginning of the disk, and end 692.1 megabytes into the disk.

          (parted) mkpart logical 0.0 692.1

     Now, we will show how to partition a low-end flash device (``low-end'', as of 2011/2012). For such devices, you should use 4MiB-aligned partitions (Cheap flash drives will be with us for a long time to come, and, for them, 1MiB alignment is not enough. Use at least 4MiB-aligned partitions. For details, see Arnd Bergman's article, http://lwn.net/Articles/428584/ and its many comments.). This command creates a tiny place-holder partition at the beginning, and then uses all remaining space to create the partition you'll actually use:

          $ parted -s /dev/sdX -- mklabel msdos \
              mkpart primary fat32 64s 4MiB \
              mkpart primary fat32 4MiB -1s

     Note the use of --, to prevent the following -1s last-sector indicator from being interpreted as an invalid command-line option. The above creates two empty partitions.  The first is unaligned and tiny, with length less than 4MiB. The second partition starts precisely at the 4MiB mark and extends to the end of the device.

     The next step is typically to create a file system in the second partition:

          $ mkfs.vfat /dev/sdX2

name
----

 -- Command: name NUMBER NAME

     Sets the name for the partition NUMBER (GPT, Mac, MIPS and PC98 only). The name can be placed in quotes. And depending on the shell may need to also be wrapped in single quotes so that the shell doesn't strip off the double quotes.

     Example:

          (parted) name 2 'Secret Documents'

     Set the name of partition 2 to `Secret Documents'.

print
-----

 -- Command: print [NUMBER]

     Displays the partition table on the device parted is editing, or detailed information about a particular partition.

     Example:

          (parted) print
          Disk geometry for /dev/hda: 0.000-2445.679 megabytes
          Disk label type: msdos
          Minor    Start       End     Type      Filesystem  Flags
          1          0.031    945.000  primary   fat32       boot, lba
          2        945.000   2358.562  primary   ext2
          3       2358.562   2445.187  primary   linux-swap
          (parted) print 1
          Minor: 1
          Flags: boot, lba
          File System: fat32
          Size:            945.000Mb (0%)
          Minimum size:     84.361Mb (0%)
          Maximum size:   2445.679Mb (100%)

quit
----

 -- Command: quit

     Quits Parted.

     It is only after Parted exits that the Linux kernel knows about the changes Parted has made to the disks.  However, the changes caused by typing your commands will probably be made to the disk immediately after typing a command.  However, the operating system's cache and the disk's hardware cache may delay this.

rescue
------

 -- Command: rescue START END
     Rescue a lost partition that used to be located approximately between START and END.  If such a partition is found, Parted will ask you if you want to create a partition for it.  This is useful if you accidently deleted a partition with parted's rm command, for example.

     Example:

          (parted) print

          Disk geometry for /dev/hdc: 0.000-8063.507 megabytes
          Disk label type: msdos
          Minor    Start       End     Type      Filesystem  Flags
          1          0.031   8056.032  primary   ext3

          (parted) rm
          Partition number? 1
          (parted) print

          Disk geometry for /dev/hdc: 0.000-8063.507 megabytes
          Disk label type: msdos
          Minor    Start       End     Type      Filesystem  Flags

     OUCH!  We deleted our ext3 partition!!!  Parted comes to the rescue...

          (parted) rescue
          Start? 0
          End? 8056
          Information: A ext3 primary partition was found at 0.031MB ->
          8056.030MB.  Do you want to add it to the partition table?
          Yes/No/Cancel? y
          (parted) print

          Disk geometry for /dev/hdc: 0.000-8063.507 megabytes
          Disk label type: msdos
          Minor    Start       End     Type      Filesystem  Flags
          1          0.031   8056.032  primary   ext3

     It's back!  :)

resizepart
----------

 -- Command: resizepart NUMBER END

     Moves the END position of partition NUMBER.  Note that this does not modify any filesystem present in the partition.  If you wish to do this, you will need to use external tools, such as resize2fs.

     When growing a partition you will want to grow the filesystem afterwards, but when shrinking, you need to shrink the filesystem before the partition.

rm
--

 -- Command: rm NUMBER

     Removes the partition with number NUMBER.  If you accidently delete a partition with this command, use mkpart to recover it.  Also, you can use the gpart program (see Related information) to recover damaged disk labels.

     Note for msdos disk labels: if you delete a logical partition, all logical partitions with a larger partition number will be renumbered.  For example, if you delete a logical partition with a partition number of 6, then logical partitions that were number 7, 8 and 9 would be renumbered to 6, 7 and 8 respectively.  This means, for example, that you have to update /etc/fstab on GNU/Linux systems.

     Example:

          (parted) rm 3

     Remove partition 3.

select
------

 -- Command: select DEVICE

     Selects the device, DEVICE, for Parted to edit.  The device can be a Linux hard disk device, a partition, a software RAID device or LVM logical volume.

     Example:

          (parted) select /dev/hdb

     Select /dev/hdb (the slave device on the first ide controller on Linux) as the device to edit.

set
---

 -- Command: set NUMBER FLAG STATE

     Changes a flag on the partition with number NUMBER.  A flag can be either ``on'' or ``off''.  Some or all of these flags will be available, depending on what disk label you are using:

     bios_grub
          (GPT) - Enable this to record that the selected partition is a GRUB BIOS partition.

     legacy_boot
          (GPT) - this flag is used to tell special purpose software that the GPT partition may be bootable.

     boot
          (Mac, MS-DOS, PC98) - should be enabled if you want to boot off the partition.  The semantics vary between disk labels.  For MS-DOS disk labels, only one partition can be bootable.  If you are installing LILO on a partition that partition must be bootable. For PC98 disk labels, all ext2 partitions must be bootable (this is enforced by Parted).

     msftdata
          (GPT) - This flag identifies partitions that contain Microsoft filesystems (NTFS or FAT).  It may optionally be set on Linux filesystems to mimic the type of configuration created by parted 3.0 and earlier, in which a separate Linux filesystem type code was not available on GPT disks.  This flag can only be removed within parted by replacing it with a competing flag, such as boot or msftres.

     msftres
          (MS-DOS,GPT) - This flag identifies a "Microsoft Reserved" partition, which is used by Windows.  Note that this flag should not normally be set on Windows filesystem partitions (those that contain NTFS or FAT filesystems).

     irst
          (MS-DOS, GPT) - this flag identifies an Intel Rapid Start Technology partition.

     esp
          (MS-DOS, GPT) - this flag identifies a UEFI System Partition. On GPT it is an alias for boot.

     lba
          (MS-DOS) - this flag can be enabled to tell MS DOS, MS Windows 9x and MS Windows ME based operating systems to use Linear (LBA) mode.

     root
          (Mac) - this flag should be enabled if the partition is the root device to be used by Linux.

     swap
          (Mac) - this flag should be enabled if the partition is the swap device to be used by Linux.

     hidden
          (MS-DOS, PC98) - this flag can be enabled to hide partitions from Microsoft operating systems.

     raid
          (MS-DOS) - this flag can be enabled to tell linux the partition is a software RAID partition.

     LVM
          (MS-DOS) - this flag can be enabled to tell linux the partition is a physical volume.

     PALO
          (MS-DOS) - this flag can be enabled so that the partition can be used by the Linux/PA-RISC boot loader, palo.

     PREP
          (MS-DOS, GPT) - this flag can be enabled so that the partition can be used as a PReP boot partition on PowerPC PReP or IBM RS6K/CHRP hardware.

     DIAG
          (MS-DOS) - Enable this to indicate that a partition can be used as a diagnostics / recovery partition.

     The print command displays all enabled flags for each partition.

     Example:

          (parted) set 1 boot on

     Set the boot flag on partition 1.

unit
----

 -- Command: unit UNIT

     Selects the current default unit that Parted will use to display locations and capacities on the disk and to interpret those given by the user if they are not suffixed by an UNIT.

     UNIT may be one of:

     s
          sector (n bytes depending on the sector size, often 512)

     B
          byte

     KiB
          kibibyte (1024 bytes)

     MiB
          mebibyte (1048576 bytes)

     GiB
          gibibyte (1073741824 bytes)

     TiB
          tebibyte (1099511627776 bytes)

     kB
          kilobyte (1000 bytes)

     MB
          megabyte (1000000 bytes)

     GB
          gigabyte (1000000000 bytes)

     TB
          terabyte (1000000000000 bytes)

     %
          percentage of the device (between 0 and 100)

     cyl
          cylinders (related to the BIOS CHS geometry)

     chs
          cylinders, heads, sectors addressing (related to the BIOS CHS geometry)

     compact
          This is a special unit that defaults to megabytes for input, and picks a unit that gives a compact human readable representation for output.

     The default unit apply only for the output and when no unit is specified after an input number.  Input numbers can be followed by an unit (without any space or other character between them), in which case this unit apply instead of the default unit for this particular number, but CHS and cylinder units are not supported as a suffix.  If no suffix is given, then the default unit is assumed. Parted will compute sensible ranges for the locations you specify (e.g., a range of +/- 500 MB when you specify the location in ``G'', and a range of +/- 500 KB when you specify the location in ``M'') and will select the nearest location in this range from the one you wrote that satisfies constraints from both the operation, the filesystem being worked on, the disk label, other partitions and so on.  Use the sector unit ``s'' to specify exact locations (if they do not satisfy all constraints, Parted will ask you for the nearest solution).  Note that negative numbers count back from the end of the disk, with ``-1s'' pointing to the last sector of the disk.

     Note that as of parted-2.4, when you specify start and/or end values using IEC binary units like ``MiB'', ``GiB'', ``TiB'', etc., parted treats those values as exact, and equivalent to the same number specified in bytes (i.e., with the ``B'' suffix), in that it provides no ``helpful'' range of sloppiness.  Contrast that with a partition start request of ``4GB'', which may actually resolve to some sector up to 500MB before or after that point. Thus, when creating a partition, you should prefer to specify units of bytes (``B''), sectors (``s''), or IEC binary units like ``MiB'', but not ``MB'', ``GB'', etc.

     Example:

          (parted) unit compact
          (parted) print
          Disk geometry for /dev/hda: 0kB - 123GB
          Disk label type: msdos
          Number  Start   End     Size    Type      File system  Flags
          1       32kB    1078MB  1077MB  primary   reiserfs     boot
          2       1078MB  2155MB  1078MB  primary   linux-swap
          3       2155MB  123GB   121GB   extended
          5       2155MB  7452MB  5297MB  logical   reiserfs

          (parted) unit chs print
          Disk geometry for /dev/hda: 0,0,0 - 14946,225,62
          BIOS cylinder,head,sector geometry: 14946,255,63.  Each cylinder
          is 8225kB.
          Disk label type: msdos
          Number  Start       End         Type      File system  Flags
          1       0,1,0       130,254,62  primary   reiserfs     boot
          2       131,0,0     261,254,62  primary   linux-swap
          3       262,0,0     14945,254,62 extended
          5       262,2,0     905,254,62  logical   reiserfs

          (parted) unit mb print
          Disk geometry for /dev/hda: 0MB - 122942MB
          Disk label type: msdos
          Number  Start   End     Size    Type      File system  Flags
          1       0MB     1078MB  1077MB  primary   reiserfs     boot
          2       1078MB  2155MB  1078MB  primary   linux-swap
          3       2155MB  122935MB 120780MB extended
          5       2155MB  7452MB  5297MB  logical   reiserfs

Related information
*******************

If you want to find out more information, please see the GNU Parted web site.

These files in the Parted distribution contain further information:

  * ABOUT-NLS - information about using Native Language Support, and the Free Translation Project.

  * AUTHORS - who wrote what.

  * ChangeLog - record of changes made to Parted.

  * COPYING - the GNU General Public License, the terms under which GNU Parted may be distributed.

  * COPYING.DOC - the GNU Free Documentation Licence, the term under which Parted's documentation may be distributed.

  * INSTALL --- how to compile and install Parted, and most other free software

Copying This Manual
*******************

GNU Free Documentation License
==============================

     [file fdl.texi not included]

This manual's history
*********************

This manual was based on the file USER included in GNU Parted version 1.4.22 source distribution.  The GNU Parted source distribution is available at ftp.gnu.org/gnu/parted.

Initial Texinfo formatting by Richard M. Kreuter, 2002.

Maintainance by Andrew Clausen from 2002 to 2005 and by Leslie P. Polzer from July 2005 onwards.

This manual is distributed under the GNU Free Documentation License, version 1.1 or later, at your discretion, any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts.  See Copying This Manual, for details.