HDD preparation

HDD preparation

Here are the steps to prepare a brand new hard drive and install a file system on it.

Setting up partitions

Partitions can be managed using parted:

sudo parted

Creating a partition table

A partition table stores information about the partitions of the drive. It can be created using:

mklabel

GPT is the current standard for label types.

New disk label type? gpt

Creating a partition

The command mkpart can be used to create partitions on the disk

mkpart

Note that the partition name is not the label of the partition's file system

Partition name?  []? primary

Among the various existing file systems, ext4 is the most convenient for Linux

File system type?  [ext2]? ext4

Define the size of the partition

Start? 2048s                                                              
End? 100%

Creating a file system in a partition

Replace MY_LABEL by the label to be used for the file system

mkfs.ext4 -L MY_LABEL /dev/sda1