How to Use the lsblk Command to View All Attached Hard Drives in Linux

When you plug a new USB flash drive or an external hard drive into a Linux server, the operating system does not automatically pop up a graphical window like Windows or macOS does. In a headless server environment, you must use the command line to manually identify the exact device ID of the new drive before you can format it or mount it. The fastest, safest, and most visually organized way to do this is by using the lsblk command.

What Does lsblk Do?

The lsblk (List Block Devices) command scans the hardware architecture of your Linux machine and outputs a perfectly formatted, tree-like diagram of every single storage drive physically connected to the motherboard, including their exact sizes and partition structures.

How to View Your Hard Drives

  1. Open your Linux terminal.
  2. Type the following simple command:

lsblk

  1. Press Enter.

The terminal will instantly output a list that looks something like this:

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 500.0G  0 disk 
├─sda1   8:1    0   500M  0 part /boot
└─sda2   8:2    0 499.5G  0 part /
sdb      8:16   1  16.0G  0 disk 
└─sdb1   8:17   1  16.0G  0 part

How to Read the Output

The output is incredibly easy to decipher once you understand the naming conventions.

  • NAME: In Linux, the first physical hard drive is always named sda. The second physical drive is sdb, the third is sdc, and so on. The numbers underneath (like sda1 and sda2) represent the specific partitions inside that physical drive.
  • SIZE: This column immediately confirms if you are looking at the correct drive. In the example above, sda is a massive 500GB internal hard drive, while sdb is clearly the 16GB USB thumb drive you just plugged in.
  • MOUNTPOINT: This column shows where the drive is currently accessible in the file system. If the mountpoint is completely blank (like our sdb1 example), it means the USB drive is physically plugged in, but the operating system has not yet mounted it for use.

By relying on lsblk, you can absolutely guarantee you are formatting the correct sdb USB drive, rather than accidentally wiping your sda master boot drive.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.