How to Create and Format Disk Partitions in Linux


In the world of Linux, managing disk storage efficiently is paramount. Disk partitioning plays a pivotal role in organizing data, enhancing performance, and ensuring the stability of your system. This guide will take you through creating and formatting disk partitions in a Linux environment.

Section 1: Understanding Disk Partitions

Simply put, a disk partition is a designated section of a physical disk drive, and it is a fundamental concept in storage management. There are several types of partitions in Linux:

  • Primary Partitions: These are the base partitions and can hold the Linux operating system.
  • Extended Partitions: An extended partition is essentially a placeholder, and it does not typically contain data itself. Think of it as an “umbrella” partition under which you can create multiple logical partitions.
  • Logical Partitions: Logical partitions are housed within extended partitions and are ideal for data storage.

Linux uses partition tables to keep track of these partitions. The two common types are the Master Boot Record (MBR) and the GUID Partition Table (GPT).

Section 2: Preparing the Disk

Start by identifying the disk you want to partition using the lsblk or fdisk -l command. This will display a list of available disks, helping you select the right one.

Section 3: Creating Disk Partitions

Creating partitions is where the real action begins. We’ll be using the fdisk command, which is a reliable and widely used partitioning tool. To create a new partition, follow these steps:

  1. Launch fdisk for the chosen disk: sudo fdisk /dev/sdX, where /dev/sdX represents the disk identifier, such as /dev/sda. Make sure to replace /dev/sdX with the appropriate identifier for your disk.
  2. Once inside fdisk, press n to create a new partition.
  3. Next, you will be prompted to choose the partition type – primary or logical. Select the appropriate option based on your requirements.
  4. After selecting the partition type, specify the size of the partition. Depending on your disk’s configuration, you can enter the size in sectors, cylinders, or other units.
  5. You will need to specify the partition’s starting and ending points. These settings can be adjusted as per your needs, or you can use the default values by simply pressing Enter.
  6. Finally, to save the changes and write them to the disk, enter w. This will write the partition table to the disk and exit fdisk.

Section 4: Formatting Disk Partitions

After creating the partition, the next step is formatting it with a file system. Common Linux file systems include ext4, xfs, and btrfs. To format a partition with ext4, for example:

sudo mkfs.ext4 /dev/sdX1

This command formats the first partition on the selected disk with the ext4 file system.

Section 5: Mounting Partitions

To use the partition, you’ll need to mount it. Choose a mount point, typically located under /mnt or /media, and use the mount command. To make the mount permanent, add an entry in the /etc/fstab file.

For instance, to mount the partition at /mnt/data, you would use the following command:

sudo mount /dev/sdX1 /mnt/data

To add a permanent entry in /etc/fstab, edit the file with a text editor and add a line like this:

/dev/sdX1 /mnt/data ext4 defaults 0 0

Section 6: Checking and Managing Partitions

To check the status of your partitions, use df or lsblk. To modify partitions, you can use tools like resize2fs for resizing.

Section 7: Best Practices and Tips

Here are some best practices for disk partitioning:

  • Plan your partitions carefully to avoid running out of space on any of them.
  • Don’t forget to create backups before any disk management. That will prevent any data loss.

Section 8: Troubleshooting and Common Issues

Common issues include accidentally deleting partitions or making incorrect changes in the fdisk utility. In such cases, data recovery tools like TestDisk can help.


Disk partitioning and formatting are essential skills for Linux users. Properly partitioned and formatted disks enhance system performance and organization. In this guide, you have learned how to manage your Linux storage effectively.

Additional Resources

For a more advanced dive into Linux disk partition, consider these resources:

Final Thoughts

As you dive into the world of Linux disk partitioning, remember that practice makes perfect. Explore these concepts in a safe, non-production environment to build your confidence. If you have questions or need assistance, don’t hesitate to reach out. Happy partitioning!

Recent Articles

Related Stories

Stay on op - Ge the daily news in your inbox