After formatting the partition, you can verify the result using several methods:
Table of Contents
- 1 What is a Disk Drive?
- 2 What is Disk Partitioning?
- 3 How to Partition Disk Drive on Linux
- 4 What is Disk Formatting?
- 5 How to Format a Disk Drive on Linux
- 6 Wrapping Up: Disk Partitioning and Formatting
- 7 FAQs on Partitioning and Formatting Disk Drives on Linux
- 7.1 What is the difference between partitioning and formatting?
- 7.2 How do I know which file system to choose?
- 7.3 Can I resize partitions without losing data?
- 7.4 What tools are recommended for disk management on Linux?
- 7.5 Is it safe to format a disk drive?
- 7.6 How do I recover data from a formatted drive?
- 7.7 What are primary, extended, and logical partitions?
- 7.8 How do I check disk space usage on Linux?
- 7.9 Can you partition a drive without formatting?
What is a Disk Drive?
Yes, you can. Partitioning simply creates the divisions on the disk. Formatting is a separate step that creates a file system within a partition to make it usable by an operating system. You might partition a disk and leave some partitions unformatted for later use or different purposes.Ready to experience the ease of Linux server management? Start your free trial with RunCloud today!

Types of Disk Drives
Suggested read: How to Kill a Process in Linux From the Command Line
- Hard Disk Drives (HDDs): HDDs store data on spinning magnetic platters and use a read/write head that moves across the surface. They are a cost-effective option for large storage capacities, but their mechanical nature results in slower access times.
- Solid-State Drives (SSDs): SSDs use flash memory to store data, eliminating moving parts and providing significantly faster read/write speeds than HDDs. This results in faster boot times, application loading, and overall system responsiveness, although typically at a higher cost per gigabyte.
- NVMe SSDs (Non-Volatile Memory Express SSDs): NVMe SSDs are a type of SSD that uses a high-speed PCIe interface. They deliver even greater performance than standard SATA SSDs. This interface allows for much higher bandwidth and lower latency, making them ideal for demanding workloads.
Use the lsblk command in your terminal to list all block devices and their partitions. Carefully examine the output, paying attention to the NAME, SIZE, TYPE, and MOUNTPOINT columns.
What is Disk Partitioning?
Managing Linux servers, especially tasks like disk partitioning and monitoring, can seem daunting. However, with tools such as RunCloud, the process becomes significantly easier and more streamlined.You’re looking for a disk (indicated by TYPE being “disk”) that is not currently mounted (has no MOUNTPOINT) or is a disk you are sure you want to repartition (which results in losing all data stored on it). The NAME will typically be something like /dev/sda, /dev/sdb, /dev/nvme0n1, etc.RunCloud provides a user-friendly web interface that simplifies server management tasks, including monitoring disk usage, managing services, and deploying applications. Instead of wrestling with the command line for every operation, you can use RunCloud’s intuitive dashboard to oversee your server’s health and performance. This allows you to focus on your applications and websites rather than getting bogged down in the complexities of server administration.
How to Partition Disk Drive on Linux
Disk formatting prepares a storage device (the whole disk or a partition) for use by an operating system. This process creates a specific file system – a structured method for organizing and storing files. The operating system uses this file system to manage data on the device. Formatting lays the groundwork that defines how the operating system will track files, directories, and free space.
Step 1: Identify the Disk
Yes, but it’s risky and requires careful planning. Tools like parted, GParted, and GNOME Disks allow resizing, but always back up your data first. Shrinking a partition is generally safer than expanding it, especially if the partition being expanded is at the end of the disk. If free space isn’t directly adjacent to the partition you’re expanding, data movement is required, increasing the risk of data loss if interrupted.Before partitioning a disk, you need to identify the correct device name. Use the lsblk command in your terminal to list all block devices (disks and partitions) connected to your system.

The df (disk free) command is the primary tool. df -h displays usage in human-readable format (e.g., GB, MB). You can also use du (disk usage) to see the size of specific directories and files. GNOME Disks provides a graphical view of disk space.Be absolutely certain you have the correct device name – partitioning the wrong disk will result in data loss.A disk drive, also known as a storage drive, is a non-volatile storage device for a computer. This device retains data even when the system loses power. The drive stores the operating system, applications, and user data, and the computer uses it to both read and write data.If the partition you intend to format is currently mounted (meaning it’s accessible as a directory), you must unmount it before formatting. Use the umount command followed by either the device name or the mount point. For example:
Step 2: Choose a Partitioning Tool
Remember to replace /dev/sdX1
with the actual partition name in the above examples.

The cfdisk utility offers a text-based interface that provides a middle ground between fdisk’s simplicity and parted’s power. GParted is a widely used and user-friendly option for a graphical interface, but it is not useful for Linux servers as they don’t have a GUI.

Partitioning divides a physical hard drive or storage device into logical sections. Each section, a partition, functions like an independent disk. On the other hand, formatting prepares a partition (or an entire unpartitioned disk) by creating a specific file system (e.g., ext4, NTFS, FAT32). This file system allows an operating system (such as Linux or Windows) to organize, store, and retrieve files. Partitioning divides the disk while formatting prepares a partition for data.Use the mkfs command (make file system) with the appropriate option for your chosen file system. The general format is: sudo mkfs -t [filesystem type] [options] /dev/sdX1
. The -t
option specifies the filesystem type. Here are the specific commands:You’re looking for the specific partition (e.g., /dev/sda1, /dev/sdb2, /dev/nvme0n1p1 – the “p” and number indicate a partition, not the whole disk). The TYPE column will show “part” for partitions. Double-check the SIZE to ensure it matches the partition you intend to format.
- Select Partition Table Type (if needed): If the disk is brand new or you want to change the partition table type, use the mklabel command. For example, (parted) mklabel GPT.
- Create the Partition: Use the mkpart command. You’ll be prompted to enter the following:
- Partition type: primary, extended (only on MBR), or logical (only within an extended partition). With GPT, you’ll almost always choose the primary.
- File system type: This is a hint for later formatting; it doesn’t actually format the partition. Choose ext4, fat32, ntfs, etc., as appropriate.
- Start: Specify the partition’s starting point, either in megabytes (MB) or gigabytes (GB) or as a percentage of the disk (e.g., 0%).
- End: Specify the partition’s ending point using the same units as the start (e.g., 100GB or 100%).
- Example: (parted)
mkpart primary ext4 0% 100%
(creates a primary partition using the ext4 formatting that takes the entire disk).
- Repeat (if needed): Repeat the
mkpart
command for each additional partition you want to create.
Step 4: Verify the Partition
Formatting is safe for the drive but permanently erases all data on the selected partition or disk. Always double-check that you’ve selected the correct partition (using lsblk, for example) before formatting. Ensure you have backups of any important data.

Managing storage is a fundamental aspect of server administration, and it can initially seem intimidating. Terms like formatting, mounting, partition table (GPT, MBR), and choosing the right file system type (NTFS, FAT32, exFAT) can quickly become overwhelming.This guide explains the essential concepts of disk partitioning and disk formatting in Linux. We’ll start by explaining what disk partitioning and disk formatting are – and why they’re necessary. Then, we’ll explore different types of file systems and help you understand their strengths and weaknesses. Finally, we’ll provide step-by-step instructions for both partitioning and formatting your disk on Linux systems.
What is Disk Formatting?
Disk partitioning is a fundamental aspect of storage management that divides a physical hard drive (or other storage device such as an SSD) into multiple logical sections. System administrators perform this division to organize data, isolate operating systems, or improve system performance.Step 3: Create a New Partition
What is a File System?
There are multiple popular file system formats:Once you’ve started parted with the correct disk (e.g., sudo parted /dev/sdb), you’ll be at the parted prompt. First, print the current partition table using the print command to double-check the device.
- ext4 (Fourth Extended Filesystem): The ext4 file system is the standard and most widely used file system for Linux distributions. It’s a journaling file system that records changes before they are written to disk. This improves reliability and reduces the risk of data corruption in case of power failures or system crashes. ext4 offers excellent performance, supports large files and volumes, and is generally the best choice for Linux server environments. It also includes delayed and multiblock allocation features to enhance write performance.
- NTFS (New Technology File System): NTFS is the primary file system used by Windows operating systems. Like ext4, it’s a journaling file system with improved reliability and data recovery capabilities. NTFS supports features such as file permissions, encryption (BitLocker), disk quotas, and shadow copies (for backups and restoring previous versions of files). It also supports much larger file and partition sizes than older FAT systems.
- FAT32 (File Allocation Table 32): FAT32 is an older file system known for its broad compatibility. It’s commonly used on USB flash drives and SD cards because it can be read and written by virtually any operating system, including Windows, macOS, and Linux. However, FAT32 has significant limitations: it supports a maximum file size of only 4GB and a practical maximum volume size of 2TB. This makes it unsuitable for storing large files like modern video files.
- exFAT (Extended File Allocation Table): exFAT is a Microsoft-developed file system designed to overcome the limitations of FAT32 while maintaining good cross-platform compatibility. It supports very large file and partition sizes, making it suitable for storing large media files and using large external drives. exFAT is often used on SDXC cards and large USB drives when compatibility with Windows and macOS is needed. It is often the preferred filesystem for USB thumb drives.
Suggested read: How to Find Most Used Disk Space Directories and Files in Linux
How to Format a Disk Drive on Linux
Each partition functions as an independent unit, almost as if it were a separate physical disk. The operating system then treats each partition as a distinct volume. This separation allows multiple file systems and operating systems to coexist on a single physical drive and simplifies backup and recovery processes.
Step 1: Identify the Partition to Format
Disk drives come in all shapes and sizes, each with its own speed and storage capabilities. Knowing their differences can help you pick the right one for your needs.Before formatting, you must know the exact device name of the partition you want to format. Formatting the wrong partition will result in irreversible data loss.

To minimize risk, disconnect any non-essential external drives.
Step 2: Unmount the Partition
After creating the partition(s), you can verify the changes using the print command within the parted prompt. This command displays the current partition table, showing the partition number, start and end points, size, file system type (hint), and any flags. Carefully review this output to ensure the partitions are as you intended.
sudo umount /dev/sdX1
(replace/dev/sdX1
with the actual partition name)sudo umount /mnt/mydirectory
(if the partition is mounted at/mnt/mydirectory
)
Suggested read: 9 Best Linux Distros in 2024
Step 3: Format the Partition
If in doubt, do not proceed!
- For ext4:
sudo mkfs -t ext4 /dev/sdX1
- For FAT32:
sudo mkfs -t vfat -F 32 /dev/sdX1
(the-F 32
specifies FAT32; you can also use-F 16
for FAT16, but this is rarely needed) - For NTFS:
sudo mkfs -t ntfs /dev/sdX1
- For exFAT:
sudo mkfs -t exfat /dev/sdX1
If anything looks incorrect, you can use rm <number> (e.g., rm 1 to remove partition number 1) to delete a partition within parted and recreate it.

Step 5: Verify the Format
Suggested read: How to Check Running Processes in Linux Using ps, top, htop, and atop Commands
- lsblk -f: This command shows each partition’s file system type (FSTYPE) and UUID. Check that the FSTYPE matches what you intended.
- blkid /dev/sdX1: This command specifically shows the specified partition’s UUID and TYPE (file system).
- Mount and check: Mount the partition (e.g., sudo mount /dev/sdX1 /mnt) and then use df -h to check the disk space and file system type. This confirms that the partition is usable. After testing, you can unmount the partition with the command sudo umount /dev/sdX1 or sudo umount /mnt if that is where it is mounted.

So let’s get started!
Wrapping Up: Disk Partitioning and Formatting
Suggested read: How do you check if the TCP port is open, closed, or in use on Linux?Understanding the different file systems, choosing the right tools, and, most importantly, double-checking every command before execution are critical for maintaining data integrity and system stability. Remember to always back up important data before making any changes to partitions. These terms relate to the older MBR (MS-DOS) partition table scheme. An MBR disk can have a maximum of four primary partitions. To overcome this limitation, one primary partition can be designated as an extended partition, which can then be subdivided into multiple logical partitions. GPT (GUID Partition Table), the modern standard, doesn’t have these limitations and supports many more partitions directly.A file system is the underlying structure that an operating system uses to manage data on a storage device. It determines how files are named, stored, organized, and accessed. Think of it as the librarian of your hard drive, keeping track of where everything is located and how to retrieve it. Without a file system, a storage device would just be a collection of unorganized data.
FAQs on Partitioning and Formatting Disk Drives on Linux
What is the difference between partitioning and formatting?
How do I know which file system to choose?
Can I resize partitions without losing data?
What tools are recommended for disk management on Linux?
Is it safe to format a disk drive?
How do I recover data from a formatted drive?
What are primary, extended, and logical partitions?
How do I check disk space usage on Linux?
Can you partition a drive without formatting?
mkfs (e.g., mkfs.ext4, mkfs.vfat) is used for formatting.
For a GUI, GParted and GNOME Disks offer user-friendly interfaces for both partitioning and formatting.
lsblk displays information about block devices (disks and partitions).
blkid shows UUIDs and file system types.
df helps monitor disk space usage.