FreeKB - Linux Commands parted (format disk partition)
Linux Commands - parted (format disk partition)

Formatting a storage device typically involves the following steps. This article includes the directions for steps 1 and 2.

  1. Create one or more partitions
  2. Assign a type to the partition
  3. Format each partition to use a certain type of file system

The fdisk command partitions a drive as MBR (master boot record). The gdisk command partitions a drive as GPT (GUID partition table). The parted command can partition a drive as either MBR or GPT. MBR is typically needed for systems with old hardware or software, because GPT is not backwards compatible with old hardware or software. gdisk or parted can be used if the system is using modern hardware and software. GPT is typically used if you need a create a partition greater than 2 TB.

In this example, we will create a new primary partition on the third storage device /dev/sdc.

  1. In Terminal, type parted and press enter
  2. Type select /dev/sdc and press enter to partition the third SATA/SCSI drive
  3. Type print and press enter to view a summary of /dev/sdc
  4. If we want to set use GPT (GUID partition table) instead of MBR, type mklabel GPT and press enter
  5. Type mkpart partition_type filesystem_type start end and press enter (example: mkpart primary 0GB 2048GB)

Notice filesystem_type was not specified. For example, ext2 or ext4 was not included in the mkpart command. Parted cannot create ext3 or ext4 file systems. fdisk, gdisk, or the mkfs command can be used to create an ext3 or ext4 file system on a drive.

Or, here is a one liner.

parted -s /dev/sdb set 1 lvm on


The gparted command can be used to use an GUI instead of the Terminal. The OS must be using runlevel 2 (Debian) or 5 (Red Hat).

Use the partprobe command to update the system to recongize the new partition.

~]# partprobe

Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter d64b3 in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   |