3

The udev rules I've created so far only deal with devices being added or removed, i.e.:

ACTION=="add"... or ACTION=="remove"...

I've come across an example of a rule that seems to deal with device state changes as well:

ACTION=="add|change", KERNEL=="sd[b-z]", ATTR{queue/rotational}=="1", RUN+="/usr/bin/hdparm -B 127 -S 12 /dev/%k"

I take it that the above rule applies whenever a matching device is added OR its state changes.

Question: What kind of state changes are possible (generally and specific to a USB hard drive)?

I've checked all udev documentation I can find and there's barely any mention of, or usage guidance, in respect of device state changes or specifically ACTION="change".

3

"change" corresponds, for example, to removing or inserting an sdcard in a sdcard reader, or changing the hard disc inside a usb-to-sata enclosure. The device itself is not added nor removed, but the media is no longer the same.

1

udev change event gets triggered when media changer (regards to tape - Netbackup like environment) or sd card reader is used in continuation with different media or sd card. When a same device is re-added (a san disk is re-added again or you do switchdisable/enable on the switch side or target port disable/enable from target side )

Below are the few change udev events that we see on the host side, when I did target port disable (from Vexata VX100 array) for an existing san lun

KERNEL[34942.047543] change   /devices/virtual/block/dm-0 (block)
KERNEL[34942.047596] change   /devices/virtual/block/dm-1 (block)
KERNEL[34942.047613] change   /devices/virtual/block/dm-2 (block)
KERNEL[34942.047631] change   /devices/virtual/block/dm-3 (block)
KERNEL[34942.047678] change   /devices/virtual/block/dm-4 (block)
UDEV  [34942.053448] change   /devices/virtual/block/dm-3 (block)
UDEV  [34942.053486] change   /devices/virtual/block/dm-4 (block)
UDEV  [34942.053507] change   /devices/virtual/block/dm-0 (block)
UDEV  [34942.053536] change   /devices/virtual/block/dm-2 (block)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.