How to Format Drive in Linux?

Partitioning and formatting a disk drive in Linux is an important task for Linux system administration. Both serve as valuable tools for addressing a range of scenarios, including preparing storage media for utilization, managing space limitations on current drives, and securely wiping a filesystem.

In this guide, we will learn how to format a drive in Linux. In addition, we will go through the steps on how to create disk partitions and mount partitions to a specific path in your Linux system. 

Linux Format Disk

Formatting a disk is a process for preparing a storage partition for disk space utilization. If you often handle substantial data assets, like working with Linux video editing software and storing numerous large files with different filesystems, it is important to understand how to free up disk space by mastering the art of how to format a drive in Linux. 

FileSystems for Linux

Below, we listed popular filesystems for Linux:

  • Ext4 serves as the default filesystem for many modern Linux distributions, accommodating files up to 16TB in size and volumes of up to 1EB. In contrast, Windows does not provide default support for Ext4.
  • Microsoft's well-known filesystem is NTFS, capable of handling file sizes and volumes of up to 8PB. Full NTFS compatibility was introduced with Linux kernel version 5.15.
  • Despite being considered outdated, FAT32 is still occasionally employed, supporting files of up to 4GB in size and volumes of up to 2TB. It's compatible with various *nix and Windows operating systems.

how to format drive in linux?

Linux Partition Disk

Partitioning creates logical storage boundaries on devices like HDDs and SSDs. In Linux, a disk partition is useful for managing file systems and hosting multiple OS installations on a single drive.

How to Format a Hard Drive in Linux 

You can format the drive in Linux using the two methods that we cover in detail below!

Linux Format Drive Using the Command Line (gdisk Utility)

Several format disk and command line tools are available to format a drive in Linux. However, we will use the “gdisk” command line tool for Linux to partition a disk. This tool is installed on almost all major Linux distributions. So, open the terminal by pressing “Ctrl+Alt+t” and follow the steps below to format the hard drive in Linux.

Step 1: Select a Drive to Format 

First, choose a disk that you want to format. However, most users are confused about how to identify the disk drive that requires formatting. So, search for a name beginning with “/dev/sd” followed by a letter. You can also use the “fdisk” command with grep in the terminal to filter results:

$ sudo fdisk -l | grep “Disk /”

The following output should display on your terminal window:

how to format drive in linux?

Step 2: Create a New Linux Partition for Disk

Now, we will create the partition on the device path “/dev/sda.” To create a new disk partition on this empty drive, we will specify it as an argument to “gdisk:”

$ sudo gdisk /dev/sda

how to format drive in linux?

Now, enter a command that requires the “gdisk” utility. As we are creating a new partition, type “n” and hit “Enter.”

Next, enter the partition number; you can choose from 4 to 128. But here, we will proceed with the default number. Then, it will ask about the first and last disk sectors that determine the actual size of a disk partition. Here, we will create a single partition. So, accept the default values and press “Enter.”

Now, commit or write all changes to the disk. To do this, type the “w” command that will commit all changes on disk and press “y” to proceed.

how to format drive in linux?

Step 3: Format Disk with Ext4

For this step, you will format the disk partition to any filesystem. First, list all disks using the following command: 

how to format drive in linux?

To format a hard drive in Linux, use the “mkfs” command. Here, we will format the disk using the ext4 filesystem.

$ sudo mkfs -t ext4 /dev/sda1

how to format drive in linux? 

Step 4: Mount Partition

Now, mount the formatted partition on your Ubuntu system. You can mount it using the “mount” command:

how to format drive in linux?

As you can see in the image above, we have mounted our disk drive to the “/var/bluevps” directory. Again, see the changes using the following command:

$ lsblk /dev/sda

how to format drive in linux?

Linux Format Disk Using Graphical User Interface (GParted Tool)

GParted is a free and open-source disk partitioning tool used for managing partitions of your system graphically. You can install and use GParted on different Linux distributions, including Ubuntu. This tool allows you to move, copy, and resize Linux disk partitions without losing your data. The GParted tool also enables you to carry out several operations, such as shrinking or growing C: drive to create some extra space for your OS, keeping data safe from lost partitions, and formatting the disk in Linux.

In this section, we will go through the steps to install GParted disk partition software on the Ubuntu 22.04 Jammy Jellyfish distribution.

How to Install GParted on Ubuntu 22.04?

You can easily install GParted on the Ubuntu system using the default Apt repository. To install it, follow the below-mentioned steps:

Step 1: Update Apt Packages Index

It is recommended to refresh all Ubuntu apt repositories before installing a new software or application package on your Linux system. So, update the packages index using the “apt update” command:

$ sudo apt update

Step 2: Install GParted on Ubuntu 22.04

To install GParted on Ubuntu 22.04, you don't need to include any external repository. Therefore, you can install it on your system using the following command:

$ sudo apt install gparted

how to format drive in linux?

Type “y” and hit “Enter” to continue the installation on Ubuntu 22.04.

Step 3: Launch GParted

Launch GParted on your Ubuntu distribution using the application search bar. To do this, click on “Activities” and type the application name “gparted” in the search bar. You will see the application icon in the search result as follows:

how to format drive in linux?

Click on the application icon to launch GParted on your desktop. When you launch it first on your Ubuntu system, you will need to enter the sudo or root password to verify your authentication. Once you enter your root password, click on “Authenticate.” 

how to format drive in linux?

After that, the following GParted graphical interface will show on your desktop:

how to format drive in linux?

In the screenshot above, you can see the Linux partition disk name, size, disk utilization information about used and unused disk space, disk partition file system, and disk mount point paths.

You can perform several operations on your device partitions. Below, we will see how to format a hard drive in Linux using GParted software.

Linux Format Disk Using GParted Tool

Once the GParted tool is installed, perform the following steps to format a disk on Linux using GParted software:

Step 1: Choose the Correct Hard Disk

The initial step is to choose the appropriate device with which we will be working, located in the upper right corner. This device is “/dev/sda1” on this Ubuntu system, as shown in the screenshot below:

how to format drive in linux?

Step 2: Create a Partition Table

We have selected a disk that currently has no partitions. To create a partition, click on “Device” and choose “Create Partition Table.” Then, select the partition type that you would like to create on your system. Here, we will use the “gpt” that is suitable for large hard disk volumes greater than 2TB. But you can select something else based on your requirements. 

how to format drive in linux?

Step 3: Add a New Linux Partition Disk

After creating the partition table, you can proceed to add a new disk partition. To access this option, move into “Partition” and then click on “New.” Here, you will need to choose the new partition size. Instead of entering the precise numbers, you can choose the Linux partition disk size using a mouse slider. We will be creating a single disk partition that will only cover the entire disk space. Click on “Add” to continue further.

how to format drive in linux?

Step 4: Write Changes to the Disk

The changes you have made are not yet written to the disk at this point. However, you can review the configurations which you have applied. Now, click on “Edit”  and choose “Apply All Operations” to write the changes on the disk.

how to format drive in linux?

Step 5: Mount Partition 

Once you commit all changes, open the GUI disk application on your system and select the Linux partition disk that you have created above. Mount this partition and choose a path carefully so that it will be accessible to you.

Conclusion

In this tutorial, we learned how to format a hard drive in Linux and how to create a partition on disk on the Ubuntu 22.04 system. Linux disk partition and formatting tools are helpful for users and Linux system administrators to manage disk partitions on a Linux system. If you are using a remote VPS Linux server, following the guidelines above will also help you create a partition and format a disk on a Linux VPS server. Thanks!