How to format disk using parted command

Partition using parted command


The fdisk command won’t create partitions larger than 2 TB so you cannot use fdisk to create partition. In this case, you can use parted command to format the disk.

NOTE: You can use fdisk command for 2TB drive, here I’m using 2TB for testing purpose.


Check the available free disk using “lsblk” , “df -h” commands and make sure that the drive is not mounted anywhere.

# lsblk

#df -h

free disk is /dev/sdb

 

Use parted command and disk name to create partition

#parted /dev/sdb

(parted) print
Model: Seagate Expansion (scsi)
Disk /dev/sdb: 2.00TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags

 

In below step, all the datas will be erased so make sure there is no important datas on the disk.

(parted) mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes

 

Mention units in TB

(parted) unit TB

 

Mention start and end size of the partition

(parted) mkpart primary 0.00TB 2.00TB

 

Print command to display created partitions

(parted) print
Model: Seagate Expansion (scsi)
Disk /dev/sdb: 2.00TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 0.00TB 2.00TB 2.00TB primary

 

Enter quit to save and exit

(parted) quit
Information: You may need to update /etc/fstab.


 

In case of any mistake you can remove the existing partitions with “rm” command and re-create it as mentioned above.

(parted) print
Model: Seagate Expansion (scsi)
Disk /dev/sdb: 2.00TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 0.00TB 2.00TB 2.00TB primary

(parted) rm 1


 

Thank you