Serial Number: WD-WX32DB0R7SEP
Serial Number: 78EWNTNAS
first drive output was:
ID_SCSI=1
ID_VENDOR=External
ID_VENDOR_ENC=External
ID_MODEL=USB3.0_DISK03
ID_MODEL_ENC=USB3.0\x20DISK03\x20\x20\x20
ID_REVISION=0103
ID_TYPE=disk
ID_SERIAL=33044564198838960
ID_SERIAL_SHORT=3044564198838960
ID_SERIAL_COMPAT=
ID_WWN=0x3044564198838960
ID_WWN_WITH_EXTENSION=0x3044564198838960
ID_SCSI_SERIAL=DD5641988389F
second
ID_SCSI=1
ID_VENDOR=External
ID_VENDOR_ENC=External
ID_MODEL=USB3.0_DISK04
ID_MODEL_ENC=USB3.0\x20DISK04\x20\x20\x20
ID_REVISION=0103
ID_TYPE=disk
ID_SERIAL=33044564198838960
ID_SERIAL_SHORT=3044564198838960
ID_SERIAL_COMPAT=
ID_WWN=0x3044564198838960
ID_WWN_WITH_EXTENSION=0x3044564198838960
ID_SCSI_SERIAL=DD5641988389F
Mhm, it seems then that in your case, not even the serial numbers (SCSI or otherwise) are differentiated. In @greg_r’s case serial numbers were different (matching the ones on the printed label) which then allowed for that script/udev rule combination to work. In your case, since there is no “good” differentiating factor (and the ID_MODEL based on which bay the disk is in, is likely not a good candidate) I don’t think the approach outlined by @greg_r will work for you.
Which orico enclosure model are you using?
I have 6558US3-C, it also say 5HDD duplicator, that might be the issue?
Good question. another shot in the dark from my side, if you run
sudo smartctl --all /dev/sda
and sudo smartctl -all /dev/sdb
what do you get then? It might be that smartctl
actually provides the “real” serial number instead of the one the enclosure overrides.
not sure if I am doing it correctly:
darkdeny@Shanghai:~> sudo smartctl -all /dev/sdb
smartctl 7.2 2021-09-14 r5237 [x86_64-linux-5.14.21-150400.24.46-default] (SUSE RPM)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org
=======> INVALID ARGUMENT TO -l: l
=======> VALID ARGUMENTS ARE: error, selftest, selective, directory[,g|s], xerror[,N][,error], xselftest[,N][,selftest], background, sasphy[,reset], sataphy[,reset], scttemp[sts,hist], scttempi
nt,N[,p], scterc[,N,M], devstat[,N], defects[,N], ssd, gplog,N[,RANGE], smartlog,N[,RANGE], nvmelog,N,SIZE <=======
I think I got it
first hdd:
darkdeny@Shanghai:~> sudo smartctl /dev/sdb --all
smartctl 7.2 2021-09-14 r5237 [x86_64-linux-5.14.21-150400.24.46-default] (SUSE RPM)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Toshiba P300 (CMR)
Device Model: TOSHIBA HDWD130
Serial Number: 78EWNTNAS
LU WWN Device Id: 5 000039 fe6e8c317
Firmware Version: MX6OACF0
User Capacity: 3,000,592,982,016 bytes [3.00 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: 7200 rpm
Form Factor: 3.5 inches
Device is: In smartctl database [for details use: -P show]
ATA Version is: ATA8-ACS T13/1699-D revision 4
SATA Version is: SATA 3.0, 6.0 Gb/s (current: 3.0 Gb/s)
Local Time is: Thu Apr 11 19:08:31 2024 MSK
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
second:
darkdeny@Shanghai:~> sudo smartctl /dev/sda --all
smartctl 7.2 2021-09-14 r5237 [x86_64-linux-5.14.21-150400.24.46-default] (SUSE RPM)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Western Digital Blue (SMR)
Device Model: WDC WD40EZAZ-00SF3B0
Serial Number: WD-WX32DB0R7SEP
Firmware Version: 0967
User Capacity: 4,000,787,030,016 bytes [4.00 TB]
Sector Size: 512 bytes logical/physical
Device is: In smartctl database [for details use: -P show]
ATA Version is: ATA/ATAPI-7 (minor revision not indicated)
Local Time is: Thu Apr 11 19:09:29 2024 MSK
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
That’s a good sign. So, I think, you could place the line in the bash script that contain hdparm
with this line:
replace this:
SERIAL=`expr substr "$(/sbin/hdparm -I $1 | grep Serial\ Number)" 22 8`
with this:
SERIAL=`expr substr "$(/usr/sbin/smartctl --all $1 | grep Serial\ Number)" 19 20`
Save, exit.
File is already set to executable since you ran it already (otherwise chmod +x orico_id
)
try running the orico_id /dev/sda
and orico_id /dev/sdb
… theoretically the Serials should now be different, and then you should be able to use the dev rule as it was written above.
hmm, not sure I am getting correct result
darkdeny@Shanghai:~> /usr/lib/udev/orico_id /dev/sdc
ID_SCSI=1
ID_VENDOR=
ID_VENDOR_ENC=
ID_MODEL=
ID_MODEL_ENC=
ID_REVISION=
ID_TYPE=
darkdeny@Shanghai:~> /usr/lib/udev/orico_id /dev/sda
ID_SCSI=1
ID_VENDOR=
ID_VENDOR_ENC=
ID_MODEL=
ID_MODEL_ENC=
ID_REVISION=
ID_TYPE=
darkdeny@Shanghai:~> /usr/lib/udev/orico_id /dev/sdb
ID_SCSI=1
ID_VENDOR=
ID_VENDOR_ENC=
ID_MODEL=
ID_MODEL_ENC=
ID_REVISION=
ID_TYPE=
what could I miss to change?
Mhm, it looks like it’s just printing what smartctl
provides (empty, too).
This is the code I changed and ran:
#!/bin/sh
SERIAL=`expr substr "$(/usr/sbin/smartctl --all $1 | grep Serial\ Number)" 22 8`
SERIAL_HEX=`echo -n "$SERIAL" | xxd -ps -c 200`
EXPORTS=`/usr/lib/udev/scsi_id --export --whitelisted -d $1`
EXPORTS="${EXPORTS/ID_SERIAL=33000000000000000/ID_SERIAL=ORICO_hdparm-sn-$SERIAL}"
EXPORTS="${EXPORTS/ID_SERIAL_SHORT=3000000000000000/ID_SERIAL_SHORT=$SERIAL}"
EXPORTS="${EXPORTS/ID_WWN=0x3000000000000000/ID_WWN=0x$SERIAL_HEX}"
EXPORTS="${EXPORTS/ID_WWN_WITH_EXTENSION=0x3000000000000000/ID_WWN_WITH_EXTENSION=0$SERIAL_HEX}"
echo "$EXPORTS"
which then results in an output like this (granted I don’t have the enclosure but virtual disks, but the original smartctl command we both tried provided the same relevant output.
rockwurst:~ # /usr/lib/udev/orico_id /dev/sda
ID_SCSI=1
ID_VENDOR=ATA
ID_VENDOR_ENC=ATA\x20\x20\x20\x20\x20
ID_MODEL=VBOX_HARDDISK
ID_MODEL_ENC=VBOX\x20HARDDISK\x20\x20\x20
ID_REVISION=1.0
ID_TYPE=disk
ID_SERIAL=1ATA_VBOX_HARDDISK_VB409035cf-baf0db55
ID_SERIAL_SHORT=ATA_VBOX_HARDDISK_VB409035cf-baf0db55
ID_SERIAL_COMPAT=
ID_SCSI_SERIAL=VB409035cf-baf0db55
smartctl /dev/sda --all
smartctl 7.2 2021-09-14 r5237 [x86_64-linux-5.14.21-150400.24.100-default] (SUSE RPM)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Device Model: VBOX HARDDISK
Serial Number: VB409035cf-baf0db55
so, not sure. since I’m using PuTTY and am logged in as root that’s the only difference I would see.
Well, this shows you, that I don’t really know bash all that well. Looking more into the program above, it seems in the end it only prints the output of the line
/usr/lib/udev/scsi_id --export --whitelisted -d $1
Since in my VM based example all items are populated correctly, it shows up just fine.
If I understand correctly the other export lines below are bash-based replacements. So, in your case using the above information those lines probably need to look like this:
EXPORTS="${EXPORTS/ID_SERIAL=33044564198838960/ID_SERIAL=ORICO_hdparm-sn-$SERIAL}"
EXPORTS="${EXPORTS/ID_SERIAL_SHORT=33044564198838960/ID_SERIAL_SHORT=$SERIAL}"
EXPORTS="${EXPORTS/ID_WWN=0x3044564198838960/ID_WWN=0x$SERIAL_HEX}"
EXPORTS="${EXPORTS/ID_WWN_WITH_EXTENSION=0x3044564198838960/ID_WWN_WITH_EXTENSION=0$SERIAL_HEX}"
within the original export it searches for the combo of the variable, e.g. ID_SERIAL along with its assigned value, which should be your “fake” serial number, and then replaces it with the one gleaned from the first command, following this syntax
${variable//pattern/replacement}
still don’t know, why suddenly nothing shows up for you at all … you might have to fiddle with the replacements to populate all relevant fields correctly … again, limited knowledge from my side on both bash and udev rules.
As an aside, here is a nice tutorial on the various ways on how to deal with variables (substitution is in section 5):
https://www.cyberciti.biz/tips/bash-shell-parameter-substitution-2.html
I finally broke through some my mistakes, now script reports different ids for different hdds:
darkdeny@Shanghai:~> sudo /usr/lib/udev/orico_id /dev/sda
hdd serial is WX32DB0R
hex serial is 5758333244423052
ID_SCSI=1
ID_VENDOR=External
ID_VENDOR_ENC=External
ID_MODEL=USB3.0_DISK03
ID_MODEL_ENC=USB3.0\x20DISK03\x20\x20\x20
ID_REVISION=0103
ID_TYPE=disk
ID_SERIAL=ORICO_hdparm-sn-WX32DB0R
ID_SERIAL_SHORT=WX32DB0R
ID_SERIAL_COMPAT=
ID_WWN=0x5758333244423052
ID_WWN_WITH_EXTENSION=05758333244423052
ID_SCSI_SERIAL=DD5641988389F
darkdeny@Shanghai:~> sudo /usr/lib/udev/orico_id /dev/sdb
hdd serial is WNTNAS
hex serial is 574e544e4153
ID_SCSI=1
ID_VENDOR=External
ID_VENDOR_ENC=External
ID_MODEL=USB3.0_DISK04
ID_MODEL_ENC=USB3.0\x20DISK04\x20\x20\x20
ID_REVISION=0103
ID_TYPE=disk
ID_SERIAL=ORICO_hdparm-sn-WNTNAS
ID_SERIAL_SHORT=WNTNAS
ID_SERIAL_COMPAT=
ID_WWN=0x574e544e4153
ID_WWN_WITH_EXTENSION=0574e544e4153
ID_SCSI_SERIAL=DD5641988389F
but in the WebUI it still reports duplicated serial.
Finally I also was able to replace ID_SCSI_SERIAL in my script, but that is not enough yet. I wonder what other variables I need to replace?..
I updated /usr/lib/udev/rules.d/60-persistent-storage.rules
with my serial, but no luck yet.
Is there a way to debug/diagnose those udev rules from /usr/lib/udev/rules.d/
folder?
from what I understand you can increase the log level by
udevadm control --log-level=debug
and then you can check with in journalctl
(maybe with journalctl -f
if you’re executing a udev rule in the running system, otherwise not that option)
Once, done, set it back to the original setting:
udevadm control --log-level=info