Linux parted command
On Unix-like operating systems, the parted command creates, views, deletes, and modifies disk partitions.
Description
GNU parted is a disk partitioning and partition resizing program. It allows you to create, destroy, resize, move and copy ext2, linux-swap, FAT, FAT32, and reiserfs partitions. It can create, resize, and move Macintosh HFS partitions, as well as detect jfs, ntfs, ufs, and xfs partitions. It is useful for creating space for new operating systems, reorganising disk usage, and copying data to new hard disks.
Syntax
parted [options] [device [command [options...]...]]
Options
-h, –help | Display a help message, and exit. | ||||||||
-l, –list | Lists partition layout on all block devices. | ||||||||
-m, –machine | Displays machine-parseable output | ||||||||
-s, –script | Never prompts for user input. | ||||||||
-v, –version | Displays version information, and exits. | ||||||||
-a alignment-type, –align alignment-type | Set alignment for newly created partitions, valid alignment types are:
|
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:
|
Known Issues
ext3 filesystem functionality does not currently work. To manage ext3 type filesystems, use tools like resize2fs or mke2fs. Note that the currently supported ext2 filesystem will be deprecated once ext3 support is finalized. Further note that ext3 support has limited functionality that is yet to be defined. Use tools like resize2fs and mke2fs to manage these types of filesystems.
To manually resize an ext3 filesystem or a partition use resize2fs, fdisk or similar tools. For LVM situations, you will need to use the LVM commands to resize the LVM elements.
Examples
parted
Brings you into the parted command prompt, where you can enter any of the commands listed as above. Note that parted should be run as the superuser to gain the full hardware access it requires; so, for instance, you may need to run parted with the sudo command instead:
sudo parted
Once inside, you will be placed at a “(parted)” prompt, where you can enter any of the above commands to partition your hard disk, or the quit command to exit.
Related commands
fdisk — A disk partitioning utility.
mkfs — Build a Linux file system, usually a hard disk partition.