fbpx Parted on Linux: Create and Manage GPT and MBR Partitions | Certificação Linux

Partition and Resize Disks with Parted on Linux

📅 01/01/2019 ⏱ 3 min ✍️ Uira Ribeiro
Linuxcommands
Partition and Resize Disks with Parted on Linux
Exam Pass App — mais de 7.000 questões LPI, offline, em 5 idiomas, disponível no Android e na App Store
Available on
Google Play
Available on
App Store

The parted command in Linux was developed to partition and resize disk partitions. It allows you to create, destroy, resize, move, and copy partitions of type ext2, Linux-swap, FAT, FAT32, reiserFS and HFS. It is very useful for reorganizing disk usage, as well as copying data to new disks.

Its use is for more experienced users, since it can create partitions directly at the shell prompt.

If no command is provided as a parameter, parted will show its own command prompt.

The commands can be:

mklabel label-type
Creates a new partition table, which can be of type "aix", "amiga", "bsd", "dvh", "gpt", "loop", "mac", "msdos", "pc98", or "sun".

mkpart part-type [fs-type] start end
Creates a partition.
The part-type can be "primary", "logical", or "extended".
The fs-type specifies the file system type, which may or may not be provided. The accepted file system types are: "btrfs", "ext2", "ext3", "ext4", "fat16", "fat32", "hfs", "hfs+", "linux-swap", "ntfs", "reiserfs" and "xfs".
The start parameter defines the beginning of the partition. It is an integer followed by a unit.
The end parameter defines the end of the partition. It is an integer followed by a unit.
The unit can be the letter "s" for Sector, if the number provided is a sector on the disk, or "B" to indicate the beginning and end of the partition in Bytes. It is also possible to define the beginning and end of partitions in binary units such as "MiB", "GiB" and "TiB".

name name
This command allows you to give a name to the partition. It can only be used on partition tables of type Mac, PC98, and GPT.

print
Shows information about a partition.                 

To create a GPT partition table on disk /dev/xvdb:

$ parted /dev/xvdb mklabel gptAviso: The existing disk label on /dev/xvdb will be destroyed and all data on this disk will be lost. Do youwant to continue?Sim/Yes/Não/No? Yes                                                       

After creating the partition table, you can create the partition:

# parted /dev/xvdb  mkpart primary btrfs 1MiB 100%Informação: You may need to update /etc/fstab.

Parted also allows you to view the newly created partition with the print command:

# parted /dev/xvdb printModel: Xen Virtual Block Device (xvd)Disk /dev/xvdb: 8590MBSector size (logical/physical): 512B/512BPartition Table: gptDisk Flags: Number  Start   End     Size    File system  Name     Sinalizador 1      1049kB  8589MB  8588MB               primary

Learn much more about Linux in our online course. You can enroll here. If you already have an account, or want to create one, just log in or create your user here.

Did you like it? Share

Uira Ribeiro

Prof. Uirá Ribeiro

Chair do Board do Linux Professional Institute

After years of watching professionals waste hours on simple tasks because they didn't know the right Linux tools, I decided to teach.
Today I'm the author of most of LPI's official Learning Materials and mentor to over 14,000 certified students.

See my full story →

That was just one piece. The course teaches the whole path — from your first command to exam day.

Certificação Linux — a plataforma líder em certificações Linux no Brasil
WhatsApp