TL;DR
To create Linux disk partition, follow these steps:
- Identify the target disk with
sudo fdisk -l
. - Start modifying the disk’s partition table with
sudo fdisk /dev/sda
. - Create a new partition, specify its type and size with n and configure as prompted.
- Define file system type and save the new partition table with t and then w to write changes.
Managing disk space on Linux can be tricky, but you’re in the right place to get it sorted. This post will show you how to create partition in Linux step-by-step, boost your system’s performance, and organize your data better. I’ll guide you through step-by-step methods using tools like fdisk
, parted
, and GParted. I’ll also tackle common errors and best practices to keep your partitions in great shape. By the end, you’ll have the confidence and knowledge to manage your disk partitions like a pro. Let’s get started!
What is Linux Disk Partitioning?
Disk partitioning is the process of dividing a hard drive or solid-state drive into smaller, separate sections called partitions. Each partition acts like a separate disk, allowing you to manage and organize your data more effectively.
Purpose of Disk Partitioning Linux:
- Organize Data: You can store different types of data in separate partitions. For example, keep your system files in one partition and your personal files in another.
- Improve Performance: By separating the operating system, applications, and data, you can reduce the read/write head movements on the disk, which can enhance performance.
- Increase Security: If you store sensitive information in a separate partition, it becomes easier to apply security measures like encryption. It also isolates the sensitive data from potential system crashes.
- Simplify Backup and Recovery: You can back up and restore individual partitions without affecting the others. This makes the process faster and more efficient.
- Multi-Boot Systems: Partitioning allows you to install and run multiple operating systems on the same disk. Each operating system can have its own partition.
By partitioning your disk, you gain more control over how your data is stored and managed, leading to a more organized and efficient computing experience.
How to Create Linux Disk Partition?
To create Linux disk partition, start by opening a terminal and using the fdisk
command with your target disk, such as sudo fdisk /dev/sda
. List existing partitions by typing p
, then create a new partition by typing n
and following the prompts to set the partition type and size.
Once done, write the changes to the disk by typing w
. Finally, format the new partition with a file system, for example, sudo mkfs.ext4 /dev/sda1
, and verify it using lsblk
to confirm the partition was created successfully.
That was the quick answer. Here are the detailed steps for this method and two other methods to create Linux disk partition:
1. Creating Disk Partitions Using fdisk
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 Linux disk partitions:
- Open Terminal.

- 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.


- 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.

- Create partition Linux by specifying its type, size, and position. To create a new partition:
n
This command initiates the process to add a new disk partition Linux.

- Set the partition number and sectors as prompted.

- Define the file system type for the new partition:
t
This command allows you to change the system id of the partition.

- Specify the type, like 20 for a Linux partition:

- Save the new partition table to the disk:
w
This command writes the changes to the disk and exits fdisk, effectively creating the new partition.

3. Creating Disk Partitions Using parted
parted is a command-line utility that allows you to manage disk partitions on Linux. It’s especially useful for creating, resizing, and deleting partitions. parted supports both MBR and GPT partitioning schemes and is ideal for users who need a flexible and powerful tool for disk management. Follow these steps to Linux create disk partition:
- Before you start, ensure that parted is installed on your system. This can be done using your package manager:
sudo apt-get install parted
This command installs the parted utility, which you’ll use for disk partitioning.

- Next, initialize the disk you want to partition by opening it with parted:
sudo parted /dev/sdX
Replace /dev/sdX with your disk identifier (e.g., /dev/sda)

This command opens the specified disk in the parted utility, allowing you to manage its partitions.
- Create a new partition table if your disk does not have one or if you want to start fresh:
(parted) mklabel gpt # Creates a GPT partition table on the disk
This command initializes the disk with a GPT partition table, preparing it for new partitions.

- Now, create a new partition on the disk:
(parted) mkpart primary ext4 0% 50%
This command creates a primary partition using the ext4 file system, spanning from 0% to 50% of the disk space.

- Finally, confirm that the new partition was created successfully:
lsblk

4. Creating Disk Partitions Using GParted (GUI Method)
GParted is a powerful graphical tool for managing disk partitions on Linux. It provides an intuitive interface for creating, resizing, and deleting partitions, making it ideal for users who prefer a GUI over command-line tools.
- First, ensure GParted is installed on your system:
sudo apt-get install gparted
This command installs GParted, a graphical partition management tool.

- Launch GParted with root privileges:
sudo gparted
This command opens the GParted application, allowing you to manage your disk partitions through a GUI.

- When GParted opens, select the disk you want to partition from the drop-down menu in the top-right corner.

- Navigate to the correct disk to ensure you are partitioning the intended device.

- Select the unallocated space on your disk.

- Right-click and choose New.

- Specify the size, type (primary or logical), and file system (e.g., ext4) for the partition. Click Add.

These steps create a new partition in the unallocated space with your chosen settings.
- Select the partition you want to format. Right-click and choose Format to. Select the desired file system (e.g., ext4).

- These steps format the selected partition with the specified file system.
- Confirm the new partition in both the GParted interface and using command-line tools:
lsblk

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.
Linux Create Partition: Final Thoughts
In this guide, I’ve walked you through detailed steps for to create disk partition in Linux, using fdisk command. I’ve also covered how to handle common partitioning errors and shared best practices for maintaining partition health.
If you want to continue expanding your Linux skills, I suggest exploring into these related topics:
- Explore how to format disk partitions in Linux, which will guide you through the process of selecting and applying various file systems after partitioning.
- Learn how to create a home directory in Linux, useful for setting up user environments after partitioning your disk.
- Check out how to install and use the GNOME Disks utility on Ubuntu, offering a powerful and user-friendly graphical tool for disk management.