How to Use Fdisk to Manage Partitions on Linux

How to Use fdisk to Manage Partitions on Linux.

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 Table in Linux

Use this commands and after enter “p” in shell:
fdisk /dev/sda

5. How to Delete a Partition in Linux

Use this command:
fdisk /dev/sda
When asked for command, enter “d”
After, enter 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 command, enter “n”
After, enter “e” for 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 Size of a Partition in Linux

Use this command to view 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 command, to fix it.
And enter “w” in command, to save it.

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

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

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

Register for free account now.