List of hard drives on Linux

As Linux administrators, we sometimes need to look at our hard drive partition table. This allows us to reconfigure old drives, freeing up space for more partitions and, if necessary, even creating space for new drives. The partition table is located in sector 0 of the hard disk. Devices on your system appear as / dev / sda, / dev / sdb in the partition table. There are several ways to view a partition table in Linux.

In this article, we will explain these ways to display the partition table in Linux OS using various commands. We will use the Terminal command line to run these commands. To open the terminal, go to the Actions tab located in the upper left corner of the desktop. Then enter terminal in the search bar. When the terminal icon appears, click on it to open it.

We ran the commands and methods described in this article on a Debian 10 system.

Viewing the partition table with lsblk command

The lsblk command displays information about block devices on the system in a tree-like format. If the device is mounted somewhere, it will also display its mount point. Run the following command in Terminal to display the partition table.

$ lsblk

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

NAME-Has a device name

MAY: MIN-Indicates the numbers of major and minor devices

RMIndicates whether the device is removable (1) or not (0)

THE SIZE-Shows the size of the device

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

A TYPE– indicates the type of device, that is, if it is a disk or partitions (PART), etc.

ATTACHMENT POINT-Shows the mount point of the device it is mounted on.

Get list of partitions using fdisk command

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

$ sudo fdisk -l

Get list of partitions using fdisk command

Scroll down the output to view the partition table as follows:

Linux sfdisk command

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

device-Device name / logical partition

boot* * Indicates that this section contains bootloader information that is used to boot the OS.

StartThe starting sector assigned to the section.

the endThe ending sector assigned to the section.

sectorsThe number of sectors assigned to the section.

The size– Section size.

I’DIdentification number assigned to the section

A typeFile type used by the section

Using sfdisk command to view partitions

Sfdisk is also used to manage Linux partition tables. However, unlike fdisk, sfdisk is not interactive. To use sfdisk to display the partition table on your system, run the command in Terminal using the following syntax “

$ sudo sfdisk -l/dev/devicename

For example, to display the partition table for / dev / sda:

$ sudo sfdisk -l /dev/sda

Using sfdisk command to view partitions

Sfdisk, as you can see, displays the same partition table data as the fdisk command. Remember that the output from the fdisk and sfdisk commands can only be viewed as authorized users.

Using 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 partitions even if the disk is larger than 2 TB, while fdisk and sfdisk are not.

You can use the following syntax to display the device partition table:

$ sudo parted /dev/device-name

For example, to display the partition table for / dev / sda:

$ sudo parted /dev/sda

By entering the above command, you will enter split command line mode. Enter the following values ​​to help you display the device partition table.

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

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

After you have entered any of the above values, your system will list the partition table.

Using parted command to list hard disk partitions

To exit command line split mode, simply type quit and press Enter.

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

$ sudo parted -l

That’s all there is to it! In this article, we learned about the different ways of listing the device partition tables on your Debian system. In addition to listing the section tables, the commands discussed above have other functions that you can view using their manual pages.

List of hard drives on Linux

Sidebar