[systemd-devel] using SYSTEMD_ALIAS with devices that re-appear on different sysfs path
Alexander 'Leo' Bergolth
leo at strike.wu.ac.at
Fri Dec 9 10:28:36 UTC 2016
Hi!
I'd like to uniquely identify USB-disks according to their GTP disk UUID
and assign a corresponding systemd device unit in order to be able to
start/stop services based on them.
However, whenever a USB device is unplugged and replugged again soon
(within a few seconds), there seems to be a small amount of time, where
the old block device node is still there:
Dez 08 21:14:35 apu systemd[1]: Device
sys-block-by\x2duuid-d28e3352\x2d7ce6\x2d4aab\x2d802a\x2d59270088604e.device
appeared twice with different sysfs paths
/sys/devices/pci0000:00/0000:00:1d.0/0000:03:00.0/usb4/4-1/4-1:1.0/host5/target5:0:0/5:0:0:0/block/sdc
and
/sys/devices/pci0000:00/0000:00:1d.0/0000:03:00.0/usb4/4-1/4-1:1.0/host6/target6:0:0/6:0:0:0/block/sdg
In those cases, the new SYSTEMD_ALIAS device is not created. (The alias
pointing to the old sysfs path is also removed some moments later.)
Is there a way to override this behavior so that the new device alias
will override the old one?
Thanks,
--leo
I am using systemd-219-19.el7_2.13.x86_64.
udev rules:
-----------
KERNEL=="sd*", ENV{DEVTYPE}=="disk", ENV{ID_DISK_GUID}!="?*",
IMPORT{program}="/etc/udev/gpt-disk-uuid.sh $devnode"
ENV{DEVTYPE}=="disk", ENV{ID_DISK_GUID}=="?*", RUN+="/usr/bin/logger -t
udevinfo -p daemon.info disk %k, guid: $env{ID_DISK_GUID}"
ENV{DEVTYPE}=="disk", ENV{ID_DISK_GUID}=="?*",
SYMLINK+="disk/by-uuid/$env{ID_DISK_GUID}"
ENV{DEVTYPE}=="disk", ENV{ID_DISK_GUID}=="?*",
ENV{SYSTEMD_ALIAS}+="/sys/block/by-uuid/$env{ID_DISK_GUID}"
syslog:
-------
disconnect:
Dez 08 21:14:26 apu kernel: usb 4-1: USB disconnect, device number 17
Dez 08 21:14:26 apu kernel: scsi 5:0:0:0: rejecting I/O to offline device
Dez 08 21:14:26 apu kernel: scsi 5:0:0:0: [sdc] killing request
Dez 08 21:14:26 apu kernel: scsi 5:0:0:0: [sdc] FAILED Result:
hostbyte=DID_NO_CONNECT driverbyte=DRIVER_OK
Dez 08 21:14:26 apu kernel: scsi 5:0:0:0: [sdc] CDB: Read(16) 88 00 00
00 00 00 08 00 10 60 00 00 00 20 00 00
Dez 08 21:14:26 apu kernel: blk_update_request: I/O error, dev sdc,
sector 134221920
Dez 08 21:14:26 apu systemd[1]: Stopping LVM2 PV scan on device 8:33...
Dez 08 21:14:26 apu systemd[1]: Stopping Spin down idle harddisk
d28e3352-7ce6-4aab-802a-59270088604e...
Dez 08 21:14:26 apu systemd[1]: Stopped Spin down idle harddisk
d28e3352-7ce6-4aab-802a-59270088604e.
Dez 08 21:14:26 apu lvm[10494]: Device 8:33 not found. Cleared from
lvmetad cache.
Dez 08 21:14:26 apu systemd[1]: Stopped LVM2 PV scan on device 8:33.
Dez 08 21:14:26 apu systemd[1]: Stopping LVM2 PV scan on device 8:81...
Dez 08 21:14:26 apu systemd[1]: Stopping Spin down idle harddisk
84128055-e167-4f20-bb14-b3634d177d5e...
Dez 08 21:14:26 apu systemd[1]: Stopped Spin down idle harddisk
84128055-e167-4f20-bb14-b3634d177d5e.
Dez 08 21:14:26 apu lvm[10500]: Device 8:81 not found. Cleared from
lvmetad cache.
Dez 08 21:14:26 apu systemd[1]: Stopped LVM2 PV scan on device 8:81.
Dez 08 21:14:26 apu systemd-udevd[651]: error opening USB device
'descriptors' file
Dez 08 21:14:34 apu kernel: usb 4-1: new SuperSpeed USB device number 18
using xhci_hcd
Dez 08 21:14:34 apu kernel: usb 4-1: New USB device found,
idVendor=152d, idProduct=9561
Dez 08 21:14:34 apu kernel: usb 4-1: New USB device strings: Mfr=1,
Product=2, SerialNumber=5
Dez 08 21:14:34 apu kernel: usb 4-1: Product: JMS56x Series
Dez 08 21:14:34 apu kernel: usb 4-1: Manufacturer: JMicron
Dez 08 21:14:34 apu kernel: usb 4-1: SerialNumber: 00000000000000000000
Dez 08 21:14:34 apu kernel: usb 4-1: UAS is blacklisted for this device,
using usb-storage instead
Dez 08 21:14:34 apu kernel: usb-storage 4-1:1.0: USB Mass Storage device
detected
Dez 08 21:14:34 apu kernel: usb-storage 4-1:1.0: Quirks match for vid
152d pid 9561: 900400
Dez 08 21:14:34 apu kernel: scsi host6: usb-storage 4-1:1.0
Dez 08 21:14:35 apu kernel: scsi 6:0:0:0: Direct-Access WDC WD30
PURX-64P6ZY0 0106 PQ: 0 ANSI: 6
Dez 08 21:14:35 apu kernel: scsi 6:0:0:1: Direct-Access WDC WD30
PURX-64P6ZY0 0106 PQ: 0 ANSI: 6
Dez 08 21:14:35 apu kernel: sd 6:0:0:0: Attached scsi generic sg1 type 0
Dez 08 21:14:35 apu kernel: sd 6:0:0:1: Attached scsi generic sg2 type 0
Dez 08 21:14:35 apu kernel: sd 6:0:0:0: [sdg] Very big device. Trying to
use READ CAPACITY(16).
Dez 08 21:14:35 apu kernel: sd 6:0:0:0: [sdg] 5860533168 512-byte
logical blocks: (3.00 TB/2.73 TiB)
Dez 08 21:14:35 apu kernel: sd 6:0:0:1: [sdh] Very big device. Trying to
use READ CAPACITY(16).
Dez 08 21:14:35 apu kernel: sd 6:0:0:0: [sdg] Write Protect is off
Dez 08 21:14:35 apu kernel: sd 6:0:0:0: [sdg] Mode Sense: 47 00 10 08
Dez 08 21:14:35 apu kernel: sd 6:0:0:1: [sdh] 5860533168 512-byte
logical blocks: (3.00 TB/2.73 TiB)
Dez 08 21:14:35 apu kernel: sd 6:0:0:0: [sdg] No Caching mode page found
Dez 08 21:14:35 apu kernel: sd 6:0:0:0: [sdg] Assuming drive cache:
write through
Dez 08 21:14:35 apu kernel: sd 6:0:0:1: [sdh] Write Protect is off
Dez 08 21:14:35 apu kernel: sd 6:0:0:1: [sdh] Mode Sense: 47 00 10 08
Dez 08 21:14:35 apu kernel: sd 6:0:0:1: [sdh] No Caching mode page found
Dez 08 21:14:35 apu kernel: sd 6:0:0:1: [sdh] Assuming drive cache:
write through
Dez 08 21:14:35 apu kernel: sd 6:0:0:0: [sdg] Very big device. Trying to
use READ CAPACITY(16).
Dez 08 21:14:35 apu kernel: sd 6:0:0:1: [sdh] Very big device. Trying to
use READ CAPACITY(16).
Dez 08 21:14:35 apu kernel: sdg: sdg1
Dez 08 21:14:35 apu kernel: sdh: sdh1
Dez 08 21:14:35 apu kernel: sd 6:0:0:0: [sdg] Very big device. Trying to
use READ CAPACITY(16).
Dez 08 21:14:35 apu kernel: sd 6:0:0:1: [sdh] Very big device. Trying to
use READ CAPACITY(16).
Dez 08 21:14:35 apu kernel: sd 6:0:0:0: [sdg] Attached SCSI disk
Dez 08 21:14:35 apu kernel: sd 6:0:0:1: [sdh] Attached SCSI disk
Dez 08 21:14:35 apu udevinfo[10547]: disk sdg, guid:
d28e3352-7ce6-4aab-802a-59270088604e
Dez 08 21:14:35 apu systemd[1]: Device
sys-block-by\x2duuid-d28e3352\x2d7ce6\x2d4aab\x2d802a\x2d59270088604e.device
appeared twice with different sysfs paths
/sys/devices/pci0000:00/0000:00:1d.0/0000:03:00.0/usb4/4-1/4-1:1.0/host5/target5:0:0/5:0:0:0/block/sdc
and
/sys/devices/pci0000:00/0000:00:1d.0/0000:03:00.0/usb4/4-1/4-1:1.0/host6/target6:0:0/6:0:0:0/block/sdg
Dez 08 21:14:35 apu udevinfo[10549]: disk sdh, guid:
84128055-e167-4f20-bb14-b3634d177d5e
Dez 08 21:14:35 apu systemd[1]: Device
sys-block-by\x2duuid-84128055\x2de167\x2d4f20\x2dbb14\x2db3634d177d5e.device
appeared twice with different sysfs paths
/sys/devices/pci0000:00/0000:00:1d.0/0000:03:00.0/usb4/4-1/4-1:1.0/host5/target5:0:0/5:0:0:1/block/sdf
and
/sys/devices/pci0000:00/0000:00:1d.0/0000:03:00.0/usb4/4-1/4-1:1.0/host6/target6:0:0/6:0:0:1/block/sdh
Dez 08 21:14:35 apu systemd[1]: Starting LVM2 PV scan on device 8:97...
Dez 08 21:14:35 apu systemd[1]: Device
dev-disk-by\x2dpartlabel-Linux\x5cx20LVM.device appeared twice with
different sysfs paths
/sys/devices/pci0000:00/0000:00:1d.0/0000:03:00.0/usb4/4-1/4-1:1.0/host6/target6:0:0/6:0:0:0/block/sdg/sdg1
and
/sys/devices/pci0000:00/0000:00:1d.0/0000:03:00.0/usb4/4-1/4-1:1.0/host6/target6:0:0/6:0:0:1/block/sdh/sdh1
Dez 08 21:14:35 apu systemd[1]: Starting LVM2 PV scan on device 8:113...
Dez 08 21:14:36 apu lvm[10551]: 1 logical volume(s) in volume group
"vg_backup" now active
Dez 08 21:14:36 apu systemd[1]: Started LVM2 PV scan on device 8:113.
Dez 08 21:14:36 apu lvm[10550]: 1 logical volume(s) in volume group
"vg_data" now active
Dez 08 21:14:36 apu systemd[1]: Started LVM2 PV scan on device 8:97.
--
e-mail ::: Leo.Bergolth (at) wu.ac.at fax ::: +43-1-31336-906050
location ::: IT-Services | Vienna University of Economics | Austria
More information about the systemd-devel
mailing list