Create partition using parted utility on Linux machine

From AcrodusWiki

Parted is a tool/utility used by linux machines to manipulate partitions on a block device.

To list currently attached disk volumes use the command:

sudo parted -l

To select the disk to partition use the command:

sudo parted sdx (x being the disk you want to format, stay away from the disk that has the bootloader and rootfilesystem on)

You will now be in the parted shell.

Create a partition table with the command:

(parted) mklabel gpt/msdos

Make sure it is unmounted. This can be done with the umount command in the terminal or within the parted shell prompt. Use print command at any time to show changes. To actually make the partition run the command:

(parted) mkpart

This will then ask to be the primary of extended partition. As well as the file system that will be implemented on the partition and the start and end location of the partition. This value is given in MB so for 8GB it should be 8000. Verify with print command.

This has successfully created the partition however the filesystem has not yet been configured. To do this the mkfs utility is required. See Create fs using mkfs utility on Linux machine.