This question already has an answer here:

WWN = world wide name

Seagate Constellation ES, model ST3500514NS, a 500 GB 3.5" SATA drive

It has "serial number", 9WJxxxxx which is eight characters. It has WWN 5000C5002E47xxxx which is a 16 characters. Both are printed on the label on the hard disk drive.

WD model WD4001FFSX, a 4 TB SATA drive

It has "serial number" WMC5D0Dxxxxx which is 12 characters. It has WWN 50014EE003Fxxxxx which is 16 characters.

HGST, model HUC109060CSS600, a 300 GB 2.5" SAS drive

It has "serial number" KWJTxxx, also eight characters. It has WWN... I don't know; it is not printed on the label and not plugged into the system to find out.

For inventory, we generally write down and track the following, which can always be gathered from the label on the drive:

  • Manufacturer
  • Model number
  • Serial number
  • Size in GB or TB, and connection type which is either SATA or SAS
  • Location where in use, or in storage when not in use

The problem arises obviously 1, 2, 3 years later when an inventory sheet shows whatever hard drive. You are pretty sure it's in a running server, but you don't want to shut down the server to pull the hard drive to read the label.

How do you get the serial number of the drive that corresponds to what is on the label?

udevadm info --query=all --name=/dev/sda has ID_SERIAL, but that is the WWN. We don't want another field to track the 16 characters of the WWN as an identifier... And I already hate writing down the long serial numbers of WD drives.

Is there a way in Linux to extract the serial number of the drive?

I believe it is possible because years ago the RAID storage manager GUI we had been using nicely reported the eight-character serial numbers of Seagate drives that were in use. And that RAID hardware has listed a bunch of Seagate-specific hard disk drives that were "officially supported", and if memory serves, really no other make/model of drives.

Is it possible this is hard disk drive firmware related, meaning it can be done on certain make drives and not others?

marked as duplicate by derobert, mdpc, Archemar, rudimeier, don_crissti May 12 '17 at 14:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    There is a problem not mentioned here: Does the drive report a serial that matches what's physically printed on the label? There are definitely some drives in my experience where this is NOT true. – robbat2 May 11 '17 at 21:00

Assuming the disk supports SMART, you should be able to retrieve the disk serial number using smartctl -i /dev/sdX

  • 1
    smartctl -a /dev/sdc | grep Serial seems to give me the result I was looking for. It seems to be very important that /dev/sd? is a single drive, and not a mounted volume or any kind of storage unit, otherwise the value for Serial is bogus. This is on a 2U server holding 16 drives, /dev/sdc is the OS and is configured as JBOD, 7 other drives are RAID5 via LSI raid card, 8 others are RAID5 via 2nd LSI card. – ron May 11 '17 at 16:56
  • 2
    @ron not a mounted volume or any kind of storage unit would logically follow given that /dev/sda is a physical device but /dev/sda1 is a partition and / is a mount point – cat May 11 '17 at 21:23

You can get the serial number through :

1) hdparm:

hdparm -I /dev/sda | grep Serial

2) sginfo is a part of sg3-utils package:

sginfo -a /dev/sda | grep Serial

3) sdparm command :

sdparm -i /dev/sda | grep 'vendor specific'

4) lshw:

lshw -class disk -class storage | grep serial

I only have WD drives to check on now, but udevadm info --query=all shows both ID_SERIAL/ID_SERIAL_SHORT (something like WD-WMATV6212345 and ID_WWN (0x50014ee051234567). Isn't the first what you are looking for?

smartctl -i also shows both, hdparm -i just the serial.

  • so hdparm -i /dev/sdc which is my one operating system drive results in HDIO_DRIVE_CMD(identify) failed: Invalid exchange and HDIO_GET_IDENTITY failed: Invalid argument. I have been completely unable to get hdparm to work at all, this is on SLES 11.4. – ron May 11 '17 at 16:53
  • so udevadm info --query=all --name=/dev/sdc does give the serial number value I am looking for, it is tied to ID_SCSI_SERIAL. The value for any of the others is all the same and is the WWN. – ron May 11 '17 at 17:01
  • That was on an HGST drive where ID_MODEL is also reported correctly as HUC109060CSS600. – ron May 11 '17 at 17:13
  • for a Seagate ST9300603SS, ID_SCSI_SERIAL reports a 20 character serial number, with the first 8 characters matching to the serial number on the label. – ron May 11 '17 at 17:17

The lshw program shows it, at least with html output

sudo lshw -C disk -html > /some/place/hw.html

The relevant section on my hardware for one of my disks -

id: disk
description:    ATA Disk
product:    ST32000542AS
vendor: Seagate
physical id: 0.0.0
bus info: scsi@0:0.0.0
logical name: /dev/sda
version:    CC34
serial: 5XW2PB56
size:   1863GiB (2TB)
capabilities:   partitioned partitioned:dos
  ansiversion   =   5
  logicalsectorsize =   512
  sectorsize    =   512
  signature =   d46cf327
  • The -html option is not needed. – RonJohn May 27 at 23:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.