Linux Commands

GDISK Command-Line Options

The GDISK command in Linux is used to partition the drives of your system. Moreover, it can also be used to list down the existing partitions and display relevant information about them. In this guide, we will be talking about the different command-line options that are available with the GDISK command on a Linux Mint 20.3 system.

GDISK Command Line Options in Linux Mint 20.3

There are different command-line options available for the GDISK command in Linux Mint 20.3. However, before proceeding with the discussion of these options, we would like to share that the GDISK utility on Linux has several different versions. The version of GDISK that is installed by default on our Linux Mint 20.3 system is GPT FDISK. Therefore, we will be using this particular version for discussing the said command-line options. Also, instead of using the “gdisk” command, we will have to use the “fdisk” command because of the version of GDISK that we have on our system. The general syntax of this command is as follows:

fdisk <option> <diskname>

Here, “option” refers to all the options that can be used with the “fdisk” command, whereas “diskname” represents the name of the particular disk whose details you wish to extract depending upon the requirements.

Help Manual

For accessing the Help Manual of the “fdisk” command for knowing all the available command-line options, we will execute the following command:

$ fdisk --help

There is a long list of options available for this command, as you can see from the image shown below. You can scroll down this list to view all the available options.

Listing Down All the Partitions

If you want to list down all the drive partitions that you have on your Linux Mint 20.3 system, then you will have to execute the following command:

$ sudo fdisk –l

All the drive partitions of our Linux Mint 20.3 system are shown in the image below:

In the same manner, you can also use the other available options with the “fdisk” command by making use of its Help Manual.

Accessing the Command Line Options Available for a Specific Drive Partition

Now, we will take a look at how we can access the command-line options that are available for a specific drive partition under the “fdisk” command. For doing that, we will execute the following command:

$ sudo fdisk /dev/sda

This command will list down all the command line options available for the “/dev/sda” partition of our Linux Mint 20.3 system. When you will execute this command, you will be prompted to enter the character “m” for proceeding further as shown in the image below:

As soon as you will hit the Enter key after typing “m”, you will be displayed with all the different options that are available for the “/dev/sda” partition of your system. These options will be divided into the form of different sections and we will briefly be discussing all of those sections one by one.

The DOS (MBR) Options

As the name implies, this set of command-line options of the “fdisk” command will mainly be related to the disk operating system’s master boot record. By making use of these options, you can easily manipulate the compatibility and bootable flags of the DOS (MBR). These options are shown in the following image:

The Generic Options

These options include generic functionalities such as deleting a partition, adding a new partition, printing the information related to each partition, etc. These options are shown in the image below:

The Miscellaneous Options

These are the options that cannot really fit into any other category. They include printing the options menu, changing the display, accessing extra functionality, etc. These options are shown in the following image:

The Script Options

These are the options using which you can load or dump the disk layout to the script file. These options are displayed in the image below:

The Save and Exit Options

This section includes the options with which you can either save the changes that you have made to a partition, or you can simply exit from the “fdisk” prompt without saving any changes as shown in the following image. However, it is highly recommended to be careful while modifying the partition tables as these changes can lead to the malfunctioning of your system.

The Label Creation Options

Finally, this set of options enables you to create new partition tables depending on your needs as shown in the image below:

Conclusion

By going through this article, you will get a nice overview of the different command-line options available for the GDISK command in Linux Mint 20.3. After understanding these options, you can conveniently use them according to your requirements.

About the author

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.