diskinfo can not show serial number, but camcontrol can

I have a external hdd disk enclosure, have some disks in it. But disk listed as `/dev/diskid/DISK-000000000000`,

camcontrol ident da0 can show serial number
Code:
pass4: <WDC WD40EZRZ-00GXCB0 80.00A80> ACS-3 ATA SATA 3.x device
pass4: 400.000MB/s transfers

protocol              ATA/ATAPI-10 SATA 3.x
device model          WDC WD40EZRZ-00GXCB0
firmware revision     80.00A80
serial number         WD-WCC7K2STN2FE
WWN                   50014ee20ef05e03
cylinders             16383
heads                 16
sectors/track         63
sector size           logical 512, physical 4096, offset 0
LBA supported         268435455 sectors
LBA48 supported       7814037168 sectors
PIO supported         PIO4
DMA supported         WDMA2 UDMA6
media RPM             5400

Feature                      Support  Enabled   Value           Vendor
read ahead                     yes      yes
write cache                    yes      yes
flush cache                    yes      yes
overlap                        no
Tagged Command Queuing (TCQ)   no       no
Native Command Queuing (NCQ)   yes              32 tags
NCQ Queue Management           no
NCQ Streaming                  no
Receive & Send FPDMA Queued    no
SMART                          yes      yes
microcode download             yes      yes
security                       yes      no
power management               yes      yes
advanced power management      no       no
automatic acoustic management  no       no
media status notification      no       no
power-up in Standby            yes      no
write-read-verify              no       no
unload                         no       no
general purpose logging        yes      yes
free-fall                      no       no
Data Set Management (DSM/TRIM) no
Host Protected Area (HPA)      yes      no      7814037168/1
HPA - Security                 no

But diskinfo -v da0 could not get serial number
Code:
da0
        512             # sectorsize
        4000787030016   # mediasize in bytes (3.6T)
        7814037168      # mediasize in sectors
        4096            # stripesize
        0               # stripeoffset
        486401          # Cylinders according to firmware.
        255             # Heads according to firmware.
        63              # Sectors according to firmware.
        000000000000    # Disk ident.
        Not_Zoned       # Zone Mode

my external enclosure is using JMicron USB to ATAATAPI Bridge.
 
So what is the actual question?

Code:
root@hera:~ # smartctl -i /dev/ada0
smartctl 6.5 2016-05-07 r4318 [FreeBSD 11.1-RELEASE-p4 amd64] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     SiliconMotion based SSDs
Device Model:     TS64GSSD370S
Serial Number:    D646741862
Firmware Version: P1225CA
User Capacity:    64,023,257,088 bytes [64.0 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-2 (minor revision not indicated)
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 3.0 Gb/s)
Local Time is:    Thu Nov 30 22:19:47 2017 EST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
 
You look at the source code of diskinfo, and see how it gathers the name of the disk. Then you decide: Is this a bug, and displaying the real diskid is an important function of diskinfo? If yes, fix it (either you fix it, or you contact the author or recent maintainer of diskinfo and ask them to fix it). Or perhaps diskinfo displaying the name is only a courtesy, done if easy and convenient, and users shouldn't rely on it anyway, in which case the program might be correct as it is. Or perhaps if diskinfo is designed to only display the name sometimes, it should never display it in the first place, as there are other ways to get the name (camcontrol clearly is the better way).

In your case, it's even more tricky: You say the disk is visible in the /dev/ file system as /dev/diskid/DISK-00..., which means the operating system's way to determine disk names is not working for this disk. Which might be fine but inconvenient, the disk is still accessible.

Underlying all this is the problem that getting the name of a disk is surprisingly difficult. To begin with, the technique used to determine the name (or id) of a disk is different for different access protocols, for example SCSI versus SATA (or ATA or IDE). In the old days (I think before the SCSI-2 standard and its CCS predecessor), disks didn't even have to have names: with parallel SCSI I think it was still legal for a disk drive to support read/write/read capacity and not identify commands, in which case there really wasn't a way to get the name of the disk. And then, early in SCSI-2, disks had to have a manufacturer, model and revision, but did not yet to have serial numbers, so sometimes you could not distinguish two disks of the same model. The requirement for serial numbers and WWN (world-wide names, a way to make sure every disk has a unique identifier) came with the required support for VPD pages, years later.

Now add to that: the way that Unixes create device file entries for hardware they find is also tricky; the /dev/diskid/... directory is really a courtesy to users, the same devices are also visible as /dev/da... or /dev/ada... or such. So to debug this problem, you need to understand quite a bit about how SATA works (in your case), in particular through extenders, and how the operating system names block devices.
 
  • Thanks
Reactions: Oko
Back
Top