Drive Serial Numbers

I've read through many threads on this and still don't get consistent results.

I would like to understand how to reliably get the serial number off of drives that I attach to the system so that I can print a label for them and use that information when things go south later for a drive.

I noticed that if the drive is attached via sata cable:

Code:
geom disk list
Geom name: ada0
Providers:
1. Name: ada0
   Mediasize: 1000204886016 (932G)
   Sectorsize: 512
   Mode: r1w1e2
   descr: Samsung SSD 870 EVO 1TB
   lunid: 5002538f3344dfe6
   ident: S75BNS0W426986P
   rotationrate: 0
   fwsectors: 63
   fwheads: 16

Is accurate. The ident field is correct.

However, if I try it on a USB connection:

Code:
Geom name: da0
Providers:
1. Name: da0
   Mediasize: 1000204886016 (932G)
   Sectorsize: 512
   Mode: r0w0e0
   descr: ASMT USB 3.0 Destop H
   lunid: 5000000000000001
   ident: 0000000007FC
   rotationrate: unknown
   fwsectors: 63
   fwheads: 255

The ident field is ridiculous (seems to refer to the USB adapter).

Smartctl seems to be the best bet, even with the drive attached to USB.

Code:
sudo smartctl -ax /dev/da0
smartctl 7.4 2023-08-01 r5530 [FreeBSD 14.0-RELEASE-p5 amd64] (local build)
Copyright (C) 2002-23, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Samsung based SSDs
Device Model:     Samsung SSD 870 EVO 1TB
Serial Number:    S75BNS0W428794Z
LU WWN Device Id: 5 002538 f3344e810
Firmware Version: SVT03B6Q

My question is what's canonical - what should "always" work?
 
use
camcontrol identify [device id]

# camcontrol identify ada0
pass0: <Hitachi HDT721010SLA360 ST6OA3AA> ATA8-ACS SATA 2.x device
pass0: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)

protocol ATA8-ACS SATA 2.x
device model Hitachi HDT721010SLA360
firmware revision ST6OA3AA
serial number STR608MS2T8SJY
WWN 5000cca35ee738cb
additional product id
cylinders 16383
heads 16
sectors/track 63
sector size logical 512, physical 512, offset 0
LBA supported 268435455 sectors
LBA48 supported 1953525168 sectors
PIO supported PIO4
DMA supported WDMA2 UDMA6
media RPM 7200
Zoned-Device Commands no

WWN is used for unique ID for the storage.
 
use
camcontrol identify [device id]

Best so far:

Code:
sudo camcontrol identify da0
pass5: <Samsung SSD 870 EVO 1TB SVT03B6Q> ACS-4 ATA SATA 3.x device
pass5: 400.000MB/s transfers

protocol              ACS-4 ATA SATA 3.x
device model          Samsung SSD 870 EVO 1TB
firmware revision     SVT03B6Q
serial number         S75BNS0W216859N
WWN                   5002538f3320aaf2
additional product id
 
Ultimately, diskinfo is built from the same ingredients as all other such tools. And the ingredients are: using whatever protocol the device speaks, ask it what its make/model/serial/revision is. In practice, there are 2-1/2 such protocols: SATA and SCSI; USB storage de-facto implements a version of the SCSI block protocol. So if the device speaks SATA, you ask it to "identify"; if the device speaks SCSI or SCSI over USB, you ask it "inquiry". One of the problems with USB devices is: adapters which provide a USB connection for another device will often return their own identity. In theory, there are special USB mass storage protocol commands to "tunnel an arbitrary SCSI/SATA/... command to the underlying device"; in practice, few applications know how to use these transparent tunnels, and not all USB adapters support them. Supposedly, SmartCtl is one of the applications that can do this.

I've often wondered if there is some way to write your own ID to the firmware of a device...
Absolutely, great idea! The common way to do that is to use the normal GPT partition table, and use unique and descriptive partition labels. Or put an extra small partition on the device, which then contains just one block or file, which contains a copy of the relevant information: "This is Seagate model 123 serial 456, firmware revision ABC. It's owned by RalphBSz, was bought on 5-Jan-2020 from NewEgg, partitioned on 9-Feb-2020, contains the ZFS vdev FooBar which is part of the 3-way mirrored Foo file system.

Interestingly complex storage software systems take this idea one step further. A system such as ZFS has lots of metadata in its storage, and it records some of the above information in that metadata. Other systems I have worked on record even more: hardware model/serial, date put into production, what cluster it is part of and on what node of the cluster it was formatted, where it is physically installed (3rd row of racks from the left, 4th rack, disk enclosure 19U from the bottom, slot 3 rear), a copy of all health issues (had 17 IO errors on 4-Jul-2021, but passed all tests afterwards, average performance is 1.3% faster than similar disks). In a good system, this information is recorded both on the disk itself (so if the disk is separated from the system, it can be identified and diagnosed), but also in redundant form within the system (so if the disk becomes unreadable, we can still figure out what its history had been).

All the required technology for this exists; all it takes is a file system and a partition table, and a few text files.
 
Back
Top