List Disk Partitions on Linux

In this article, we will explain a ways to list the partition table in a Linux OS using various commands. We will use the command-line Terminal in order to run these commands. To open the Terminal, go to the Activities tab located in the top left corner of your desktop. Then in the search bar, type terminal. When the terminal icon appears, click on it to open.

We have run the commands and methods explained in this article on a Debian system.

View partition table through the lsblk command

The lsblk command lists the information about block devices in the system in a tree format. If a device is mounted at some location, it will also display its mount point. Run the following command in the Terminal in order to display the partition table.

$ lsblk

In the above output, you can see all the logical partitions from my device (sda) as well as its partitions sda1, sda2, and sda5. Let’s see what the columns in above output indicate:

NAME-Indicates name of the devices

MAJ:MIN-Indicates the Major and Minor Device numbers

RM-Indicates whether the device is removable(1) or not (0)

SIZE-Indicates the size of the device

RO-Indicates if the device read-only(1) or not (0)

TYPE– Indicates the type of device, i.e, if it is a disk or partitions(PART), etc.

MOUNTPOINT-Indicates the mount point of the device where it is mounted

Get the list of partitions with the fdisk command

The fdisk command (stands for Format-disk or Fixed-disk) is used to create, view, change and remove hard disk partitions in a Linux system. combining fdisk with –l flag can be used to list all the available partitions on your system. Enter the following command in Terminal to list the partitions on your system:

$ sudo fdisk -l

Let’s see what the columns in the above output indicate:

Device-Name of the device/logical partition

Boot-The * indicates that this partition has the bootloader information which is used to boot an OS.

Start-The starting sector assigned to the partition.

End-The ending sector assigned to the partition.

Sectors-The number of sectors assigned to the partition.

Size-The size of the partition.

ID-The identification number assigned to the partition

Type-The file type used by the partition

Using sfdisk command to view partitions

Sfdisk is also used to manipulate partition tables in Linux. However, unlike the fdisk utility, sfdisk runs non-interactively. To use sfdisk to list the partition table in your system, run the command in Terminal using the following syntax”

$ sudo sfdisk -l/dev/devicename

Exemple

$ sudo sfdisk -l /dev/sda

The sfdisk as you can see displays the same partition table details as the fdisk command. Remember that the output of the fdisk and sfdisk command can only be viewed as authorized users.

Using the parted command to list hard disk partitions

The parted command can also be used to view the hard disk partitions of a device on a Linux system. It can be used to list the partitions even if the disk size is larger than 2 TB while the fdisk and sfdisk cannot.

In order to list the partition table of a device, the following syntax can be used:

$ sudo parted /dev/device-name

Exemple

$ sudo parted /dev/sda

By entering the above command, you will enter into the parted command prompt mode. Enter the following values that will help you in listing the partition table of a device.

Unit GB: Enter this if you want the output to be displayed in gigabytes.

Unit TB: Enter this if you want the output to be displayed in terabytes .

Once you entered any one of the above values, your system will list the partition table.

To exit the parted command prompt mode, simply type quit and hit Enter.

To list the partition table for all the block devices on the system, use the following command:

$ sudo parted -l

In this article, we have learned various ways through which you can list the partition table of devices in your Debian system. 

Source

About Author