Find out how to Create, Resize and Delete Linux Partitions With Cfdisk

Partitioning your hard drives is one of the most frustrating tasks you will encounter while installing Linux. Sophisticated command line tools make it difficult for beginners to get started with partition management.

What you need is a partition management tool specifically designed for beginners. This is where cfdisk comes to the rescue. For those who want to better manage partitions on their computer, Cfdisk is the best choice.

Here you will learn how to create new partitions under Cfdisk under Linux as well as how to resize, change and delete partitions.

What is cfdisk

Cfdisk is a text-based, graphical command line tool that you can use to create, delete, and modify hard drive partitions on your system. Unlike other command line tools, Cfdisk provides an interactive way to manage partitions for beginners.

The Cfdisk package is preinstalled on most of the popular Linux distributions. You can install cfdisk manually if you can't find it on your system by default.

To install the package on Debian-based systems:

sudo apt-get install cfdisk

On Fedora:

sudo dnf install cfdisk

On CentOS:

sudo yum install cfdisk

About Arch-based distributions:

sudo pacman -S cfdisk

Enter to launch cfdisk in your terminal sudo cfdisk, and press Enter. The default utility interface looks something like this.

cfdisk partition manager

Cfdisk also displays information about the storage device at the top of the screen. The following details are provided:

  1. Hard drive name

  2. Plate label

  3. Size in bytes and GB

  4. Number of sectors

  5. Identifier

If your system contains multiple storage devices, you can use the following syntax to indicate which device you want to change:

cfdisk (device)

If / dev / sda is your system's hard disk drive (HDD) you enter cfdisk / dev / sda This option allows you to manage partitions only on your hard drive. You can also enter cfdisk / dev / sdb to partition external storage devices connected to your system.

Creating Linux Partitions with Cfdisk

In order to create new hard disk partitions with Cfdisk, there must be free space on your storage space. Notice in the picture below that there is 3 GB of free space available.

Partition table

For the demonstration we'll create a new partition with the New Option from the menu. You can scroll through the menus using the button Right and Left Arrow keys. Use the option to select a partition from the table Above and Low Cursor keys.

Create a new cfdisk partition

To create a partition:

  1. Choose free space Partition from the list

  2. Highlight the New possibility

  3. Tap Enter to confirm the action

  4. Select on a new unpartitioned hard drive Primary when prompted for the partition type

  5. Tap Enter to confirm

Now you need to specify the size of the new partition. Since there is still 3 GB of space left in the memory, we will create a partition with a size of 3 GB. You can enter any number (1 GB, 2 GB, etc.).

Partition size

Finally you choose Write from the menu and press Enter. Type in Yes to confirm your choice.

Related: The Pros and Cons of Partitioning a Hard Drive

Change the Linux file system type

When you create a new partition in your storage, the default partition type is set to Linux file system. However, if you want to use the partition for something else, such as B. for Linux swap or EFI, you can easily change the type with Cfdisk.

To change the file system type, select the newly created partition from the table. Select the Art Option from the menu and press Enter.

Change partition type

Cfdisk offers you 108 different partition types to choose from. You can choose the file system type that suits your needs.

After changing the partition type, you must write the changes to the hard drive again. Choose Write from the menu and press Enter. Art Yes to complete the process.

Writing data to the cfdisk table

Delete Linux partitions

Deleting partitions is the easiest task that you can do with Cfdisk. Just select the partition from the table Clear from the menu and press Enter.

delete old partitions

Now you have to write the changes to the hard disk by selecting Write from the menu.

Changing the size of old partitions on Linux

With Cfdisk, you can resize your partitions in seconds.

First, select the partition you want to resize and select the one change size Option from the menu. Next, specify the new size you want to assign to the partition. For this demonstration, the size of the newly created partition will be changed to 2 GB.

Resize hard drive partitions cfdisk

Again you have to Write the changes to the hard drive.

Changing the size of partitions on Linux

Additional cfdisk commands

While Cfdisk is the perfect choice for beginners who don't want to mess around with text commands, you can still manage your partitions from the command line with Cfdisk.

For those who have good experience with other terminal-based partition management tools like Fdisk, here are some additional commands that you can use with Cfdisk.

  • -h, -Help: Display help on using Cfdisk.
  • -L, -Color: Colorize the output displayed on the screen.
  • -V, – version: View version details for Cfdisk.
  • -z, –zero: This allows you to create a new partition table from scratch. The previous partition table is not read by the application.
  • b: Turn the bootable flag on or off for the selected partition.
  • d: Delete the highlighted partition.
  • H: Display the help screen while using Cfdisk.
  • n: Create a new partition from the selected free space.
  • q: Exit the program without writing any data to the table.
  • s: Correct the partition order.
  • t: Change the type of the selected partition.
  • u: Save the disk layout to an output file.
  • W: Write the data in the table.
  • x: Toggle the display of additional information about the selected partition.

Partition management with cfdisk

Knowing how to create and manage your hard drive partitions is important to know when running Linux on your computer. Even during Linux installation, users need to partition their memory to allocate memory to the system. Dual booting a Linux distribution without knowledge of drive partitioning is an enormous risk factor.

While many Linux distributions allow you to graphically partition your hard drive, some don't. To easily counteract such situations, it is a must for everyone to familiarize themselves with at least one command line partition management tool.

Dual boot against virtual machine

Dual Boot vs. Virtual Machine: Which One Is Right For You?

Do you want to run multiple operating systems on one computer? This is how you decide whether a virtual machine or a dual boot is right for you.

About the author

Deepesh Sharma
(13 articles published)

Deepesh is Staff Writer for Linux at MUO. He has been writing informational content on the Internet for over 3 years. In his spare time he enjoys writing, listening to music and playing the guitar.

More
From Deepesh Sharma

Subscribe to our newsletter

Sign up for our newsletter to receive tech tips, reviews, free e-books, and exclusive offers!

One more step …!

Please confirm your email address in the email we just sent you.

. "border =" 0

Leave a Reply

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