You are not logged in.

#1 2016-12-25 14:19:47

8472
Member
From: Slovakia
Registered: 2010-05-15
Posts: 89

[SOLVED] udev rule not working, although the log says it does

Hello,

I'm having a problem to get my udev rule working, although the log `udevadm control --log-priority=debug` says it does.
Testing rule at first, which should only start simple `RUN+="/usr/bin/echo test > /tmp/inserted.txt"` (applied with `udevadm control --reload`), to see whether it's working properly.
Despite of the success noted in the log, there is no such output file stored in the /tmp/.

Notebook Lenovo L560 + LTS kernel.
SD card (which is working fine after I applyied the following fix for the built-in card reader first), with details:

  looking at device '/devices/pci0000:00/0000:00:1c.4/0000:05:00.0/mmc_host/mmc0/mmc0:0007/block/mmcblk0':
    KERNEL=="mmcblk0"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{alignment_offset}=="0"
    ATTR{capability}=="10"
    ATTR{discard_alignment}=="0"
    ATTR{ext_range}=="8"
    ATTR{force_ro}=="0"
    ATTR{inflight}=="       0        0"
    ATTR{range}=="8"
    ATTR{removable}=="0"
    ATTR{ro}=="1"
    ATTR{size}=="245415936"
    ATTR{stat}=="     165        0     8594      230        0        0        0        0        0      150      230"

  looking at parent device '/devices/pci0000:00/0000:00:1c.4/0000:05:00.0/mmc_host/mmc0/mmc0:0007':
    KERNELS=="mmc0:0007"
    SUBSYSTEMS=="mmc"
    DRIVERS=="mmcblk"
    ATTRS{cid}=="413432534431323830004c106d010900"
    ATTRS{csd}=="400e00325b590003a82f7f800a400000"
    ATTRS{date}=="09/2016"
    ATTRS{erase_size}=="512"
    ATTRS{fwrev}=="0x0"
    ATTRS{hwrev}=="0x3"
    ATTRS{manfid}=="0x000041"
    ATTRS{name}=="SD128"
    ATTRS{oemid}=="0x3432"
    ATTRS{preferred_erase_size}=="25165824"
    ATTRS{scr}=="0245800301000000"
    ATTRS{serial}=="0x004c106d"
    ATTRS{type}=="SD"

Built-in card reader:

#  lspci -nn
05:00.0 SD Host controller [0805]: O2 Micro, Inc. SD/MMC Card Reader Controller [1217:8621] (rev 01)


Simple conditions in /etc/udev/rules.d/82-mmc.rules:

ACTION=="add", KERNEL=="mmc0:0007", SUBSYSTEMS=="mmc", RUN+="/usr/bin/echo test > /tmp/inserted.txt"
ACTION=="remove", KERNEL=="mmc0:0007", SUBSYSTEMS=="mmc", RUN+="/usr/bin/echo test > /tmp/removed.txt"

removal of SD from slot:

Dec 25 14:37:34 notebookL560 kernel: mmc0: card 0007 removed
Dec 25 14:37:34 notebookL560 systemd-udevd[14128]: seq 11360 processed
Dec 25 14:37:34 notebookL560 systemd-udevd[14128]: Unload module index
Dec 25 14:37:34 notebookL560 systemd-udevd[14128]: Unloaded link configuration context.
Dec 25 14:37:34 notebookL560 systemd-udevd[14129]: Unload module index
Dec 25 14:37:34 notebookL560 systemd-udevd[14129]: Unloaded link configuration context.
Dec 25 14:37:34 notebookL560 systemd-udevd[14131]: starting '/usr/bin/echo test > /tmp/removed.txt'
Dec 25 14:37:34 notebookL560 systemd-udevd[14130]: '/usr/bin/echo test > /tmp/removed.txt'(out) 'test > /tmp/removed.txt'
Dec 25 14:37:34 notebookL560 systemd-udevd[14130]: Process '/usr/bin/echo test > /tmp/removed.txt' succeeded.
Dec 25 14:37:34 notebookL560 systemd-udevd[14130]: passed device to netlink monitor 0x5596b44f3950
Dec 25 14:37:34 notebookL560 systemd-udevd[14130]: seq 11362 processed
Dec 25 14:37:34 notebookL560 systemd-udevd[14130]: Unload module index
Dec 25 14:37:34 notebookL560 systemd-udevd[14130]: Unloaded link configuration context.

inserted the SD in the slot:

Dec 25 14:37:37 notebookL560 systemd-journald[140]: Suppressed 3854 messages from /system.slice/systemd-udevd.service
Dec 25 14:37:37 notebookL560 systemd-udevd[175]: seq 11363 queued, 'add' 'mmc'
Dec 25 14:37:37 notebookL560 systemd-udevd[175]: seq 11363 forked new worker [15216]
Dec 25 14:37:37 notebookL560 systemd-udevd[175]: seq 11364 queued, 'add' 'bdi'
Dec 25 14:37:37 notebookL560 systemd-udevd[175]: seq 11364 forked new worker [15217]
Dec 25 14:37:37 notebookL560 systemd-udevd[15216]: seq 11363 running
Dec 25 14:37:37 notebookL560 systemd-udevd[15216]: IMPORT builtin 'hwdb' /usr/lib/udev/rules.d/50-udev-default.rules:15
Dec 25 14:37:37 notebookL560 systemd-udevd[15216]: IMPORT builtin 'hwdb' returned non-zero
Dec 25 14:37:37 notebookL560 kernel: mmc0: new ultra high speed SDR104 SDXC card at address 0007
Dec 25 14:37:37 notebookL560 kernel: mmcblk0: mmc0:0007 SD128 117 GiB (ro)
Dec 25 14:37:37 notebookL560 kernel:  mmcblk0: p1
Dec 25 14:37:37 notebookL560 systemd-udevd[15216]: RUN 'kmod load $env{MODALIAS}' /usr/lib/udev/rules.d/80-drivers.rules:5
Dec 25 14:37:37 notebookL560 systemd-udevd[15216]: RUN '/usr/bin/echo test > /tmp/inserted.txt' /etc/udev/rules.d/82-mmc.rules:4
Dec 25 14:37:37 notebookL560 systemd-udevd[15216]: Execute 'load' 'mmc:block'
Dec 25 14:37:37 notebookL560 systemd-udevd[15216]: Inserted 'mmc_block'
Dec 25 14:37:37 notebookL560 systemd-udevd[15218]: starting '/usr/bin/echo test > /tmp/inserted.txt'
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: seq 11364 running
Dec 25 14:37:37 notebookL560 systemd-udevd[175]: seq 11365 queued, 'add' 'block'
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: passed device to netlink monitor 0x5596b44db550
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: seq 11364 processed
Dec 25 14:37:37 notebookL560 systemd-udevd[175]: seq 11366 queued, 'add' 'block'
Dec 25 14:37:37 notebookL560 systemd-udevd[15216]: '/usr/bin/echo test > /tmp/inserted.txt'(out) 'test > /tmp/inserted.txt'
Dec 25 14:37:37 notebookL560 systemd-udevd[15216]: Process '/usr/bin/echo test > /tmp/inserted.txt' succeeded.
Dec 25 14:37:37 notebookL560 systemd-udevd[15216]: passed device to netlink monitor 0x5596b44f3950
Dec 25 14:37:37 notebookL560 systemd-udevd[15216]: seq 11363 processed
Dec 25 14:37:37 notebookL560 systemd-udevd[175]: passed 252 byte device to netlink monitor 0x5596b44d1dc0
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: seq 11365 running
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: GROUP 6 /usr/lib/udev/rules.d/50-udev-default.rules:55
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: LINK 'disk/by-id/mmc-SD128_0x004c106d' /usr/lib/udev/rules.d/60-persistent-storage.rules:56
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: IMPORT builtin 'path_id' /usr/lib/udev/rules.d/60-persistent-storage.rules:65
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: IMPORT builtin 'path_id' returned non-zero
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: IMPORT builtin 'blkid' /usr/lib/udev/rules.d/60-persistent-storage.rules:77
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: probe /dev/mmcblk0 raid offset=0
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: handling device node '/dev/mmcblk0', devnum=b179:0, mode=0660, uid=0, gid=6
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: set permissions /dev/mmcblk0, 060660, uid=0, gid=6
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: creating symlink '/dev/block/179:0' to '../mmcblk0'
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: creating link '/dev/disk/by-id/mmc-SD128_0x004c106d' to '/dev/mmcblk0'
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: creating symlink '/dev/disk/by-id/mmc-SD128_0x004c106d' to '../../mmcblk0'
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: created db file '/run/udev/data/b179:0' for '/devices/pci0000:00/0000:00:1c.4/0000:05:00.0/mmc_host/mmc0/mmc0:0007/block/mmcblk0'
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: passed device to netlink monitor 0x5596b44db550
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: seq 11365 processed
Dec 25 14:37:37 notebookL560 systemd-udevd[175]: Validate module index
Dec 25 14:37:37 notebookL560 systemd-udevd[175]: Check if link configuration needs reloading.
Dec 25 14:37:37 notebookL560 systemd-udevd[175]: passed 269 byte device to netlink monitor 0x5596b44d1dc0
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: seq 11366 running
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: GROUP 6 /usr/lib/udev/rules.d/50-udev-default.rules:55
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: LINK 'disk/by-id/mmc-SD128_0x004c106d-part1' /usr/lib/udev/rules.d/60-persistent-storage.rules:57
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: IMPORT builtin 'blkid' /usr/lib/udev/rules.d/60-persistent-storage.rules:77
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: probe /dev/mmcblk0p1 raid offset=0
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: LINK 'disk/by-uuid/0123-4567' /usr/lib/udev/rules.d/60-persistent-storage.rules:80
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: handling device node '/dev/mmcblk0p1', devnum=b179:1, mode=0660, uid=0, gid=6
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: set permissions /dev/mmcblk0p1, 060660, uid=0, gid=6
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: creating symlink '/dev/block/179:1' to '../mmcblk0p1'
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: creating link '/dev/disk/by-id/mmc-SD128_0x004c106d-part1' to '/dev/mmcblk0p1'
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: creating symlink '/dev/disk/by-id/mmc-SD128_0x004c106d-part1' to '../../mmcblk0p1'
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: creating link '/dev/disk/by-uuid/0123-4567' to '/dev/mmcblk0p1'
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: creating symlink '/dev/disk/by-uuid/0123-4567' to '../../mmcblk0p1'
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: created db file '/run/udev/data/b179:1' for '/devices/pci0000:00/0000:00:1c.4/0000:05:00.0/mmc_host/mmc0/mmc0:0007/block/mmcblk0/mmcblk0p1'
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: passed device to netlink monitor 0x5596b44db550
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: seq 11366 processed
Dec 25 14:37:37 notebookL560 systemd-udevd[175]: cleanup idle workers
Dec 25 14:37:37 notebookL560 systemd-udevd[15216]: Unload module index
Dec 25 14:37:37 notebookL560 systemd-udevd[15216]: Unloaded link configuration context.
Dec 25 14:37:37 notebookL560 systemd-udevd[175]: worker [15216] exited
Dec 25 14:37:37 notebookL560 systemd-udevd[175]: cleanup idle workers
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: Unload module index
Dec 25 14:37:37 notebookL560 systemd-udevd[15217]: Unloaded link configuration context.
Dec 25 14:37:37 notebookL560 systemd-udevd[175]: worker [15217] exited

Have also tried the following, WIKI:Some devices, that should be treated as removable, are not, with no help of course.

ACTION=="add", ENV{ID_SERIAL_SHORT}=="0x004c106d", ENV{UDISKS_AUTO}="1", ENV{UDISKS_SYSTEM}="0", RUN+="/usr/bin/echo test > /tmp/inserted.txt"
ACTION=="remove", ENV{ID_SERIAL_SHORT}=="0x004c106d", ENV{UDISKS_AUTO}="1", ENV{UDISKS_SYSTEM}="0", RUN+="/usr/bin/echo test > /tmp/removed.txt"

removal of SD from slot:

Dec 25 14:31:51 notebookL560 systemd-journald[140]: Suppressed 3153 messages from /system.slice/systemd-udevd.service
Dec 25 14:31:51 notebookL560 systemd-udevd[175]: seq 10596 queued, 'remove' 'block'
Dec 25 14:31:51 notebookL560 kernel: mmc0: card 0007 removed
Dec 25 14:31:51 notebookL560 systemd-udevd[175]: Validate module index
Dec 25 14:31:51 notebookL560 systemd-udevd[175]: Check if link configuration needs reloading.
Dec 25 14:31:51 notebookL560 systemd-udevd[175]: seq 10596 forked new worker [27734]
Dec 25 14:31:51 notebookL560 systemd-udevd[175]: seq 10597 queued, 'remove' 'block'
Dec 25 14:31:51 notebookL560 systemd-udevd[27734]: seq 10596 running
Dec 25 14:31:51 notebookL560 systemd-udevd[27734]: Assertion 'udev_device && key' failed at src/libudev/libudev-device.c:203, function udev_device_get_property_value(). Ignoring.
Dec 25 14:31:51 notebookL560 systemd-udevd[27734]: no reference left, remove '/dev/disk/by-id/mmc-SD128_0x004c106d-part1'
Dec 25 14:31:51 notebookL560 systemd-udevd[27734]: no reference left, remove '/dev/disk/by-uuid/0123-4567'
Dec 25 14:31:51 notebookL560 systemd-udevd[27734]: passed device to netlink monitor 0x5596b44e7000
Dec 25 14:31:51 notebookL560 systemd-udevd[27734]: seq 10596 processed
Dec 25 14:31:51 notebookL560 systemd-udevd[175]: passed 255 byte device to netlink monitor 0x5596b44d1dc0
Dec 25 14:31:51 notebookL560 systemd-udevd[27734]: seq 10597 running
Dec 25 14:31:51 notebookL560 systemd-udevd[27734]: Assertion 'udev_device && key' failed at src/libudev/libudev-device.c:203, function udev_device_get_property_value(). Ignoring.
Dec 25 14:31:51 notebookL560 systemd-udevd[27734]: no reference left, remove '/dev/disk/by-id/mmc-SD128_0x004c106d'
Dec 25 14:31:51 notebookL560 systemd-udevd[27734]: passed device to netlink monitor 0x5596b44e7000
Dec 25 14:31:51 notebookL560 systemd-udevd[27734]: seq 10597 processed
Dec 25 14:31:51 notebookL560 systemd-udevd[175]: cleanup idle workers
Dec 25 14:31:51 notebookL560 systemd-udevd[27734]: Unload module index
Dec 25 14:31:51 notebookL560 systemd-udevd[27734]: Unloaded link configuration context.
Dec 25 14:31:51 notebookL560 systemd-udevd[175]: worker [27734] exited
Dec 25 14:31:51 notebookL560 systemd-udevd[175]: seq 10598 queued, 'remove' 'bdi'
Dec 25 14:31:51 notebookL560 systemd-udevd[175]: seq 10598 forked new worker [27736]
Dec 25 14:31:51 notebookL560 systemd-udevd[27736]: seq 10598 running
Dec 25 14:31:51 notebookL560 systemd-udevd[27736]: passed device to netlink monitor 0x5596b44f3950
Dec 25 14:31:51 notebookL560 systemd-udevd[27736]: seq 10598 processed
Dec 25 14:31:51 notebookL560 systemd-udevd[175]: cleanup idle workers
Dec 25 14:31:51 notebookL560 systemd-udevd[27736]: Unload module index
Dec 25 14:31:51 notebookL560 systemd-udevd[27736]: Unloaded link configuration context.
Dec 25 14:31:51 notebookL560 systemd-udevd[175]: worker [27736] exited
Dec 25 14:31:51 notebookL560 systemd-udevd[175]: seq 10599 queued, 'remove' 'mmc'
Dec 25 14:31:51 notebookL560 systemd-udevd[175]: seq 10599 forked new worker [27739]
Dec 25 14:31:51 notebookL560 systemd-udevd[27739]: seq 10599 running
Dec 25 14:31:51 notebookL560 systemd-udevd[27739]: passed device to netlink monitor 0x5596b44f3950
Dec 25 14:31:51 notebookL560 systemd-udevd[27739]: seq 10599 processed
Dec 25 14:31:51 notebookL560 systemd-udevd[175]: cleanup idle workers
Dec 25 14:31:51 notebookL560 systemd-udevd[27739]: Unload module index
Dec 25 14:31:51 notebookL560 systemd-udevd[27739]: Unloaded link configuration context.
Dec 25 14:31:51 notebookL560 systemd-udevd[175]: worker [27739] exited

inserted the SD in the slot:

Dec 25 14:31:54 notebookL560 systemd-udevd[175]: seq 10600 queued, 'add' 'mmc'
Dec 25 14:31:54 notebookL560 systemd-udevd[175]: seq 10600 forked new worker [27743]
Dec 25 14:31:54 notebookL560 systemd-udevd[27743]: seq 10600 running
Dec 25 14:31:54 notebookL560 systemd-udevd[175]: seq 10601 queued, 'add' 'bdi'
Dec 25 14:31:54 notebookL560 systemd-udevd[27743]: IMPORT builtin 'hwdb' /usr/lib/udev/rules.d/50-udev-default.rules:15
Dec 25 14:31:54 notebookL560 systemd-udevd[175]: seq 10601 forked new worker [27745]
Dec 25 14:31:54 notebookL560 systemd-udevd[27743]: IMPORT builtin 'hwdb' returned non-zero
Dec 25 14:31:54 notebookL560 systemd-udevd[27743]: RUN 'kmod load $env{MODALIAS}' /usr/lib/udev/rules.d/80-drivers.rules:5
Dec 25 14:31:54 notebookL560 systemd-udevd[27745]: seq 10601 running
Dec 25 14:31:54 notebookL560 systemd-udevd[27743]: Execute 'load' 'mmc:block'
Dec 25 14:31:54 notebookL560 systemd-udevd[27743]: Inserted 'mmc_block'
Dec 25 14:31:54 notebookL560 systemd-udevd[27743]: passed device to netlink monitor 0x5596b44f3950
Dec 25 14:31:54 notebookL560 kernel: mmc0: new ultra high speed SDR104 SDXC card at address 0007
Dec 25 14:31:54 notebookL560 kernel: mmcblk0: mmc0:0007 SD128 117 GiB (ro)
Dec 25 14:31:54 notebookL560 kernel:  mmcblk0: p1
Dec 25 14:31:54 notebookL560 systemd-udevd[27743]: seq 10600 processed
Dec 25 14:31:54 notebookL560 systemd-udevd[27745]: passed device to netlink monitor 0x5596b44db550
Dec 25 14:31:54 notebookL560 systemd-udevd[27745]: seq 10601 processed
Dec 25 14:31:54 notebookL560 systemd-udevd[175]: cleanup idle workers
Dec 25 14:31:54 notebookL560 systemd-udevd[27745]: Unload module index
Dec 25 14:31:54 notebookL560 systemd-udevd[27743]: Unload module index
Dec 25 14:31:54 notebookL560 systemd-udevd[27745]: Unloaded link configuration context.
Dec 25 14:31:54 notebookL560 systemd-udevd[27743]: Unloaded link configuration context.
Dec 25 14:31:54 notebookL560 systemd-udevd[175]: worker [27743] exited
Dec 25 14:31:54 notebookL560 systemd-udevd[175]: worker [27745] exited
Dec 25 14:31:54 notebookL560 systemd-udevd[175]: seq 10602 queued, 'add' 'block'
Dec 25 14:31:54 notebookL560 systemd-udevd[175]: seq 10602 forked new worker [27746]
Dec 25 14:31:54 notebookL560 systemd-udevd[175]: seq 10603 queued, 'add' 'block'
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: seq 10602 running
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: GROUP 6 /usr/lib/udev/rules.d/50-udev-default.rules:55
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: LINK 'disk/by-id/mmc-SD128_0x004c106d' /usr/lib/udev/rules.d/60-persistent-storage.rules:56
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: IMPORT builtin 'path_id' /usr/lib/udev/rules.d/60-persistent-storage.rules:65
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: IMPORT builtin 'path_id' returned non-zero
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: IMPORT builtin 'blkid' /usr/lib/udev/rules.d/60-persistent-storage.rules:77
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: probe /dev/mmcblk0 raid offset=0
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: handling device node '/dev/mmcblk0', devnum=b179:0, mode=0660, uid=0, gid=6
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: set permissions /dev/mmcblk0, 060660, uid=0, gid=6
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: creating symlink '/dev/block/179:0' to '../mmcblk0'
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: creating link '/dev/disk/by-id/mmc-SD128_0x004c106d' to '/dev/mmcblk0'
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: creating symlink '/dev/disk/by-id/mmc-SD128_0x004c106d' to '../../mmcblk0'
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: created db file '/run/udev/data/b179:0' for '/devices/pci0000:00/0000:00:1c.4/0000:05:00.0/mmc_host/mmc0/mmc0:0007/block/mmcblk0'
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: passed device to netlink monitor 0x5596b44e7000
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: seq 10602 processed
Dec 25 14:31:54 notebookL560 systemd-udevd[175]: passed 269 byte device to netlink monitor 0x5596b44d1dc0
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: seq 10603 running
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: GROUP 6 /usr/lib/udev/rules.d/50-udev-default.rules:55
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: LINK 'disk/by-id/mmc-SD128_0x004c106d-part1' /usr/lib/udev/rules.d/60-persistent-storage.rules:57
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: IMPORT builtin 'blkid' /usr/lib/udev/rules.d/60-persistent-storage.rules:77
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: probe /dev/mmcblk0p1 raid offset=0
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: LINK 'disk/by-uuid/0123-4567' /usr/lib/udev/rules.d/60-persistent-storage.rules:80
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: handling device node '/dev/mmcblk0p1', devnum=b179:1, mode=0660, uid=0, gid=6
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: set permissions /dev/mmcblk0p1, 060660, uid=0, gid=6
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: creating symlink '/dev/block/179:1' to '../mmcblk0p1'
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: creating link '/dev/disk/by-id/mmc-SD128_0x004c106d-part1' to '/dev/mmcblk0p1'
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: creating symlink '/dev/disk/by-id/mmc-SD128_0x004c106d-part1' to '../../mmcblk0p1'
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: creating link '/dev/disk/by-uuid/0123-4567' to '/dev/mmcblk0p1'
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: creating symlink '/dev/disk/by-uuid/0123-4567' to '../../mmcblk0p1'
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: created db file '/run/udev/data/b179:1' for '/devices/pci0000:00/0000:00:1c.4/0000:05:00.0/mmc_host/mmc0/mmc0:0007/block/mmcblk0/mmcblk0p1'
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: passed device to netlink monitor 0x5596b44e7000
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: seq 10603 processed
Dec 25 14:31:54 notebookL560 systemd-udevd[175]: cleanup idle workers
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: Unload module index
Dec 25 14:31:54 notebookL560 systemd-udevd[27746]: Unloaded link configuration context.
Dec 25 14:31:54 notebookL560 systemd-udevd[175]: worker [27746] exited

Could you please help me identify what I'm doing wrong?



Thank you very much in advance,
8472

Last edited by 8472 (2016-12-26 10:27:33)


Logic clearly dictates that the needs of the many outweigh the needs of the few.

Offline

#2 2016-12-25 14:37:07

loqs
Member
Registered: 2014-03-06
Posts: 18,963

Re: [SOLVED] udev rule not working, although the log says it does

Dec 25 14:37:34 notebookL560 systemd-udevd[14131]: starting '/usr/bin/echo test > /tmp/removed.txt'
Dec 25 14:37:34 notebookL560 systemd-udevd[14130]: '/usr/bin/echo test > /tmp/removed.txt'(out) 'test > /tmp/removed.txt'
Dec 25 14:37:34 notebookL560 systemd-udevd[14130]: Process '/usr/bin/echo test > /tmp/removed.txt' succeeded.

Is it not the case the parameter being passed to echo is 'test > /tmp/removed.txt'  and no shell redirection occurs because /usr/bin/echo is called directly.

Offline

#3 2016-12-25 16:06:36

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [SOLVED] udev rule not working, although the log says it does

Put your commands in a script, and make udev run *that script*.

Offline

#4 2016-12-25 16:18:43

8472
Member
From: Slovakia
Registered: 2010-05-15
Posts: 89

Re: [SOLVED] udev rule not working, although the log says it does

Thank you guys.

Some new findings.
Obviously, not every command in the system, is running.
e.g.,
- /usr/bin/echo, /usr/bin/mount - are not working
- /usr/bin/touch, /usr/bin/mkdir, /usr/bin/rm - DO WORK.
- and yes, a script like /tmp/run.sh will work too (just like brebs advised).


I think I could use the script workaround, however, I still would be interested, about why aren't the other commands working (for instance the simple `/usr/bin/mount /dev/mmcblk0p1 /mnt/sd128gb`)?
Some people on the internet were showing examples of udev rules, using e.g. echo or mount. It's strange.


Logic clearly dictates that the needs of the many outweigh the needs of the few.

Offline

#5 2016-12-25 16:33:44

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [SOLVED] udev rule not working, although the log says it does

Debug it. Have udev run a script which contains e.g.:

#!/bin/bash

/usr/bin/mount /dev/mmcblk0p1 /mnt/sd128gb &> /tmp/debug.txt
echo "This is evidence that the script ran." >> /tmp/debug.txt

Offline

#6 2016-12-25 19:36:11

8472
Member
From: Slovakia
Registered: 2010-05-15
Posts: 89

Re: [SOLVED] udev rule not working, although the log says it does

brebs wrote:

Debug it. Have udev run a script which contains e.g.:

#!/bin/bash

/usr/bin/mount /dev/mmcblk0p1 /mnt/sd128gb &> /tmp/debug.txt
echo "This is evidence that the script ran." >> /tmp/debug.txt

Obviously the "mount" command while working inside of the udev rules (either called via script or directly in the RUN+=) is weird.
At first I thought running "mount" through script within udev's RUN+= would work fine, but obviously it's not.

82-mmc.rules:

ACTION=="add", KERNEL=="mmc0:0007", SUBSYSTEMS=="mmc", RUN+="/tmp/mounting.sh"

when called in the CLI works fine:

#!/bin/bash
/usr/bin/mount /dev/mmcblk0p1 /mnt/sd128gb

"Process '/tmp/mounting.sh' succeeded.", yeah, right, big crap, keep on dreaming (+ empty /tmp/debug.txt):

Dec 25 20:12:34 notebookL560 systemd-udevd[180]: seq 3214 queued, 'add' 'mmc'
Dec 25 20:12:34 notebookL560 systemd-udevd[180]: Validate module index
Dec 25 20:12:34 notebookL560 systemd-udevd[180]: Check if link configuration needs reloading.
Dec 25 20:12:34 notebookL560 systemd-udevd[180]: seq 3214 forked new worker [10405]
Dec 25 20:12:34 notebookL560 systemd-udevd[10405]: seq 3214 running
Dec 25 20:12:34 notebookL560 systemd-udevd[10405]: IMPORT builtin 'hwdb' /usr/lib/udev/rules.d/50-udev-default.rules:15
Dec 25 20:12:34 notebookL560 systemd-udevd[10405]: IMPORT builtin 'hwdb' returned non-zero
Dec 25 20:12:34 notebookL560 systemd-udevd[10405]: RUN 'kmod load $env{MODALIAS}' /usr/lib/udev/rules.d/80-drivers.rules:5
Dec 25 20:12:34 notebookL560 systemd-udevd[10405]: RUN '/tmp/l560sdreaderfix.sh' /etc/udev/rules.d/81-sdreader.rules:1
Dec 25 20:12:34 notebookL560 systemd-udevd[10405]: RUN '/tmp/mounting.sh' /etc/udev/rules.d/82-mmc.rules:6
Dec 25 20:12:34 notebookL560 systemd-udevd[10405]: Execute 'load' 'mmc:block'
Dec 25 20:12:34 notebookL560 kernel: mmc0: new ultra high speed SDR104 SDXC card at address 0007
Dec 25 20:12:34 notebookL560 systemd-udevd[180]: seq 3215 queued, 'add' 'module'
Dec 25 20:12:34 notebookL560 systemd-udevd[180]: seq 3215 forked new worker [10408]
Dec 25 20:12:34 notebookL560 systemd-udevd[180]: seq 3216 queued, 'add' 'bdi'
Dec 25 20:12:34 notebookL560 systemd-udevd[180]: seq 3216 forked new worker [10409]
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: seq 3215 running
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: passed device to netlink monitor 0x555e138219f0
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: seq 3215 processed
Dec 25 20:12:34 notebookL560 systemd-udevd[10409]: seq 3216 running
Dec 25 20:12:34 notebookL560 systemd-udevd[10409]: passed device to netlink monitor 0x555e13844a40
Dec 25 20:12:34 notebookL560 systemd-udevd[10409]: seq 3216 processed
Dec 25 20:12:34 notebookL560 systemd-udevd[180]: seq 3217 queued, 'add' 'block'
Dec 25 20:12:34 notebookL560 systemd-udevd[10405]: Inserted 'mmc_block'
Dec 25 20:12:34 notebookL560 kernel: mmcblk0: mmc0:0007 SD128 117 GiB 
Dec 25 20:12:34 notebookL560 kernel:  mmcblk0: p1
Dec 25 20:12:34 notebookL560 systemd-udevd[180]: seq 3218 queued, 'add' 'block'
Dec 25 20:12:34 notebookL560 systemd-udevd[180]: seq 3219 queued, 'add' 'drivers'
Dec 25 20:12:34 notebookL560 systemd-udevd[180]: passed 140 byte device to netlink monitor 0x555e138276d0
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: seq 3219 running
Dec 25 20:12:34 notebookL560 systemd-udevd[10410]: starting '/tmp/l560sdreaderfix.sh'
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: passed device to netlink monitor 0x555e138219f0
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: seq 3219 processed
Dec 25 20:12:34 notebookL560 systemd-udevd[10405]: Process '/tmp/l560sdreaderfix.sh' succeeded.
Dec 25 20:12:34 notebookL560 systemd-udevd[10411]: starting '/tmp/mounting.sh'
Dec 25 20:12:34 notebookL560 systemd-udevd[10405]: Process '/tmp/mounting.sh' succeeded.
Dec 25 20:12:34 notebookL560 systemd-udevd[10405]: passed device to netlink monitor 0x555e13811c00
Dec 25 20:12:34 notebookL560 systemd-udevd[10405]: seq 3214 processed
Dec 25 20:12:34 notebookL560 systemd-udevd[180]: passed 250 byte device to netlink monitor 0x555e138276d0
Dec 25 20:12:34 notebookL560 kernel: EXT4-fs (mmcblk0p1): recovery complete
Dec 25 20:12:34 notebookL560 kernel: EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Opts: (null)
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: seq 3217 running
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: GROUP 6 /usr/lib/udev/rules.d/50-udev-default.rules:55
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: LINK 'disk/by-id/mmc-SD128_0x004c106d' /usr/lib/udev/rules.d/60-persistent-storage.rules:56
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: IMPORT builtin 'path_id' /usr/lib/udev/rules.d/60-persistent-storage.rules:65
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: IMPORT builtin 'path_id' returned non-zero
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: IMPORT builtin 'blkid' /usr/lib/udev/rules.d/60-persistent-storage.rules:77
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: probe /dev/mmcblk0 raid offset=0
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: RUN '/tmp/l560sdreaderfix.sh' /etc/udev/rules.d/81-sdreader.rules:1
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: handling device node '/dev/mmcblk0', devnum=b179:0, mode=0660, uid=0, gid=6
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: set permissions /dev/mmcblk0, 060660, uid=0, gid=6
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: creating symlink '/dev/block/179:0' to '../mmcblk0'
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: creating link '/dev/disk/by-id/mmc-SD128_0x004c106d' to '/dev/mmcblk0'
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: creating symlink '/dev/disk/by-id/mmc-SD128_0x004c106d' to '../../mmcblk0'
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: created db file '/run/udev/data/b179:0' for '/devices/pci0000:00/0000:00:1c.4/0000:05:00.0/mmc_host/mmc0/mmc0:0007/block/mmcblk0'
Dec 25 20:12:34 notebookL560 systemd-udevd[10415]: starting '/tmp/l560sdreaderfix.sh'
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: Process '/tmp/l560sdreaderfix.sh' succeeded.
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: passed device to netlink monitor 0x555e138219f0
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: seq 3217 processed
Dec 25 20:12:34 notebookL560 systemd-udevd[180]: passed 267 byte device to netlink monitor 0x555e138276d0
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: seq 3218 running
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: GROUP 6 /usr/lib/udev/rules.d/50-udev-default.rules:55
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: LINK 'disk/by-id/mmc-SD128_0x004c106d-part1' /usr/lib/udev/rules.d/60-persistent-storage.rules:57
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: IMPORT builtin 'blkid' /usr/lib/udev/rules.d/60-persistent-storage.rules:77
Dec 25 20:12:34 notebookL560 systemd-udevd[10408]: probe /dev/mmcblk0p1 raid offset=0
Dec 25 20:12:35 notebookL560 systemd-udevd[10408]: LINK 'disk/by-uuid/f1f2ef79-a9e8-4e60-b765-e41b1ec60f22' /usr/lib/udev/rules.d/60-persistent-storage.rules:80
Dec 25 20:12:35 notebookL560 systemd-udevd[10408]: RUN '/tmp/l560sdreaderfix.sh' /etc/udev/rules.d/81-sdreader.rules:1
Dec 25 20:12:35 notebookL560 systemd-udevd[10408]: handling device node '/dev/mmcblk0p1', devnum=b179:1, mode=0660, uid=0, gid=6
Dec 25 20:12:35 notebookL560 systemd-udevd[10408]: set permissions /dev/mmcblk0p1, 060660, uid=0, gid=6
Dec 25 20:12:35 notebookL560 systemd-udevd[10408]: creating symlink '/dev/block/179:1' to '../mmcblk0p1'
Dec 25 20:12:35 notebookL560 systemd-udevd[10408]: creating link '/dev/disk/by-id/mmc-SD128_0x004c106d-part1' to '/dev/mmcblk0p1'
Dec 25 20:12:35 notebookL560 systemd-udevd[10408]: creating symlink '/dev/disk/by-id/mmc-SD128_0x004c106d-part1' to '../../mmcblk0p1'
Dec 25 20:12:35 notebookL560 systemd-udevd[10408]: creating link '/dev/disk/by-uuid/f1f2ef79-a9e8-4e60-b765-e41b1ec60f22' to '/dev/mmcblk0p1'
Dec 25 20:12:35 notebookL560 systemd-udevd[10408]: creating symlink '/dev/disk/by-uuid/f1f2ef79-a9e8-4e60-b765-e41b1ec60f22' to '../../mmcblk0p1'
Dec 25 20:12:35 notebookL560 systemd-udevd[10408]: created db file '/run/udev/data/b179:1' for '/devices/pci0000:00/0000:00:1c.4/0000:05:00.0/mmc_host/mmc0/mmc0:0007/block/mmcblk0/mmcblk0p1'
Dec 25 20:12:35 notebookL560 systemd-udevd[10416]: starting '/tmp/l560sdreaderfix.sh'
Dec 25 20:12:35 notebookL560 systemd-udevd[10408]: Process '/tmp/l560sdreaderfix.sh' succeeded.
Dec 25 20:12:35 notebookL560 systemd-udevd[10408]: passed device to netlink monitor 0x555e138219f0
Dec 25 20:12:35 notebookL560 systemd-udevd[10408]: seq 3218 processed
Dec 25 20:12:35 notebookL560 systemd-udevd[180]: cleanup idle workers
Dec 25 20:12:35 notebookL560 systemd-udevd[10409]: Unload module index
Dec 25 20:12:35 notebookL560 systemd-udevd[10409]: Unloaded link configuration context.
Dec 25 20:12:35 notebookL560 systemd-udevd[10408]: Unload module index
Dec 25 20:12:35 notebookL560 systemd-udevd[10408]: Unloaded link configuration context.
Dec 25 20:12:35 notebookL560 systemd-udevd[180]: worker [10409] exited
Dec 25 20:12:35 notebookL560 systemd-udevd[180]: cleanup idle workers
Dec 25 20:12:35 notebookL560 systemd-udevd[180]: worker [10408] exited
Dec 25 20:12:35 notebookL560 systemd-udevd[180]: cleanup idle workers
Dec 25 20:12:35 notebookL560 systemd-udevd[10405]: Unload module index
Dec 25 20:12:35 notebookL560 systemd-udevd[10405]: Unloaded link configuration context.
Dec 25 20:12:35 notebookL560 systemd-udevd[180]: worker [10405] exited

Now, not calling script, rather the mount command with parameters directly:

ACTION=="add", KERNEL=="mmc0:0007", SUBSYSTEMS=="mmc", RUN+="/usr/bin/mount /dev/mmcblk0p1 /mnt/sd128gb"

output:
1st attempt, not a single word about the "/tmp/mounting.sh", and no mounted partition, of course:

Dec 25 20:27:19 notebookL560 kernel: mmc0: new ultra high speed SDR104 SDXC card at address 0007
Dec 25 20:27:19 notebookL560 kernel: mmcblk0: mmc0:0007 SD128 117 GiB 
Dec 25 20:27:19 notebookL560 kernel:  mmcblk0: p1
Dec 25 20:27:19 notebookL560 kernel: EXT4-fs (mmcblk0p1): recovery complete
Dec 25 20:27:19 notebookL560 kernel: EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Opts: (null)
Dec 25 20:27:19 notebookL560 systemd-udevd[3285]: Unloaded link configuration context.
Dec 25 20:27:19 notebookL560 systemd-udevd[3287]: Unload module index
Dec 25 20:27:19 notebookL560 systemd-udevd[3287]: Unloaded link configuration context.

Logic clearly dictates that the needs of the many outweigh the needs of the few.

Offline

#7 2016-12-25 19:45:41

loqs
Member
Registered: 2014-03-06
Posts: 18,963

Re: [SOLVED] udev rule not working, although the log says it does

See the warning about mount and udev on the wiki udev#Writing_udev_rules

Offline

#8 2016-12-25 19:49:02

8472
Member
From: Slovakia
Registered: 2010-05-15
Posts: 89

Re: [SOLVED] udev rule not working, although the log says it does

loqs wrote:

See the warning about mount and udev on the wiki udev#Writing_udev_rules

Damn, many thanks, I must've forgot that.
I'll give it another try tomorrow and let you know afterwards.


Logic clearly dictates that the needs of the many outweigh the needs of the few.

Offline

#9 2016-12-26 10:29:26

8472
Member
From: Slovakia
Registered: 2010-05-15
Posts: 89

Re: [SOLVED] udev rule not working, although the log says it does

Mounting resolved, by using

ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{UDISKS_FILESYSTEM_SHARED}="1"

Thanks for the help, guys.


Logic clearly dictates that the needs of the many outweigh the needs of the few.

Offline

Board footer

Powered by FluxBB