4 Ways to View Disks and Partitions in Linux


As an open-source operating system, Linux provides various tools and commands that allow users to manage their disk and partition configurations. Whether you're a system administrator or a casual user, you may need to view your disks and partitions at some point. In this article, we'll explore four ways to view disks and partitions in Linux, along with some examples.

Using fdisk Command

fdisk is a command-line tool that allows you to view and manage disk partitions on Linux systems. To view disk partitions, you need to run fdisk command with disk device name as an argument.

The following command shows how to view partitions on /dev/sda −

$ sudo fdisk -l /dev/sda

The "-l" option stands for list and displays partition table for specified disk. output includes information about disk size, sector size, partition layout, and file system type.

Using lsblk Command

lsblk is another command-line tool that provides a clear and concise view of storage devices and their corresponding partitions in Linux. command displays a tree-like hierarchy of block devices, which includes disks, partitions, and other block devices such as loop devices and RAM disks.

To use lsblk, run following command −

$ sudo lsblk

The output displays all available block devices in system, including their mount points, sizes, and other information. If you want to view partitions of a specific disk, you can use "-o" option to display output in a specific format.

For example, following command displays only partitions on /dev/sda disk −

$ sudo lsblk -o NAME,SIZE,MOUNTPOINT /dev/sda

Using blkid Command

blkid is a command-line tool that provides information about file systems and partitions on a device. It displays UUID, label, and file system type of each partition in a human-readable format.

To view partitions on a device using blkid, run following command −

$ sudo blkid

The output displays device names, UUIDs, file system types, and labels (if any) of all partitions available in system. You can also use "-p" option to display output in a machine-readable format.

For example, following command displays UUID and file system type of /dev/sda2 partition −

$ sudo blkid /dev/sda2

Using GParted Tool

GParted is a graphical tool that allows you to view and manage disk partitions in Linux. It provides a user-friendly interface for managing partitions, including creating, deleting, resizing, and moving partitions.

To use GParted, you need to install it first using package manager of your Linux distribution. Once installed, you can launch it from Applications menu or run following command −

$ sudo gparted

The tool displays a list of all available storage devices and their corresponding partitions. You can click on a partition to view its properties, including file system type, size, and mount point. You can also perform various operations on partitions, such as resizing, moving, or copying them.

Here are a few additional tips and tricks to help you get the most out of viewing disks and partitions in Linux −

Use the -t option with the fdisk command to view only the partitions of a specific type. For example, to view only the partitions of type 83 (Linux), you can run the following command −

sudo fdisk -l -t 83

Use the -o option with the lsblk command to customize the output. For example, to view only the device name, size, and mount point of each partition, you can run the following command −

sudo lsblk -o NAME,SIZE,MOUNTPOINT

Use the -h option with the df command to display the sizes in a human-readable format. For example, to view the disk usage information for all partitions in a human-readable format, you can run the following command −

df -h

Use the -p option with the blkid command to display the output in a parsable format. This can be useful if you want to automate the process of viewing disk and partition information. For example, to view the UUID and file system type of all partitions in a parsable format, you can run the following command −

sudo blkid -p /dev/sd*

These are just a few examples of the many ways you can customize and fine-tune the output of these commands to suit your needs. With practice and experimentation, you can discover new ways to view and analyze disk and partition information in Linux, and become a more effective and knowledgeable user.

Conclusion

Linux provides various tools and commands to view disks and partitions in system. In this article, we explored four ways to view disks and partitions, including fdisk, lsblk, and blkid commands, and GParted tool. These tools and commands can be used to gain a better understanding of disk layout, identify disk usage patterns, and troubleshoot disk-related issues.

Updated on: 31-Mar-2023

18K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements