Getting hard disk drive serial number at the terminal - not the WWN

2,033

Solution 1

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

Solution 2

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

Solution 3

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.

Solution 4

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
configuration:  
  ansiversion   =   5
  logicalsectorsize =   512
  sectorsize    =   512
  signature =   d46cf327
Share:
2,033

Related videos on Youtube

Roberto
Author by

Roberto

Updated on September 18, 2022

Comments

  • Roberto
    Roberto almost 2 years

    following the angular documentation

    ng-options guidelines

    I write that part of code:

    <select ng-model="model" ng-options="item.CODE as item.NAME disable when item.DISABLE for item in list" id="foo" name="foo" ng-change="change()">
    

    but return me back this error:

    Syntax Error: Token 'disable' is an unexpected token at column 11 of the expression [{3}] starting at [{4}].

    What I'm doing wrong?

    • robbat2
      robbat2 about 7 years
      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.
  • Victor Benetatos
    Victor Benetatos about 8 years
    Well, he is having an object data source, i thing, not an array!
  • Jenish Rabadiya
    Jenish Rabadiya about 8 years
    @VictorBenetatos the name(list) gave me hint it is the array.
  • ste2425
    ste2425 about 8 years
    Are you saying item.one as item.two cannot be used when using disable?
  • Jenish Rabadiya
    Jenish Rabadiya about 8 years
    @ste2425 ummm, Yes it is as per the document.
  • Jenish Rabadiya
    Jenish Rabadiya about 8 years
    Well, I think Whole ngOption directive was not there in earlier version.
  • ste2425
    ste2425 about 8 years
    @JenishRabadiya ahh didn't see the version of the docs, as mentioned this is perfectly valid syntax in newer version which confused me.
  • Roberto
    Roberto about 8 years
    I'm using version 1.4.4
  • Roberto
    Roberto about 8 years
    So you think the problem is that I'm using an array with that format: [{CODE: "", NAME: "", DISABLE: true}, ..]
  • Jenish Rabadiya
    Jenish Rabadiya about 8 years
    @Roberto Yes. or use this syntex select as label disable when disable for (key, value) in object
  • Roberto
    Roberto about 8 years
    I try as you write in your first answer but still didn't work. Now I'm going to try with new syntax you write now.
  • Jenish Rabadiya
    Jenish Rabadiya about 8 years
    @Roberto it works look at my plunk here.
  • Roberto
    Roberto about 8 years
    @Jenish yes but doing like that on the select appear the CODE string and not the NAME string
  • Roberto
    Roberto about 8 years
    I need that the select show the tiem.NAME but to the MODEL go the item.CODE
  • ron
    ron about 7 years
    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
    ron about 7 years
    That was on an HGST drive where ID_MODEL is also reported correctly as HUC109060CSS600.
  • ron
    ron about 7 years
    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.
  • cat
    cat about 7 years
    @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
  • Peter Mortensen
    Peter Mortensen about 7 years
  • RonJohn
    RonJohn about 5 years
    The -html option is not needed.
  • Benyamin Jafari
    Benyamin Jafari almost 5 years
    How to retrieve hard disk serial when I use a VM ubuntu? The above commands return nothing on this situation
  • Ishara Samintha
    Ishara Samintha over 4 years
    when i change to code.angularjs.org/1.4.5/angular.js (v1.4.5) this version disable things worked fro me earlier i had v1.3.0