1

The Azure tutorial Use the portal to attach a data disk to a Linux VM shows the following command to prepare a disk:

sudo parted /dev/sdc --script mklabel gpt mkpart xfspart xfs 0% 100%

Looked at the parted man page to make sure what I'm doing, and it states that

mkpart [part-type name fs-type] start end
   Create a new partition. part-type may  be  speci‐
   fied only with msdos and dvh partition tables, it
   should be one of "primary",  "logical",  or  "ex‐
   tended".   name is required for GPT partition ta‐
   bles and fs-type is optional.  fs-type can be one
   of  "btrfs",  "ext2",  "ext3",  "ext4",  "fat16",
   "fat32",  "hfs",  "hfs+",  "linux-swap",  "ntfs",
   "reiserfs", "udf", or "xfs".

Unless I'm misinterpreting it, part-type is required when using the mkpart command with parted, and its value should be one of the three listed.

So why does the command in the Azure tutorial work?

toraritte
  • 1,080

1 Answers1

1

This answer shows that things are not so black and white, but the Arch wiki page on parted answer this beautifully in section "4.2 Partition schemes" (emphases mine):

  • part-type-or-part-label is interpreted differently based on the partition table:

    • MBR: the parameter is interpreted as part-type, which can be one of primary, extended or logical.

  • GPT: the parameter is interpreted as part-label, which sets the PARTLABEL attribute of the partition. The partition label always has to be set, since mkpart does not allow to create partitions with empty label.

    NOTE: Many tutorials on the web use commands which start with mkpart primary even for GPT. They are wrong, this would set "primary" as the partition label.


The man page snippet in the question is beautifully explained in this answer. For example, part-type isn't even required and partitions can have empty strings as names.

toraritte
  • 1,080