How to find the serial number of a hard drive in Linux

Categories

How to find the serial number of a hard drive in Linux

You are here:

Knowing the serial numbers of your hard drives can be really useful in many cases, but it is mostly common in replacing the specific drive in your server.

 

First, we will need smartmontools package. To install it we need to use the following command:

CentOS/Almalinux/Rockylinux/Redhat:

sudo yum install smartmontools

Debian/Ubuntu:

sudo apt-get install smartmontools

 

To get the serial number of a specific drive in our server simply use the following command (replacing /dev/sdX with the device name of the drive you want a serial number from e.g. /dev/sda or /dev/nvme0n1):

sudo smartctl -a /dev/sdX | grep Serial

 

If you don’t know what your devices are called you can type:

lsblk

to get a list of all the drives that are connected to your system. For example:

[root@cp-dev3 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 594M 0 loop /var/tmp
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 600M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
├─sda3 8:3 0 2G 0 part [SWAP]
└─sda4 8:4 0 16.4G 0 part /

Here there is only 1 drive and it is called /dev/sda

Table of Contents