parted
A partition manipulation program.
List Partitions
List all partitions on all devices.
parted -l
Select Device
Start parted interactive mode on a specific device.
parted [device]
Create Partition Table
Create a new GPT partition table (Warning: Erases all data).
parted [device] mklabel gpt
Create a new MBR (msdos) partition table.
parted [device] mklabel msdos
Create Partition
Create a primary partition from 0% to 100% of the disk.
parted [device] mkpart primary ext4 0% 100%
Resize Partition
Resize partition 2 to end at 32GB.
parted [device] resizepart 2 32GB
Resize partition 2 to use all available space.
parted [device] resizepart 2 100%
Note: After resizing the partition, you need to resize the filesystem:
- For ext4:
resize2fs [device]2 - For xfs:
xfs_growfs /mount/point
Delete Partition
Delete partition 1.
parted [device] rm 1
Set Flag
Set the boot flag on partition 1.
parted [device] set 1 boot on
Align Check
Check alignment of partition 1.
parted [device] align-check optimal 1