Harddisk serial number from terminal?

Another solution which does not require root privileges:

udevadm info --query=all --name=/dev/sda | grep ID_SERIAL

This is actually the library that lsblk, mentioned by don_crissti, leverages, but my version of lsblk does not include the option for serial.


In terminal type:

# hdparm -I /dev/sd? | grep 'Serial\ Number'

EDIT: You can also use lshw or smartctl

  • lshw

    # lshw -class disk

  • smartctl

    # smartctl -i /dev/sda

If you are missing those tools, just install following packages

# apt-get install hdparm
# apt-get install smartmontools
# apt-get install lshw

Device1 name and corresponding serial number:

lsblk --nodeps -o name,serial

output:

NAME SERIAL
sda  0000000012400917BA30
sdb  0000000012400917BA96

add -n if you don't want to print the header line:

lsblk --nodeps -no name,serial

output:

sda  0000000012400917BA30
sdb  0000000012400917BA96

Pass device as argument to get only the serial number of a specific device:

lsblk --nodeps -no serial /dev/sda

output:

0000000012400917BA30

Keep in mind lsblk lists information about all available (or the specified) block devices. Now, for those who do not know what that last term means:
In general, block devices are devices that store or hold data. Diskette drives, hard drives and CD-ROM drives are all block devices. But that's not a problem when using lsblk as you can simply add more columns e.g type (device type) and/or tran (device transport type) etc:

lsblk --nodeps -no name,serial,type,tran
sda  0000000012400917BA30     disk sata
sdb  0000000012400917BA96     disk sata
sr0  4B583242334C453233353320 rom  usb