Alright, I found a much better solution for this:

# SCSI EVPD page 0x80 values
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI}=="1", IMPORT{program}="/usr/bin/sg_inq 
--export --inhex=/sys/block/$kernel/device/vpd_pg80 --raw", ENV{ID_SCSI_SN}="1"
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI_SN}!="1" GOTO="sg3_utils_id_end"
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI}=="1", ENV{ID_SCSI_SN}!="1", 
IMPORT{program}="/usr/bin/sg_inq --export --page=sn $tempnode", 
ENV{ID_SCSI_SN}="1"

I fail the USB SCSI device only if it does not contain VPD_PG80.. and
then it keeps its serial as it won't support SCSI commands anyway. This
is better because it keeps compatibility with SCSI protocol, for USB
drives supporting not only SCSI commands but also SCSI protocol itself:

Example for a memory stick (only SCSI commands):

$ sudo sg_inq --export --inhex=/sys/block/sdc/device/vpd_pg80 --raw
unable to open binary file /sys/block/sdc/device/vpd_pg80: No such file or 
directory

This will make udev to stop all other rules (and stop udev for running
another INQ directly to the device, which would fail).

Now, for a device that supports SCSI protocol:

$ sudo sg_inq --export --inhex=/sys/block/sdb/device/vpd_pg80 --raw
SCSI_IDENT_SERIAL=NA7EMXLG

then udev will keep running all other udev rules (and get a new
SCSI_SERIAL_SN, for example).

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1833618

Title:
  MAAS can't deploy Ubuntu if ID_SERIAL of any block device is broken
  (USB pendrive in this case).

To manage notifications about this bug go to:
https://bugs.launchpad.net/curtin/+bug/1833618/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to