First, run the parted command to specify the block device:
sudo parted /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01
This opens a (parted) prompt where you can run commands without repeating the device path.
Then, create a new GPT partition table using mklabel:
Then, create partitions using the mkpart command. The partlabel flag specifies the partition name. Provide a name, or use "" to create the partition without a label. The start and end values define the partition boundaries.
mkpart <partlabel> <start> <end>
parted also supports multiple units. We recommend using percentages so parted aligns partitions properly. For example, to create one partition that spans the entire volume, run mkpart like this:
Then, create two equally sized partitions:
mkpart example1 0% 50%
mkpart example2 50% 100%
Then, exit parted with the quit command:
First, run the gdisk command using the volume identifier. gdisk scans the device and opens an interactive prompt.
sudo gdisk /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01
Then, create a new GPT partition table with the o command:
o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N):
Confirm the operation by typing Y. Then, create a new partition with the n command:
gdisk prompts you for the partition number, first sector, last sector or size, and partition type. Press ENTER to accept the default values.
Partition number (1-128, default 1):
First sector (34-209715166, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-209715166, default = 209715166) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'
When prompted for the last sector, you can alternatively specify a relative size using +. For example, entering +10G creates a partition that is 10 GiB in size instead of requiring you to calculate the ending sector manually:
Last sector (2048-209715166, default = 209715166) or {+-}size{KMGTP}: +10G
After you enter the size, gdisk confirms the partition type:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'
This creates a 10 GiB partition.
To review the partition table, run the p command:
gdisk displays the disk details and the current partition table, showing the new 10 GiB partition along with its start and end sectors, partition type, and other disk metadata like this:
Disk /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01: ...
...
Number Start (sector) End (sector) Size Code Name
1 2048 20973567 10.0 GiB 8300 Linux filesystem
To write the changes and exit, enter the w command:
w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N):
gdisk displays a final warning that writing the GPT data overwrites existing partitions and prompts you to confirm. Enter Y to confirm. gdisk writes the new partition table to disk and exits.