list disks ubuntu

On Linux, everything is a file. This includes your system’s physical disks as well as logical ones (partitions). The kernel presents these disks as files stored in the /dev directory.

Devices such as hard disks are categorized as block devices as data is accessed from them in fixed chunks. There are numerous ways to get information on such devices, with the most common being lsblk.

List Disks with lsblk

The lsblk utility reads the sysfs filesystem and lists info about the specified block devices. When run without any parameters, it lists all available block devices.

sudo lsblk

Check the relevant output fields like NAME, SIZE, TYPE, etc, to recognize the devices. The disk entries will be named sda, vda, nvme0n1, and so on. The partitions will have a suffix added to the device name (sda1, nvme0n1p1, etc.). 

One way the kernel identifies devices is through their allocated major and minor numbers. As you’re likely trying to list physical disks, you can exclude unwanted devices (e.g., loop devices) from the output by specifying their major number with the -e flag.

sudo lsblk -e7

You can also use grep to clean up the output like so.

sudo lsblk | grep -v '^loop'

Use fdisk to List Disks

fdisk is typically used for modifying partition tables. But if you use the list option (-l) without specifying any device, it’ll display the partition table info for all devices mentioned in /proc/partitions.

sudo fdisk -l

The output will be a bit long, but you’ll get additional info on devices such as the disk model and partition types. 

List Disks with lshw

lshw is another tool that’s commonly used for getting information on hardware components. To get info on devices belonging to the disk class, you can use

sudo lshw -class disk

Alternatively, you could also shortlist disks and partitions like so.

sudo lshw -short | awk '/disk|volume/'   

Use GNOME Disks

You can use the GNOME Disks utility if you prefer to stick to the GUI for disk management. Simply search and open ‘Disks’ from the Activities overview. You’ll find all of your disks listed in the app along with other info like their partition tables, mount points, sizes, etc.

Anup Thapa

Senior Writer

Anup Thapa is a Linux enthusiast with an extensive background in computer hardware and networking. His goal is to effectively communicate technical concepts in a simplified form understandable by new Linux users. To this end, he mainly writes beginner-friendly tutorials and troubleshooting guides. Outside of work, he enjoys reading up on a range of topics, traveling, working out, and MOBAs.