udevadm info --query=all --name=/dev/sda | grep ID_SERIAL
lsblk
, mentioned by don_crissti, leverages, but my version of lsblk does not include the option for serial.lshw
or smartctl
# lshw -class disk
# smartctl -i /dev/sda
-n
if you don't want to print the header line:device
as argument to get only the serial number of a specific device:lsblk
lists information about all available (or the specified) block devices. Now, for those who do not know what that last term means:lsblk
as you can simply add more columns e.g type
(device type) and/or tran
(device transport type) etc:hdparm
you can see your Harddisk serial number from terminal.ls -l /dev/disk/by-id
because it'll show a disk's WWN if available. The WWN is usually printed on the disk's label, so it's easy to identify.wwn-id
for the disk. The awk
filter may need to be adjusted depending on the OS distribution and version.I needed a scripted solution to read the wwn-id
, which is needed for Pacemaker disk fencing.If partitions (/dev/sdX1
e.g.) have already been created another grep
is needed to filter the output: