[systemd-devel] udev event on usb unpluged

Tom Yan tom.ty89 at gmail.com
Wed Aug 26 22:13:43 PDT 2015


Maybe there's indeed some problem with your kernel or device. I tried
the following rule on my machine:
/etc/udev/rules.d/usb.rules:SUBSYSTEM=="usb", RUN+="/usr/bin/bash -c
'echo $ACTION $DEVPATH >> /home/tom/test"

And here's the "test" log after I reboot and plug/unplug a usb thumb
drive (2-4):
add /devices/pci0000:00/0000:00:1a.0/usb3
add /devices/pci0000:00/0000:00:14.0/usb2
add /devices/pci0000:00/0000:00:1d.0/usb4
add /devices/pci0000:00/0000:00:14.0/usb1
add /devices/pci0000:00/0000:00:1d.0/usb4/4-0:1.0
add /devices/pci0000:00/0000:00:1a.0/usb3/3-0:1.0
add /devices/pci0000:00/0000:00:14.0/usb2/2-0:1.0
add /devices/pci0000:00/0000:00:14.0/usb1/1-0:1.0
add /devices/pci0000:00/0000:00:14.0/usb2/2-1
add /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0
add /devices/pci0000:00/0000:00:14.0/usb2/2-2
add /devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0
add /devices/pci0000:00/0000:00:1a.0/usb3/3-1
add /devices/pci0000:00/0000:00:1a.0/usb3/3-1/3-1:1.0
add /devices/pci0000:00/0000:00:1d.0/usb4/4-1
add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1:1.0
add /devices/pci0000:00/0000:00:14.0/usb1/1-13
add /devices/pci0000:00/0000:00:14.0/usb1/1-13/1-13:1.0
add /devices/pci0000:00/0000:00:14.0/usb1/1-13/1-13:1.1
add /devices/pci0000:00/0000:00:14.0/usb1/1-13/1-13:1.2
add /devices/pci0000:00/0000:00:14.0/usb1/1-14
add /devices/pci0000:00/0000:00:14.0/usb1/1-14/1-14:1.0
add /devices/pci0000:00/0000:00:14.0/usb1/1-14/1-14:1.1
add /devices/pci0000:00/0000:00:14.0/usb2/2-4
add /devices/pci0000:00/0000:00:14.0/usb2/2-4/2-4:1.0
remove /devices/pci0000:00/0000:00:14.0/usb2/2-4/2-4:1.0
remove /devices/pci0000:00/0000:00:14.0/usb2/2-4

Perhaps you can check the devpath and see if it's actually gone with
`ls` after you unplug the cable/device?

On 26 August 2015 at 21:35, Robert Milasan <rmilasan at suse.com> wrote:
> On Wed, 26 Aug 2015 15:32:13 +0200 (CEST)
> <christophe.jalady at free.fr> wrote:
>
>> >They are not referring to your device, but the machine on which you
>> >are
>> running the rule.
>> >In a terminal/console you run: udevadm monitor
>> >The do the removal itself and see what 'udevadm monitor' says.
>>
>> this is the problem: the machine which are running the rule is a
>> "specific robotic device" with one usb port and no screen (and no
>> network device). Either I connect through ssh using the usb cable
>> (eth over usb) or I use the usb cable to test my plug/unplug process.
>> I cannot have a console _and_ test the unplugging at the same time.
>
> Then login into that machine and run screen, in which you run:
> 'udevadm monitor -u -p > /tmp/udev.log 2>&1'
>
> Do the necessary removal of the usb cable or whatever, then attach
> the usb cable again, login again and check the log.
>
>>
>> Christophe
>>
>
>
> --
> Robert Milasan
>
> L3 Support Engineer
> SUSE Linux (http://www.suse.com)
> email: rmilasan at suse.com
> GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel


More information about the systemd-devel mailing list