fdisk utility

fdisk is a simple text-based partitioning utility. It exists for both Windows and Linux operating systems. You can use the fdisk utility in Linux to view, create, modify or edit partitions. In this lesson we will go through some basic features of this program.

Using fdisk

To use fdisk, type the command followed by the name of the disk you would like to partition. This opens up the fdisk prompt. For example, to partition the primary SATA disk, we would enter the following command:

invoking fdisk command

Once inside the fdisk prompt, you can type commands to accomplish various goals.

To display the current partition table, type p:

fdisk print partiton table

To create a new partition, type n. This will open up a text wizard with series of questions about the partition:

fdisk create new partition

To delete a partition, type d. The program will ask you for the partition number:

fdisk delete partition

In the example above you can see that we have deleted the partition number 3 that was created in the previous step.

When you create a partition, fdisk assigns it a type code of 0x83, which corresponds to a Linux filesystem. If you want to create a Linux swap partition or a partition for another OS, type t. To get a list of known partition types, type l.

You can exit the fdisk utility in two ways. First, you can type q. The program exits without saving any changes. To save the changes to the disk and then quit, type w.

Subscribe to our Newsletter

Like us on Facebook

Geek University 2019