For many operations on the Linux platform, you’ll need to know information about your hard drive. Unfortunately, most beginner Linux users are unaware of how to find hard drive info on Linux. As a result, many they into problems when running advanced operations like formatting, moving files around, etc.
In this guide, we’re going to cover how you can quickly find information about your hard drive. We’ll go over how to discover the drive label, partition information, UUID info and more!
Hard drive label
On Addictivetips, I reference the LSBLK tool quite a lot in my Linux tutorials. The reason I talk about it so much is that it’s incredibly useful for day-to-day operations on Linux, especially with things that have to do with hard drives and other removable data storage devices on the platform.
Lsblk isn’t a program you’ll ever need to install. It’s a core utility on all Linux distributions and is intended for basic diagnostic purposes. Furthermore, the Lsblk tool doesn’t require a root account or even “sudo” access. Not requiring root means that even if you’re using Linux on a PC with no ability to enter system-level commands easily, you’ll still be able to quickly and easily view the information you need.
To use Lsblk with its primary function, launch a terminal window. Unsure about how to find the terminal on your Linux PC? Press Ctrl + Shift + T on the keyboard. Alternatively, you can use the Ctrl + Alt + T keyboard combination to open a window as well.
When the terminal window is open, run the command below.
After running the lsblk command in a terminal, you’ll see a tree-like structure. This structure shows you several columns, such as NAME, MAJ: MI, RM, SIZE, RO, TYPE, and MOUNTPOINT.
All of the names in the tree list are important, and you can use them to determine information about your storage devices. However, the only thing that matters when you’re trying to figure out a hard drive label is the “NAME” column.
For example, I have several hard drives plugged in, and I need to find the name of my 931 GB hard drive. So, to find the correct label for my usual I’d do the following.
Step 1: go to the “SIZE” column and look for the hard drive that is 931.5G.
Step 2: move on from the “SIZE” column backward and make my way to “NAME” on that same line. The “NAME” area will show me the 931.5 GB drive’s label is/dev/sda.
Locate partition names
Another use of the Lsblk command is its ability to show the user partition information. It works a lot like viewing device names. To do it, execute the lsblk command like usual.
Once the command prints the info out on screen, locate the drive you’d like to find partition info for. Then, scroll down and look at the tree diagram under “NAME.”
In the tree diagram, Lsblk will show you lines pointing to each of the partitions. Each partition’s name is denoted by a number. For example, under /dev/sda (the 931.5 GB drive used in the example) we see two partitions. Their names are /dev/sda1 and /dev/sda2.
Find UUID info
If you’re manually setting up a hard drive on your Linux system, you’ll need to add an entry in the /etc/fstab file. Usually, setting up a drive requires special information, known as a UUID (universally unique identifier).
There are a few ways to find the UUID information for a hard drive on Linux, but by far the quickest and easiest way is by once again using the Lsblk tool with the -f switch.
Note: you may need to use sudo to access the UUID info with Lsblk, as some Linux OSes disable the ability to view it as a regular user.
To access your UUID info, run:
Or, if your system disables viewing UUID info on drives as a regular user, do:
sudo lsblk -f
When the command output finishes, you’ll see the Lsblk tool print out drive information as it usually does, with a new “UUID” column.
Save UUID info
Need to save the UUID information for later? In the terminal window, enter the following command.
Note: the command written out below is an example. Be sure to replace the X with the UUID code output that appears when you run the lsblk -f command in terminal.
echo "X" >> ~/my-uuid.txt
View the saved UUID text file at any time in the terminal by using the cat tool.
Or, if you’re not a fan of Cat, consider opening it up in the Nano text editor for a better viewing experience.