Most average Linux users or beginners often lack the know-how to retrieve hard drive information on Linux. Hence, in this article, Mytour will walk you through finding information about hard drives on Linux.
Finding Hard Drive Information
Discover Various Methods to Find Linux Hard Drive Information, with LSBLK Tool Being the Most Popular.
Lsblk isn't a standalone program, so you won't need to install it. Essentially, Lsblk is a core utility across all Linux distributions, used for diagnostics. Moreover, it doesn't require root access or 'sudo' privileges.
Not needing root access means even on a Linux machine without the ability to execute system-level commands, you can still quickly view the information you need.
To use Lsblk to find hard drive information, first open a Terminal window by pressing Ctrl + Shift + T or Ctrl + Alt + T. In the Terminal window, enter the following command:
lsblk
On the screen, you'll see a tree-like structure. This structure displays columns including NAME, MAJ: MI, RM, SIZE, RO, TYPE, and MOUNTPOINT. Your task is to find the hard drive name in the NAME column.
For instance, in this case, you need to find the 931 GB hard drive. To find the hard drive name, follow the steps below:
Step 1: Navigate to the SIZE column and locate the 931.5 GB hard drive.
Step 2: Next, move to the NAME column on the same row, the name of the 931.5 GB hard drive displayed in the NAME column is /dev/sda.
Find Partition Names
Additionally, the Lsblk command is capable of displaying user partition information. To do this, first open a Terminal window and enter the following command:
lsblk
After running the command, the information will be displayed on the screen, locate the hard drive you want to find partition information for, then scroll down and look at the diagram in the NAME column.
In the diagram, Lsblk will show you lines pointing to each partition, the name of the partition is indicated by a number. For example, in the /dev/sda drive (the 931.5 GB hard drive in the example above) there are 2 partitions, these partitions are named /dev/sda1 and /dev/sda2 respectively.
Find UUID Information
If you manually install the hard drive on a Linux computer, you will need to add an entry to the /etc/fstab file. Typically, setting up a hard drive requires specific information, known as UUID (universally unique identifier).
There are numerous ways to find UUID information for hard drives on Linux, however, the quickest and simplest method is to use the Lsblk tool combined with the -f command.
Note: You'll need to use sudo to access UUID information with Lsblk, as some Linux operating systems disable the ability to view information under regular user permissions.
To access UUID information, run the command:
lsblk -f
Alternatively, if the Linux system doesn't allow viewing UUID information for hard drives under regular user permissions, use the command:
sudo lsblk -f
After executing the command, the Lsblk tool will print hard drive information, including a new UUID column.
Save UUID Information
If you need to save UUID information for later use, on the Terminal window, you enter the following command:
Note: In the command below, replace X with the UUID output code displayed when you run the lsblk -f command in the terminal.
echo 'X' >> -/my-uuid.txt
To view the saved UUID file, we use the Cat command. On the Terminal window, enter the following command:
cat -/my-uuid.txt
Or if you prefer not to use the Cat command, another way is to open the file in the Nano text editor:
nano -/my-uuid.txt
This article by Mytour has just guided you on how to find hard drive information on Linux. We hope this article provides you with some new useful information. If you have any doubts or questions that need answering, readers can leave their comments below the article. If you're using the Windows operating system, you can refer to how to check hard drive here.