Using parted to create a new partition on an existing GPT partition table

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux

Issue

New disks have been added to a storage array. This was done in the storage directly, so that the new space is now seen by the system as unpartitioned space on the volume.
How to add a new partition to the system considering that the partition tabel is GPT?

Resolution

In parted specify the start of the new partition coinciding with the end of the preceding one. E.g.

(parted) print

Model: DELL MD3000 (scsi)
Disk /dev/sde: 9989GB
Sector size (logical/physical): 512B/512B Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags
1      17.4kB  6998GB  6998GB               primary

Create the new partition using all the available space with the following command:

(parted) mkpart primary 2048s -1s

It's best to start at 1MB (2048s) to ensure the partition is properly aligned, but this ultimately depends on the underlying hardware.

Note that using -1s as the END is equivalent as specifying the last sector of the disk.

Root Cause

Doing the same operation with fdisk is straightforward since it proposes the first usable value as the default starting sector of the new partition.
With parted it is unclear what value needs to be specified as START. However fdisk does not support GPT partiton tables.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments