VMware ESXi and vSphere Cluster Management

GNU Parted Utility: List, Create, and Delete Linux Disk Partitions

Learn how to use GNU Parted to inspect partition tables, create and delete Linux partitions, choose safe boundaries, and prepare new partitions for mounting.

GNU Parted is an interactive, text-based Linux utility for viewing and editing disk partition tables. It works with whole disk devices such as /dev/sda, not merely with individual partition paths, and changes the metadata that defines where partitions begin and end.

Partition-table management is different from filesystem management. Parted can create a partition entry, but it does not normally create a usable filesystem inside that partition. Afterward, you may need an appropriate mkfs command and then mount.

Important safety rules

  • Identify the target disk by comparing its device name, size, model, and existing partitions.
  • Review the current layout with tools such as lsblk and Parted's print command.
  • Confirm that the proposed range is genuinely unallocated before creating a partition.
  • Do not change the layout of partitions that are actively mounted. Unmount them and stop services that use them when practical.
  • Use explicit units such as MiB or GiB to avoid ambiguous boundaries.
  • Before rm, verify both the partition number and the backup status.

Partition tables and disk terminology

A partition table is disk metadata that records partition boundaries, identifiers, and attributes. A partition is a defined range of disk sectors. A filesystem, such as ext4 or XFS, is the structure inside a partition that organizes files and directories. A mount point is a directory through which Linux makes a filesystem available.

GNU Parted commonly works with these disk-label formats:

  • MBR/DOS: a legacy scheme with a limited primary-partition model.
  • GPT: a modern scheme designed for large disks and many partitions.
  • Apple Partition Map (APM): a format associated with older Apple systems.
  • BSD disk labels: a disk-label format used by BSD-derived systems.

MBR and GPT partition models

Disk labelPartition modelExtended partition supportKey planning note
MBR/DOSPrimary, extended, and logical partitionsYesAn extended partition is a container for logical partitions; it is not normally a data filesystem partition itself.
GPTRegular GPT partitionsNoGPT does not use the primary, extended, or logical distinction.

On an MBR disk, a primary partition is directly represented in the partition table. An extended partition provides a container for one or more logical partitions. On GPT, create ordinary GPT partitions instead of requesting extended or logical types.

Identify the correct disk first

Linux represents storage devices with device nodes under /dev. Examples include /dev/sda for a disk and /dev/sda1 for one of its partitions. Names vary: a system may use SATA-style names such as /dev/sda, NVMe names such as /dev/nvme0n1, or other device naming schemes.

lsblk -f

Review the disk size, partition paths, filesystem types, UUIDs, and mount points. Do not assume that /dev/sda is the correct device merely because it is a familiar example. A removable drive, virtual disk, or another physical disk may have a different name.

Launch an interactive Parted session

Open Parted against the whole disk with elevated privileges:

sudo parted /dev/sda

Replace /dev/sda with the verified target disk. When Parted starts, it presents its own prompt. The exact prompt text can vary by version, but commands such as print, unit, mkpart, rm, and quit are entered there.

Use the disk path when editing its partition table. Do not substitute a partition path such as /dev/sda1 for a whole-disk operation.

Inspect the existing layout with print

At the Parted prompt, run:

print

The output typically includes:

  • the disk path and total disk size;
  • the partition-table type, also called the disk label, such as gpt or msdos;
  • each partition's number;
  • start and end positions;
  • partition size;
  • a filesystem hint, when one is detected;
  • flags such as boot- or ESP-related attributes.

The partition number in this output is the number later supplied to rm. It is not the same as choosing a device name by guesswork. Run print before creation or deletion so you know which ranges are occupied and which are unallocated space.

Use explicit units

Parted can display and accept positions using units such as MiB, GiB, MB, or GB. Historical or default output may use megabyte-oriented values, which can make boundaries difficult to compare. Set an explicit unit at the prompt:

unit MiB
print

Using an explicit unit makes start and end positions easier to read and reproduce. Storage alignment also matters: suitable sector boundaries can improve performance and compatibility. Let Parted use its normal alignment behavior where possible, and inspect the resulting boundaries rather than selecting arbitrary offsets.

Create a partition with mkpart

The mkpart command creates a partition-table entry over a specified range. Depending on the disk-label type and Parted version, its arguments can include a partition type, an optional filesystem-type hint, and start and end positions.

Creation is possible only when the requested range fits entirely within one contiguous unallocated region. The range must not overlap an existing partition. A filesystem hint helps describe the intended use, but it does not format the partition.

MBR extended-partition example

On an MBR/DOS disk, this example requests an approximately 3 GiB extended partition from 1024 MiB through 4096 MiB:

unit MiB
mkpart extended 1024MiB 4096MiB

This range is illustrative only. It is safe to use only if print shows that the entire interval is unallocated on the selected MBR disk. The extended partition is a container; logical partitions would be created inside it. It is not itself the ordinary data filesystem that you would normally mount.

Parted versions can ask additional questions or accept slightly different syntax, especially when selecting a filesystem-type hint. Read the prompt and confirm that the requested partition type and boundaries match your plan.

GPT partition creation

GPT does not support the MBR primary/extended/logical model. Create a regular GPT partition in a free range instead. For example, a filesystem hint may be supplied when supported by the installed Parted version:

unit MiB
mkpart data 4096MiB 7168MiB

Here, data is a descriptive partition name in contexts where Parted accepts one; it is not a filesystem. Confirm the exact prompt and syntax for the installed version. The essential requirements remain the same: use a free contiguous range, choose suitable aligned boundaries, and verify the resulting layout.

Delete a partition with rm

To remove a partition-table entry, use rm followed by the partition number shown by print:

rm 3

This removes partition number 3 from the current disk's partition table. It can make the contents of that partition unavailable, even if the data sectors have not immediately been overwritten. Never infer the number from a remembered device name; run print, identify the exact intended entry, and confirm your backup first.

After deletion, inspect the revised layout:

print

The former partition range should now appear as unallocated space, subject to the disk-label format and Parted's display.

Common Parted commands

CommandPurposeExample useRisk or caution
printShow disk information, partition entries, and free spaceprintRead it carefully before every change.
unitChoose display and input unitsunit MiBUnits reduce ambiguity, but boundaries still must fit available space.
mkpartCreate a partition-table entrymkpart extended 1024MiB 4096MiBIncorrect ranges can overlap data or create an unusable layout.
rmRemove a partition-table entryrm 3Can make the partition's contents inaccessible.
quitLeave the interactive sessionquitQuitting does not undo changes already accepted.

Apply changes and leave Parted

Partition-table changes are applied as Parted accepts the operations. Use the normal exit command after reviewing the result:

quit

quit is not a rollback mechanism. If you create or remove a partition and then quit, the accepted change remains. The operating system may also need to re-read the changed partition table before new or modified device nodes are fully recognized. If tools do not immediately show the result, refresh partition information with an appropriate system tool, then check again with lsblk. Resolve mounted or otherwise busy partitions before retrying.

Prepare a new partition for use

A newly created partition generally has no filesystem. After verifying the new device path, create the intended filesystem. For an ext4 data partition, an example is:

sudo mkfs.ext4 /dev/sda3

Create a mount directory and mount the filesystem:

sudo mkdir -p /mnt/data
sudo mount /dev/sda3 /mnt/data
lsblk -f

Use the filesystem appropriate for the workload and distribution. For a persistent mount across reboots, configure an entry using the filesystem's UUID rather than relying only on a changeable device name. Obtain the UUID with lsblk -f or another block-device inspection tool, and test the configuration carefully before rebooting.

Safe operational workflow

StepActionResultVerification
Identify diskInspect block devices and confirm the target by size, model, and layoutThe correct whole-disk device is knownlsblk -f
Inspect layoutOpen Parted and run unit MiB followed by printDisk label, partition numbers, boundaries, and free ranges are clearCompare output with the intended plan
Create or delete partitionUse mkpart or verified rmThe requested partition-table change is acceptedReview Parted's response
Confirm layoutRun print again and exit with quitThe new partition or unallocated range is visibleCheck with print and lsblk
Create filesystemRun the appropriate mkfs command when neededThe partition can organize ordinary fileslsblk -f
Mount filesystemMount it at a valid directory and test reads and writesThe storage is available to Linux applicationsCheck the mount point and run a controlled test

Troubleshooting

The wrong disk was selected

Similar device names or skipping the inspection step can lead to the wrong target. Stop before making changes, compare disk size and existing partitions with lsblk and Parted's print, and reopen Parted on the verified disk. If changes have already been made, avoid further writes and restore from backup where possible.

mkpart rejects the requested range

The start or end may overlap an existing partition, fall outside the disk, or leave no suitable contiguous free space. Run print, locate one actual unallocated range, and choose boundaries entirely within it.

Extended or logical creation fails

The disk may use GPT. Extended and logical partitions are MBR concepts, so create a regular GPT partition instead. Change the disk-label scheme only after carefully planning a backup and migration, because converting labels can destroy the existing partition layout.

The new partition is not visible

The kernel may not yet have re-read the partition table, or a partition may still be mounted or otherwise in use. Refresh partition information with an appropriate system tool, recheck with lsblk, and resolve busy devices before repeating an operation.

The partition cannot be mounted

Check that the partition path is correct and that a filesystem exists. A missing filesystem, wrong partition selection, or missing mount directory can all cause failure. Inspect with lsblk -f, create the intended filesystem if appropriate, create the mount directory, and mount again.

A partition was deleted accidentally

Stop normal write activity on the disk. Do not create new partitions or filesystems over the affected range. Restore from a verified backup where possible; otherwise, treat recovery as a specialized task rather than continuing ordinary partition operations.

Exam-relevant notes

  • Parted edits partition tables; it does not automatically create a filesystem merely because a partition was created.
  • print supplies the partition number used by rm.
  • quit exits Parted but does not undo accepted changes.
  • MBR supports primary, extended, and logical partition concepts; GPT does not use that model.
  • An extended MBR partition is a container for logical partitions, not normally the final mounted data partition.
  • Start and end values must fit inside unallocated space and should use suitable alignment.
  • A device node such as /dev/sda1 represents a partition, while /dev/sda represents the whole disk in this example.

For a concise reference, return to the GNU Parted utility guide after identifying the disk and confirming your backup.