How to Find a Hard Drive Serial Number in Linux
When managing your Linux system, it’s crucial to keep track of your hard disk or storage devices, and one key piece of information is the serial number of your storage drives.
The serial number uniquely identifies each drive and is essential for various administrative tasks such as troubleshooting, monitoring, and maintenance.
In this guide, we’ll explore several methods, both command-line and graphical, to find the serial number of your hard drives in a Linux environment.
1. lshw (List Hardware)
The lshw command is a small tool that helps find out all the details about the hardware in your computer.
It tells you things like how much memory you have, the version of the software running on your hardware, details about your mainboard, the type and speed of your CPU, information about your cache, and the speed of your bus.
To find the serial number of your hard drive, use the following command, which will display a list of block devices along with their serial numbers as shown.
sudo lshw -class disk OR sudo lshw -class disk | grep serial
2. lsblk (List Block Devices)
The lsblk command is used to list detailed information about all available storage devices connected to the system including details like names, sizes, and types, giving a structured overview of block devices.
To display a list of block devices along with their serial numbers, run:
lsblk -o NAME,SERIAL
3. smartctl (SMART Control)
smartctl is a command-line tool used to keep track of and control storage drives equipped with SMART (Self-Monitoring, Analysis and Reporting Technology) capability.
It offers in-depth details about the drive’s health, performance, and most importantly, its serial number, aiding in drive identification and diagnostics.
To use the smartctl command, you need to install it on your Linux system by using the following appropriate command for your specific Linux distribution.
sudo apt install smartmontools [On Debian, Ubuntu and Mint] sudo yum install smartmontools [On RHEL/CentOS/Fedora and Rocky/AlmaLinux] sudo emerge -a sys-apps/smartmontools [On Gentoo Linux] sudo apk add smartmontools [On Alpine Linux] sudo pacman -S smartmontools [On Arch Linux] sudo zypper install smartmontools [On OpenSUSE]
After installing it, you can use smartctl to locate the serial number.
sudo smartctl -i /dev/sda
Make sure to replace /dev/sda
with your actual hard disk and look for the “Serial Number” field in the output as shown.
4. udevadm (udev administration)
The udevadm command is used to control and query the udev (device manager) service to get information about devices and their properties and perform other administrative tasks related to device management on a Linux system.
To get the serial number of a hard disk using udevadm, you can use the following command.
udevadm info --query=property --name=/dev/sda | grep SERIAL
5. hdparm (Get/Set ATA/SATA Drive Parameters)
The hdparm command is a command-line tool that is used to inspect and adjust settings for hard disk storage drives by providing detailed information like the serial number, model, and firmware details of connected drives.
To use the hdparm command, you need to install it on your Linux system by using the following appropriate command for your specific Linux distribution.
sudo apt install hdparm [On Debian, Ubuntu and Mint] sudo yum install hdparm [On RHEL/CentOS/Fedora and Rocky/AlmaLinux] sudo emerge -a sys-apps/hdparm [On Gentoo Linux] sudo apk add hdparm [On Alpine Linux] sudo pacman -S hdparm [On Arch Linux] sudo zypper install hdparm [On OpenSUSE]
After installing it, you can use hdparm to find the serial number.
sudo hdparm -i /dev/sda | grep SerialNo
6. inxi Command
The inxi command is used to gather and display information about the system configuration including detailed information about the hardware, CPU, memory, graphics, network, serial number, and more.
To use the inxi command, you need to install it on your Linux system by using the following appropriate command for your specific Linux distribution.
sudo apt install inxi [On Debian, Ubuntu and Mint] sudo yum install inxi [On RHEL/CentOS/Fedora and Rocky/AlmaLinux] sudo emerge -a sys-apps/inxi [On Gentoo Linux] sudo apk add inxi [On Alpine Linux] sudo pacman -S inxi [On Arch Linux] sudo zypper install inxi [On OpenSUSE]
After installing it, you can use inxi to find the serial number.
inxi -Dxx
7. GParted (GNOME Partition Editor)
GParted is a graphical partition editor that is used to create, resize, delete, move, and manage disk partitions on various storage devices, such as hard drives and USB drives.
To use the GParted tool, you need to install it on your Linux system by using the following appropriate command for your specific Linux distribution.
sudo apt install gparted [On Debian, Ubuntu and Mint] sudo yum install gparted [On RHEL/CentOS/Fedora and Rocky/AlmaLinux] sudo emerge -a sys-apps/gparted [On Gentoo Linux] sudo apk add gparted [On Alpine Linux] sudo pacman -S gparted [On Arch Linux] sudo zypper install gparted [On OpenSUSE]
After installing it, open GParted either through your system’s application menu or by running the following command in the terminal.
sudo gparted
In the GParted interface, select the hard disk for which you want to find the serial number from the drop-down menu in the upper-right corner.
After selecting the disk, click on the “View” menu and choose “Device Information“, which will provide you with detailed information about the selected disk, including its serial number.
8. Disks (Gnome-Disks)
gnome-disks is a graphical utility for the GNOME desktop environment that is used to manage and analyze disk drives and storage devices. Also, it provides information about storage devices, manages partitions, formats disks, and performs other disk-related tasks.
Open gnome-disks either through your system’s application menu or by running the following command in the terminal.
sudo gnome-disks
You will see a list of available disks in the left panel of gnome-disks. Click on the disk for which you want to find the serial number.
Conclusion
Whether you prefer the command line or a graphical interface, Linux offers a variety of tools to help you find the serial number of your storage drives.
These methods empower you to efficiently manage and monitor your storage devices, enhancing the overall stability and performance of your Linux system.