I have this fairly basic udev rule named /etc/udev/rules.d/99-sd.rules
:
ACTION=="add", SUBSYSTEM=="mmc", KERNEL=="mmcblk0p1", RUN+="/usr/bin/echo 'aa' > /tmp/test"
The goal is to create test
file when I insert the SD card and it gets its p1
partition recognized.
Now, after creating this rule, I did everything:
sudo udevadm control --reload-rules
sudo systemctl restart udev
sudo reboot
But still that file is not getting created when I insert the SD card. (And SD card is OK, I can even mount it).
What is the problem here? This drives me crazy and I can't see what's wrong. With udevadm I can see the kernel event coming in about the SD card. But then WHY is not my file getting created?
OS: Debian Bullseye
This is dmesg:
[ 85.299246] mmc0: new ultra high speed SDR104 SDXC card at address aaaa
[ 85.301507] mmcblk0: mmc0:aaaa SN64G 59.5 GiB
[ 85.307164] mmcblk0: p1
/tmp
is empty even when I tried with "bash":
$ cat /etc/udev/rules.d/99-sd.rules
ACTION=="add", SUBSYSTEM=="mmc", KERNEL=="mmcblk0p1", RUN+="/bin/bash -c '/usr/bin/echo aa > /tmp/test'"
udevadm monitor
:
$ sudo udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
KERNEL[191.651922] add /devices/platform/fe2b0000.dwmmc/mmc_host/mmc0/mmc0:aaaa (mmc)
KERNEL[191.655196] add /devices/virtual/bdi/179:96 (bdi)
UDEV [191.656246] add /devices/platform/fe2b0000.dwmmc/mmc_host/mmc0/mmc0:aaaa (mmc)
UDEV [191.656604] add /devices/virtual/bdi/179:96 (bdi)
KERNEL[191.657702] add /devices/platform/fe2b0000.dwmmc/mmc_host/mmc0/mmc0:aaaa/block/mmcblk0 (block)
KERNEL[191.657862] add /devices/platform/fe2b0000.dwmmc/mmc_host/mmc0/mmc0:aaaa/block/mmcblk0/mmcblk0p1 (block)
KERNEL[191.658527] bind /devices/platform/fe2b0000.dwmmc/mmc_host/mmc0/mmc0:aaaa (mmc)
UDEV [191.689858] add /devices/platform/fe2b0000.dwmmc/mmc_host/mmc0/mmc0:aaaa/block/mmcblk0 (block)
UDEV [191.732813] add /devices/platform/fe2b0000.dwmmc/mmc_host/mmc0/mmc0:aaaa/block/mmcblk0/mmcblk0p1 (block)
UDEV [191.735289] bind /devices/platform/fe2b0000.dwmmc/mmc_host/mmc0/mmc0:aaaa (mmc)