In Linux systems, the cfdisk is the curses-based command-line tool used to manage hard drive partitions including creating, deleting, and modifying. It provides an effective and user-friendly text-based graphical interface with basic partitioning functionalities. It displays all disks and partitions along with relevant information.
In this guide, I am going to cover cfdisk command and how to use it to create and delete partitions in Linux.
Run the cfdisk command with the /dev/sda as an argument in the terminal:
You will receive the following output in the terminal:
In my Linux system, we have three partitions that can be edited.
Let’s perform some of the functions for better understanding.
Choose the disk; resize it by clicking on the Resize option using the arrow buttons and hit Enter button:
Allocate the size according to need or choice and press the Enter button to save it:
As you can see, the disk size has been updated and it also mentions the free space:
You can also change the partition type by selecting the Type and press Enter:
Once you select the Type option; this will display the partitions types list in front of you; choose any of them:
We have reduced the size of disk 3 in Step 1, and this creates free space in the system. Now, we can create a new partition as well max of size 3.5G.
Move to Free Space and click on the New option:
Set the size of the new disk and hit Enter:
The new partition of 3.0G is successfully created:
After the partition size allocation, you can set the type of created partition; let’s suppose I am assigning it Linux Swap type:
Move to the Write option to write the partition to make changes:
A prompt will appear to confirm if you’re sure to write the partition table, type yes and Press Enter button:
Now we have four disk partitions in the Linux system:
The cfdisk command is a text-based graphical interface used to handle disk partitions. With the help of this, you can create, edit, and delete any partition easily as it is a simple and effective tool. Throughout this guide, we have learned how we can manage disk partitions by resizing them and changing their type. We have also created a new disk; allocated a size and write it in a partition table.