Close this search box.

How to Use Fdisk to Manage Partitions on Linux

Table of Contents


For computer file systems, fdisk is a command-line utility that provides disk partitioning functions. In versions of the Windows NT operating system line from Windows 2000 onwards, fdisk is replaced by a more advanced tool called diskpart. Similar utilities exist for Unix-like systems.

There are 10 fdisk Commands to Manage Linux Disk Partitions:

1. View all Disk Partitions in Linux

Use this command to check all:
sudo fdisk -l

2. View Specific Disk Partition in Linux

Use this command to check only one:
fdisk -l /dev/sda

3. Check all Available fdisk Commands

This command helps you to use fdisk:
fdisk /dev/sda
Enter “m” for help.

4. Print all Partition Tables in Linux

Use this command and enter “p” in the shell:
fdisk /dev/sda

5. How to Delete a Partition in Linux

Use this command:fdisk /dev/sda
When asked for a command, enter “d”
After, enter the partition number that you want to delete.

6. How to Create a New Partition in Linux

Use this command:
fdisk /dev/sda
When asked for a command, enter “n”
After, enter “e” for the extended partition and “p” for the primary partition.
Next, enter the size of the partition.
To save it, enter “w”.

7. How to Format a Partition in Linux

To format any partition, enter this command:
mkfs.ext4 /dev/sda3
Note: change /dev/sda3 with the disk location that you want to format.

8. How to Check the Size of a Partition in Linux

Use this command to view the size of a partition:
fdisk -s /dev/sda3

9. How to Fix Partition Table Order

Use this command to fix:
fdisk /dev/sda
Enter “f” in the command, to fix it.
And enter “w” in the command, to save it.

10. How to Disable Boot Flag (*) of a Partition

Use this command to Disable the boot flag:
fdisk /dev/sda
Enter the “p” command to view the current partition.
Next, enter “a” to disable the flag.
Then enter the number of the partition.

You have successfully learned How to Use Fdisk to Manage Partitions on Linux.
Enjoy it.

show hidden files and hide folders in Ubuntu


fdisk is a command-line utility that can be used to manage disk partitions on Linux systems. Its functionality includes creating, deleting, resizing, and modifying partitions.

To use fdisk, you need to first identify the disk you want to partition and then start fdisk by typing “fdisk /dev/diskname” in a terminal. From there, you can use various commands to create, delete, and modify partitions, including “n” to create a new partition, “d” to delete a partition, and “w” to save changes and exit fdisk.

To delete a partition using fdisk, you can start by identifying the partition number you want to delete using the “p” command to print the current partition table. Then, type “d” followed by the partition number, and type “w” to save changes and exit the fdisk.

Yes, you can resize a partition using fdisk by deleting the existing partition, creating a new partition with the desired size, and saving changes using the “w” command. This process will require you to identify the partition you want to resize and to use the appropriate commands to delete and create the new partition.

To view partition information using fdisk, you can use the “p” command to print the current partition table. This will display information about the existing partitions, including their start and end sectors and their partition types.

If you want to exit fdisk without saving changes, you can type “q” and press Enter. This will allow you to exit the fdisk without making any permanent changes to the partition table.

Make a Comment
Share on
VPSie Cloud service

Fast and Secure Cloud VPS Service

For a month

The First 1 orders gets free discount today! Try Sign up on VPSie to get a chance to get the discount.