There are some great tools available on Linux to format and partition hard drives and other media. GParted is probably one of the best known tools out there. It has great functionality but it is a GUI application. In command line the options get thinner and more convoluted. Several older tools and commands don’t like GPT partitioning tables and so will not function properly. GPT partition tables are also needed to make use of hard drives larger than 2 TB.
Locate the Storage Device
List connected physical devices.
sudo fdisk -l
GPT is not supported so it will only display partial information. It can still be used to display the capacity and device node information to help locate the desired device.
List disk devices with label, UUID and type information.
List existing partitions, mount points and disk capacity.
Partition with Parted
Install parted with pacman.
sudo pacman -S parted
Start parted against the device to be partitioned.
sudo parted /dev/sd?
Double check that
/dev/sd? is replaced with the correct device before proceeding to execute irreversible commands.
Create a partition table (disk label in parted).
Enter the the type of partitioning table. This should be
gpt in most cases especially for devices larger than 2 TB.
Create a primary partition that uses the full capacity of the drive use one of the following commands.
mkpart primary 0% 100%
System drives should be marked as
logical while storage drives should be marked
primary. The second and last arguments are the start and end of the partition respectively. Start and end can be specified in a number of ways such as sectors, percentages, units of capacity or any combination of these units. To start the partition at the beginning of the hard drive specify the first sector which can be expressed as
0.00TB. To use the entire capacity of the hard drive set the end of the partition on the last sector which can be expressed as
6.00TB. The simplest option is to use percentage values as then the sectors are optimized automatically.
Right now we have a partitioned disk but we can’t access it until it is formatted with a suitable file system. Parted only supports
reiserfs (if libreiserfs is installed) file systems. None of them are particularly useful in most scenarios these days. We will need yet another tool which will depend on your choice of file system. In most circumstances
ext4 filesystem will be the best choice under Linux.
Format with ext4 filesystem.
sudo mkfs.ext4 /dev/sd?1
There should not exist a functional
ext4 formatted partition spanning the entire storage device. The partitioned and formatted devices need to be mounted before use.