8 Simple Steps to Create Disk Partition in Linux


To create disk partitions in Linux, follow these steps:

  1. Identify the target disk with sudo fdisk -l.
  2. Start modifying the disk’s partition table with sudo fdisk /dev/sda.
  3. Create a new partition, specify its type and size with n and configure as prompted.
  4. Define file system type and save the new partition table with t and then w to write changes.

Disk partitioning on your Linux system might seem challenging, but it’s essential for optimizing your system’s efficiency. I will take you through a clear, step-by-step approach to help you confidently manage disk partitions, suitable for both beginners and those with some technical knowledge. You’ll learn how to use tools like fdisk to create and manage partitions and how to troubleshoot common partitioning errors. I will also share maintenance tips to ensure your system stays organized and runs smoothly. By the end of this article, you’ll have all the knowledge you need to enhance the performance and longevity of your Linux setup.

How to Create Disk Partition in Linux?

fdisk is a powerful command-line tool used for creating and managing disk partitions on Linux. It provides precise control over the configuration of storage devices, making it ideal for systems administrators and users comfortable with terminal commands. Here is the step-by-step guide to create disk partitions:

  1. Open Terminal.
open terminal
  1. Use fdisk to list all the disks and their partitions to find the disk you want to partition.
sudo fdisk -l

This command displays detailed information about all disks and partitions, helping you identify the target disk, such as /dev/sda.

listing disk and its partitions
primary disk and its partitions
  1. Start modifying the disk’s partition table by running the following command:
sudo fdisk /dev/sda

This command starts fdisk in interactive mode for the disk /dev/sda, allowing you to modify its partitions.

starting disk modification
  1. Create a new partition by specifying its type, size, and position. To create a new partition:

This command initiates the process to add a new partition.

creating new partition
  1. Set the partition number and sectors as prompted.
created new partition with default settings
  1. Define the file system type for the new partition:

This command allows you to change the system id of the partition.

changing file system type of partition
  1. Specify the type, like 20 for a Linux partition:
changing partition type to linux
  1. Save the new partition table to the disk:

This command writes the changes to the disk and exits fdisk, effectively creating the new partition.

saving the partition table to the disk

5 Common Partitioning Errors and Solutions

Partitioning a disk can sometimes lead to unexpected issues. Here are five common problems you might encounter while partitioning your Linux system, along with straightforward solutions to help you resolve them effectively.

  • 🛑 Unallocated Space Too Small: To create new partitions where space is insufficient, resize existing ones using GParted. This tool effectively shrinks other partitions, freeing up necessary space without losing data.
  • ⚠️ Cannot Write to Table: Errors such as “cannot write to partition table” occur when partitions are active. Use a live USB to manage partitions, which allows editing without interference from the system’s operations.
  • 🔄 Overlapping Partitions: Overlapping partitions cause data errors and loss. Adjust or resize these partitions using a partition editor to ensure that each has its distinct and non-overlapping segment on the disk.
  • 🛠️ File System Errors: For file system issues when formatting or accessing partitions, use the command fsck /dev/sda1. This checks and repairs the partition, ensuring it is free from errors and accessible.
  • 📊 Partition Table Full: On MBR disks limited to four primary partitions, convert one primary partition into an extended partition. This change allows for more logical partitions within the extended partition, expanding your capacity.

5 Disk Partition Maintenance Tips

Maintaining the health of disk partitions is crucial for system stability and data integrity. Regular checks and optimizations can significantly extend the life of your storage devices. Here are five effective tips to help you manage and maintain your disk partitions efficiently.

  • 🔄 Regularly Check for Errors: Use tools like fsck for Linux to scan and fix file system errors on your partitions regularly. This preventive measure helps avoid data corruption and system crashes.
  • 🧹 Clean Up Unnecessary Files: Regularly delete unnecessary files and uninstall unused applications to prevent your partitions from becoming too full. This prevents performance degradation due to overly full partitions.
  • 📊 Monitor Disk Usage: Regularly monitor your disk usage with tools like df and du. Keeping an eye on disk space usage helps you manage storage resources more effectively and plan for future expansions or clean-ups.
  • 🔧 Defragment Regularly: For partitions with file systems that tend to fragment (like NTFS), regularly defragment the disk. This optimizes file storage, improves access speed, and extends the life of the drive.
  • 🛡️ Backup Frequently: Always have a backup strategy in place. Regular backups of your important data protect against data loss in the event of disk failure or other hardware issues. Use automated backup solutions to ensure data is backed up consistently.

Wrapping it Up

In this guide, I’ve walked you through detailed steps for partitioning disks in Linux, using fdisk command. I’ve also covered how to handle common partitioning errors and shared best practices for maintaining partition health. These insights should help you manage your system’s partitions more effectively and avoid common pitfalls.

If you’re keen on expanding your knowledge, look into topics like optimizing disk performance, advanced file system management, or enhancing security for Linux systems. Each of these subjects can further improve your skills and ensure your system runs smoothly, complementing what you’ve learned in this guide about disk partitioning.

Frequently Asked Questions

  1. Can I resize a partition without losing data?

    Yes, you can resize a partition without losing data using tools like GParted or the resize2fs command for ext3/4 file systems. However, it’s crucial to backup your data before resizing as a precaution against any potential errors that might occur during the process.

  2. How do I recover data from a deleted partition?

    Recovering data from a deleted partition is possible with tools like TestDisk or PhotoRec. These tools scan the disk to find remnants of the deleted partition and attempt to restore files. Success depends on whether new data has overwritten the old data.

  3. How do I choose the right file system for my Linux partitions?

    Choosing the right file system for your Linux partitions depends on your needs. For general use, ext4 offers a good balance of performance and reliability. XFS and Btrfs are suitable for large data operations and systems requiring high reliability and scalability.

  4. What is the impact of partition size on system performance?

    The impact of partition size on system performance can be significant, especially for databases and applications that require high I/O throughput. Larger partitions can reduce the number of disk seeks and improve caching efficiency, leading to faster access times and overall improved system responsiveness.



Ojash is a skilled Linux expert and tech writer with over a decade of experience. He has extensive knowledge of Linux's file system, command-line interface, and software installations. Ojash is also an expert in shell scripting and automation, with experience in Bash, Python, and Perl. He has published numerous articles on Linux in various online publications, making him a valuable resource for both seasoned Linux users and beginners. Ojash is also an active member of the Linux community and participates in Linux forums.



Akshat is a software engineer, product designer and the co-founder of Scrutify. He's an experienced Linux professional and the senior editor of this blog. He is also an open-source contributor to many projects on Github and has written several technical guides on Linux. Apart from that, he’s also actively sharing his ideas and tutorials on Medium and Attirer. As the editor of this blog, Akshat brings his wealth of knowledge and experience to provide readers with valuable insights and advice on a wide range of Linux-related topics.

Share this article
Shareable URL
Prev Post

How to Ping on Discord on Linux? [4 Simple Methods]

Next Post

How to Linux Format Disk Partitions? [3 Easy Methods]

Leave a Reply

Your email address will not be published. Required fields are marked *

Read next