[SOLVED]My udev rules don't automount usb device

Hi,
I'm using this .rules file for automounting usb devices:
# start at sdc to ignore the system hard drive
KERNEL!="sd[c-z]*", GOTO="my_media_automount_end" #sda and sdb are internal hard drives
ACTION=="add", PROGRAM!="/sbin/blkid %N", GOTO="my_media_automount_end"
# import some useful filesystem info as variables
IMPORT{program}="/sbin/blkid -o udev -p %N"
# get the label if present, otherwise assign one based on device/partition
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="%k"
# create the dir in /media and symlink it to /mnt
ACTION=="add", RUN+="/bin/mkdir -p '/media/%E{dir_name}'"
# global mount options
ACTION=="add", ENV{mount_options}="relatime"
# filesystem-specific mount options (777/666 dir/file perms for ntfs/vfat)
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},gid=100,dmask=000,fmask=111,utf8"
# automount ntfs filesystems using ntfs-3g driver
ACTION=="add", ENV{ID_FS_TYPE}=="ntfs", RUN+="/bin/mount -t ntfs-3g -o %E{mount_options} /dev/%k '/media/%E{dir_name}'"
# automount all other filesystems
ACTION=="add", ENV{ID_FS_TYPE}!="ntfs", RUN+="/bin/mount -t auto -o %E{mount_options} /dev/%k '/media/%E{dir_name}'"
# clean up after device removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l '/media/%E{dir_name}'", RUN+="/bin/rmdir '/media/%E{dir_name}'"
# exit
LABEL="my_media_automount_end"
The folders in /media are created successfully but no mounting takes place. The folders are empty and when I do
umount /media/device
, it returns:
umount: device/: not mounted
But when I try to remove the folder, it sometimes returns:
rmdir: failed to remove 'device/': Device or resource busy
When I unplug the device, the folders are deleted successfully.
When I manually mount the device with the code for ntfs from the rules-file, it works fine. I have also verified that the device is at /dev/sdc.
Through searching I didn't find any post with a problem like that. My guess was that somehow this test fails:
ACTION=="add", ENV{ID_FS_TYPE}=="ntfs"
I already tried removing the second condition, but the result stays the same. So I am left rather clueless, I hope, you guys can help me
Last edited by toffi-fee (2014-05-04 22:47:38)

Thanks for the reply! So now I changed the rules to:
KERNEL!="sd[c-z]*", GOTO="my_media_automount_end"
ACTION=="add", PROGRAM!="/sbin/blkid %N", GOTO="my_media_automount_end"
# import some useful filesystem info as variables
IMPORT{program}="/sbin/blkid -o udev -p %N"
ACTION=="add", RUN+="/bin/udisksctl mount -b /dev/%k"
# clean up after device removal
ACTION=="remove", RUN+="/bin/udisksctl unmount -b '/dev/%k'"
# exit
LABEL="my_media_automount_end"
But now nothing seems to happen when I plug in, also no folder creation at /run/media/user/, hmmm..
Last edited by toffi-fee (2014-05-04 19:27:53)

Similar Messages

  • [solved] /etc/udev/rules.d/10-network.rules ignored

    Hi.
    I have 4 nics (eth0, eth1, eth2, eth3) mapped to MAC addresses in  /etc/udev/rules.d/10-network.rules.
    Some months ago, I had to symlink /etc/udev/rules.d/80-net-name-slot.rules to /dev/null in order to use these static names.
    Now it doesn't work anymore (again and again and again) after a full update (kernel and I assume systemd).  The "nic-names" are completely wrong.  You call this "predictable". I call this "unpredictable". The only thing which is predictable is that after a kernel update, the network will stop working. It has been that way for months and months ... fortunately I don't update other machines anymore.
    Was this non sense really necessary?
    Anyway, if you could tell me what to do now to get my network rules applied again, I would really appreciate.
    Right now all ethX/MAC are wrong and none of them gets an IP (had to set an IP manually to post here).
    * I know what "predictable Network Interface Names" is about. I don't want this bullshit. It's much worse as it used to be. Keep it simple, folks!
    Last edited by Agnelo de la Crotche (2013-03-27 07:14:05)

    tomegun wrote:To narrow down the problem you are experiencing: What do you mean when you say that the names are "wrong"? Are they still eth0, eth1,... just in the wrong order, or are you actually seeing the "weird" new names given by udev?
    To answer this question more precisely.
    * with  /etc/udev/rules.d/80-net-name-slot.rules => /dev/nul and /etc/udev/rules.d/10-network.rules posted earlier  (in #4)
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 00:0a:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
    3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 00:06:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
    4: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 00:24:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
    5: eth3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 00:1b:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
    6: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT
    link/ether 66:64:b3:6a:26:61 brd ff:ff:ff:ff:ff:ff
    The rules are ignored.
    * after deleting   /etc/udev/rules.d/80-net-name-slot.rules
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    2: enp6s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 00:0a:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
    3: enp6s1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 00:06:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
    4: enp2s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 00:24:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
    5: enp4s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 00:1b:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
    6: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT
    link/ether a2:ee:ec:d1:65:2d brd ff:ff:ff:ff:ff:ff
    The rules don't apply.
    * with  /etc/udev/rules.d/80-net-name-slot.rules => /dev/nul and after replacing eth0, eth1, eth2, eth3 with arbitrary names net0, net1, net2, net3 in  /etc/udev/rules.d/10-network.rules
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    2: net1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 00:24:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
    3: net3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 00:0a:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
    4: net2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 00:06:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
    5: net0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 00:1b:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
    6: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT
    link/ether ea:63:09:b7:1b:1b brd ff:ff:ff:ff:ff:ff
    But the rules were applied in this case!
    It solved the problem described originally.  I think I was hit by the race condition after upgrating to kernel 3.8.4-1. This was actually my first 3.8 kernel.
    With kernel 3.7, the rules were working even if the devices were named eth0, eth1, etc.
    Those names don't work anymore, at least in my case.
    Further I  created this file for static ips:
    # cat /etc/systemd/system/network.service
    [Unit]
    Description=Wired Static IP Connectivity
    Wants=network.target
    Before=network.target
    BindsTo=sys-subsystem-net-devices-net0.device
    After=sys-subsystem-net-devices-net0.device
    [Service]
    Type=oneshot
    RemainAfterExit=yes
    ExecStart=/sbin/ip link set dev net0 up
    ExecStart=/sbin/ip addr add 192.168.101.9/24 dev net0
    ExecStart=/sbin/ip link set dev net1 up
    ExecStart=/sbin/ip addr add 192.168.102.9/24 dev net1
    ExecStart=/sbin/ip link set dev net2 up
    ExecStart=/sbin/ip addr add 192.168.104.9/24 dev net2
    ExecStart=/sbin/ip link set dev net3 up
    ExecStart=/sbin/ip addr add 192.168.105.9/24 dev net3
    ExecStart=/sbin/ip route add default via 192.168.101.1
    ExecStop=/sbin/ip addr flush dev net0
    ExecStop=/sbin/ip link set dev net0 down
    ExecStop=/sbin/ip addr flush dev net1
    ExecStop=/sbin/ip link set dev net1 down
    ExecStop=/sbin/ip addr flush dev net2
    ExecStop=/sbin/ip link set dev net2 down
    ExecStop=/sbin/ip addr flush dev net3
    ExecStop=/sbin/ip link set dev net3 down
    [Install]
    WantedBy=multi-user.target
    I disabled netcfg and enabled network.service.
    Problem is solved now.

  • [SOLVED] Custom udev rule only working when triggered manually

    I have the following rule created for a USB gamecube controller adapter:
    SUBSYSTEMS=="usb", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="0337", MODE="0666"
    This rule only takes effect when I run udevadm trigger AFTER my device is plugged in. If I then unplug the device, and plug it back in, my device no longer works. My device also doesn't work on boot. I have to plug my device in and then trigger the rules manually.
    Any ideas why this is happening? I don't want to have to run udevadm trigger every time I turn my computer on.
    Last edited by Exershio (2015-04-15 23:01:19)

    I tried reloading the configuration but it doesn't affect the issue. As for monitoring udev, this appears when I plug the device in:
    KERNEL[3439.476646] add /devices/pci0000:00/0000:00:12.0/usb4/4-5 (usb)
    KERNEL[3439.478441] add /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0 (usb)
    KERNEL[3439.486155] add /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0/0003:057E:0337.0009 (hid)
    KERNEL[3439.492319] add /class/usbmisc (class)
    KERNEL[3439.492497] add /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0/usbmisc/hiddev0 (usbmisc)
    KERNEL[3439.492602] add /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0/0003:057E:0337.0009/hidraw/hidraw0 (hidraw)
    UDEV [3439.493842] add /class/usbmisc (class)
    UDEV [3439.494832] add /devices/pci0000:00/0000:00:12.0/usb4/4-5 (usb)
    UDEV [3439.496365] add /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0 (usb)
    UDEV [3439.498256] add /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0/usbmisc/hiddev0 (usbmisc)
    UDEV [3439.498378] add /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0/0003:057E:0337.0009 (hid)
    UDEV [3439.499567] add /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0/0003:057E:0337.0009/hidraw/hidraw0 (hidraw)
    So it seems udev is detecting the GC adapter being plugged in, but it doesn't apply permissions 0666 to it until I manually run udevadm trigger.
    See what happens below, directly after plugging it in:
    $ ls -l /dev/bus/usb/004/005
    crw-rw-r-- 1 root root 189, 388 Apr 15 16:59 /dev/bus/usb/004/005
    $ sudo udevadm trigger
    $ ls -l /dev/bus/usb/004/005
    crw-rw-rw- 1 root root 189, 388 Apr 15 17:03 /dev/bus/usb/004/005
    Okay this is weird. So I appended my udev rule with GROUP="users" to see if that would help, and after reloading the rules, this happens after my device is plugged in:
    $ ls -l /dev/bus/usb/004/005
    crw-rw-r-- 1 root users 189, 393 Apr 15 17:32 /dev/bus/usb/004/005
    $ sudo udevadm trigger
    $ ls -l /dev/bus/usb/004/005
    crw-rw-rw- 1 root users 189, 393 Apr 15 17:34 /dev/bus/usb/004/005
    So it appears the device is taking on GROUP="users" immediately after being plugged in, but it wont set MODE="0666" until after running udevadm trigger
    Anyone have any ideas?
    Last edited by Exershio (2015-04-15 21:38:15)

  • Interface names get swapped, but udev rules don't work

    I'm using the (apparently nightmarish) broadcom_wl module.
    This:
    https://wiki.archlinux.org/index.php/Br … every_time
    and this:
    https://wiki.archlinux.org/index.php/Co … es_varying
    don't work.  the 10-network.rules file I create is just completely ignored.
    Any ideas?
    Arch is my distro of choice for my desktop, but it is turning out to be an enormous PITA on my laptop.

    hmmm,
    NAME
               The name, a network interface should be renamed to. Or as a
               temporary workaraound, the name a device node should be named.
               Usually the kernel provides the defined node name, or even creates
               and removes the node before udev even receives any event. Changing
               the node name from the kernel's default creates inconsistencies and
               is not supported. If the kernel and NAME specify different names,
               an error will be logged. Udev is only expected to handle device
               node permissions and to create additional symlinks, not to change
               kernel-provided device node names. Instead of renaming a device
               node, SYMLINK should be used. Symlink names must never conflict
               with device node names, it will result in unpredictable behavior.
    try creating symlinks instead.

  • [solved] My udev rule for my Android phone doesn't work, not sure why

    I have the HTC G1 Android phone and I'm trying to get a udev rule working for it.  This is my rule ...
    /etc/udev/rules.d/50-android.rules
    SUBSYSTEM=="usb_device", SYSFS{idVendor}=="0bb4", MODE="0666", NAME=="android"
    ... but when I connect my phone, /dev/android doesn't appear.  0bb4 is correct ...
    /sys/class/usb_device/usbdev5.2/device/idVendor
    0bb4
    ... so what's going on?
    Last edited by synthead (2008-11-28 15:19:09)

    There is, but I can already use it that way.  I'm learning how to code in java so I can develop applications for it.  There's a feature in the SDK where you can install and run your code on your Android device fairly seamlessly.  You literally hit "Run" and a few moments later, your phone's going to town.  But for this to work, permissions need to be set (0666).  But my udev rule does nothing and I dont understand why.
    This is where I got this information: http://code.google.com/android/intro/de … cehardware

  • Udev rules don't work

    I am on my laptop, where I am trying to write some udev rules.
    Firstly, as a test I tried to make a symlink when connecting my ext hd.
    $ udevadm info /dev/sdb
    E: ID_PART_TABLE_UUID=ea04843c-526e-45bf-9d45-beba1b180285
    $ cat /etc/udev/rules.d/61-rules.rules
    ENV{ID_PART_TABLE}=="ea04843c-526e-45bf-9d45-beba1b180285" NAME="lilalum"
    And well, nothing happens (there is no lilalum in /dev) when I plug in my ext hd.
    Secondly, my low bat rule doesn't work.
    $ cat /etc/udev/rules.d/99-lowbat.rules
    SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="10", RUN+="/usr/bin/systemctl suspend"
    SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="9", RUN+="/usr/bin/systemctl suspend"
    SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="8", RUN+="/usr/bin/systemctl suspend"
    It just doesn't do anything when the battery gets that low, and no the battery did not skip both 10, 9 and 8 percent.
    Last edited by Ploppz (2014-05-03 12:41:02)

    Ah... thanks, it works now!
    One more small issue... I tried writing a test to detect when the charger of my laptop gets plugged in or out, I put it in 61-rules.rules
    SUBSYSTEM=="power_supply", RUN+="/usr/bin/touch /home/ploppz/charger"
    The battery does send signals to udev:
    $ udevadm monitor
    monitor will print the received events for:
    UDEV - the event which udev sends out after rule processing
    KERNEL - the kernel uevent
    # Plugging out:
    KERNEL[944.333548] change /devices/platform/ACPI0003:00/power_supply/AC (power_supply)
    UDEV [944.340228] change /devices/platform/ACPI0003:00/power_supply/AC (power_supply)
    KERNEL[944.426599] change /devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
    UDEV [944.428599] change /devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
    KERNEL[944.470830] change /devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
    UDEV [944.472781] change /devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
    # Plugging in:
    KERNEL[950.317263] change /devices/platform/ACPI0003:00/power_supply/AC (power_supply)
    KERNEL[950.331752] change /devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
    UDEV [950.332023] change /devices/platform/ACPI0003:00/power_supply/AC (power_supply)
    KERNEL[950.332576] change /devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
    UDEV [950.333609] change /devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
    UDEV [950.334891] change /devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
    I also tried putting it in 99-lowbat.rules, stilll no luck. I'm also wondering whether udev reads all the rules every time an event happens, or if it caches them such that when I write a rule, I'll have to either wait a bit or do some action to update the rules cache?

  • [UDev] No more uuidage for usb device ?

    Since udev update, I haven't anymore symlinks in /dev/disk/by-uuid/ for my usb devices.. and I need them
    /lib/udev/vol_id seem to have disappear too..
    Help °o°

    upgraded udev (141-5 -> 145-1)
    I have still /dev/disk/by-uuid. But I have got problem too.
    When I plug my usb external hard drive in, it took a long time to find it. And later I unplugged the drive, /dev/sdb /dev/sdb1 /deb/sdb2 /dev/sdb5 remains...
    And my usb drive can't be found as /dev/sdc1 but only /dev/sdc, and it also remains after unplugging.
    Another thing I noticed is that on boot, it took only 100ms the udev part, while it was 400+ms before.
    Something changed in udev obviously.
    Edit::
    Just come and report back. After the second reboot after upgrading, my issue has gone.
    Last edited by lolilolicon (2009-08-27 07:04:43)

  • [SOLVED]Udev: How to easily automount usb/storage devices?...

    Hello there everyone, first time posting here.
    So as for my question, I recently finished up my preferred install for arch but I have just one problem. Can't seem to get Udev working right.
    Before I was using debian with the same Udev automount rules posted in the wiki actually. Then I tried the same ones migrating to arch but they don't seem to work. After searching for my netbook, getting the runaround, then searching for an alternative method and getting the same it's getting kind of annoying. So here I am.
    I'm running Arch with LXDE and all default DE components(PCmanFM, openbox, etc). I don't have HAL installed, only udisks and udev as PnP support. Any help?
    (Also in specific, I was using the second rule in the Udev wiki page. The one with LUKS support)
    (Ah, nevermind is was just a tiny bit of a syntax error. A little bit more googling helped me find the answer)
    Last edited by jjsullivan (2011-02-10 09:03:33)

    v43 wrote:i'll tell you anyway
    my choice was autofs (+hal). no volume managers.
    it works like a charm with thunar (and pcmanfm too).
    Its nice that you told anyway, solved my problem

  • Multiple /dev designator fstab(solved in udev rules)

    Is it possible to enable multiple USB ID's in fstab as follows;
    /dev/sc[0-9] /cdrom iso9660 ro,users,noauto  0  0
    The cdrom is connected on an IDE-USB cable.
    The idea is to enable audio CD regardless  of the state of the USB selection process.
    Adding an entry for each USB designator is an option.

    Entered the following in CD Symlinks;
    ==============================================================
    BUS=="scsi",    KERNEL="scd[0-9]", ACTION=="add", IMPORT="/sbin/cdrom_id --export $tempnode"
    =============================================================
    This seems to have solved the selection for audio cd's in USB-cdrom, regardless of the designator.

  • Curious thunar - autofs - udev rules behavior

    I've just set up autofs and udev ruls to get my usb devices automounting, and everything automounts fine.  The only issue I'm having is that my w800 doesn't automatically show up in the thunar sidebar (but it does automount).  All other devices automount, and show up in the sidebar.
    It's worth noting that my w800 memory stick is wonky as all getout, and sometimes when I plug it in, dmesg tells me:
    scsi 29:0:0:0: Direct-Access Sony Eri Memory Stick 0000 PQ: 0 ANSI: 0
    sd 29:0:0:0: [sdc] 8005632 512-byte hardware sectors (4099 MB)
    sd 29:0:0:0: [sdc] Write Protect is off
    sd 29:0:0:0: [sdc] Mode Sense: 00 6a 00 00
    sd 29:0:0:0: [sdc] Assuming drive cache: write through
    sd 29:0:0:0: [sdc] 8005632 512-byte hardware sectors (4099 MB)
    sd 29:0:0:0: [sdc] Write Protect is off
    sd 29:0:0:0: [sdc] Mode Sense: 00 6a 00 00
    sd 29:0:0:0: [sdc] Assuming drive cache: write through
    sdc:
    and there's no /dev/sdc to be found.  damn thing's partitioned anyway.
    Anyway, my files are as follows:
    /etc/udev/rules.d/10-user.rules
    BUS=="usb", ATTRS{serial}=="356554005531070_0", KERNEL=="sd?1", NAME="%k", SYMLINK+="w800", GROUP="storage"
    BUS=="usb", ATTRS{serial}=="00000000-00000000-3878b387-c905fa0c-00000000", ATTR{size}=="15666600", KERNEL=="sd?1", NAME="%k", SYMLINK+="sansa", GROUP="storage"
    BUS=="usb", ATTRS{serial}=="00000000-00000000-3878b387-c905fa0c-00000000", KERNEL=="sd?1", NAME="%k", SYMLINK+="sansa_card", GROUP="storage"
    # Symlink USB keys
    SUBSYSTEMS=="usb", ATTRS{serial}=="0000000000017D", KERNEL=="sd?", NAME="%k", SYMLINK+="shazam", GROUP="storage"
    SUBSYSTEMS=="usb", KERNEL=="sd?1", NAME="%k", SYMLINK+="usbstorage", GROUP="storage"
    /etc/autofs/
    shazam -fstype=auto,async,nodev,nosuid,umask=000 :/dev/shazam
    w800 -fstype=auto,async,nodev,nosuid,umask=000 :/dev/w800
    sansa -fstype=auto,async,nodev,nosuid,umask=000 :/dev/sansa
    sansa_card -fstype=auto,async,nodev,nosuid,umask=000 :/dev/sansa_card
    usbstorage -fstype=auto,async,nodev,nosuid,umask=000 :/dev/usbstorage
    /etc/fstab (to allow easy umounting from thunar or whereever):
    /dev/shazam /media/shazam vfat rw,user,noauto,group,flush,quiet,nodev,nosuid,noexec,noatime,dmask=000,fmask=111 0 0
    /dev/sansa /media/sansa vfat rw,user,noauto,group,flush,quiet,nodev,nosuid,noexec,noatime,dmask=000,fmask=111 0 0
    /dev/sansa_card /media/sansa_card vfat rw,user,noauto,group,flush,quiet,nodev,nosuid,noexec,noatime,dmask=000,fmask=111 0 0
    /dev/w800 /media/w800 vfat rw,user,noauto,group,flush,quiet,nodev,nosuid,noexec,noatime,dmask=000,fmask=111 0 0i
    p
    /dev/usbstorage /media/usbstorage vfat rw,user,noauto,group,flush,quiet,nodev,nosuid,noexec,noatime,dmask=000,fmask=111 0 0
    Is there anything I appear to be doing wrong, or is it just my w800 being a crapweasel?  I like having this automounting while not having to use a DE.  I really don't use my w800 much anyway, due to the crappy memory card thing, but this is hurting my geek pride.
    Thanks!

    While I have no personal experience with it, I do know that there is a pkg specifically for mounting and/or making removable media visible to thunar. It's called thunar-volman, available here:: http://archlinux.org/packages/12374/
    FWIW, I got ALL the above by doing a pkg search at archlinux.org, for: thunar

  • [SOLVED] automatic usb-backup with udev-rules + script

    I would like to have my usb-harddrive automatically start a backup as soon as it is plugged in.  And finally a bell is supposed to ring.
    I've created an udev-rule and a backup-script as shown below.
    However, instead of creating /dev/backup-drive first something strange is happening:
    The bell rings 3 times, followed by the backup, followed by a 4th ring.
    What's going on?
    Here's may udev-rule:
    ## /etc/udev/rules.d/95-backup.rules
    SUBSYSTEMS=="usb", ATTRS {serial}=="100", SYMLINK=="backup-drive", RUN+="/usr/local/bin/backup-thumb.sh"
    fstab:
    /dev/backup-drive    /media/backup   ext3     rw,user    0 0
    and my script:
    #!/bin/bash
    sleep 10
    rsync -vrtolgh --exclude '/.VirtualBox/' --delete /home/myhome /media/backup-drive
    aplay /usr/share/sounds/phone.wav
    Last edited by mehldutt (2007-07-03 20:28:27)

    The syntax of your udev rule is all wrong - for example after SYMLINK you should use "+=" or ":=". "==" is for comparing to some value.
    I think in rsync command line you want -H not -h (help) option. Also -v (verbose) is useless since you'll never see the output.
    Another thing which will prevent running rsync properly is /media/backup-drive while you use /media/backup in fstab.
    I suggest that you first try running rsync command from the command line "manually" and try if it works at all. After you'll make it work try the below suggestions.
    Another problem: what makes the backup drive mounted under /media/backup directory when you plug it into usb slot ? Are you doing it somehow "manually" in the 10 second period after plugging ? Do you use automounter of some kind ?
    If you intend to use ext3 as the backup drive filesystem you should also add sync command after rsync to make sure no data stays in RAM cache.
    I think you need to read udev manpage first.
    I can also advice you to read my udev rules for automounting usb devices (it's for any type of filesystem and any number of partitions):
    KERNEL=="sd[b-z]", NAME:="%k", SYMLINK+="usbhd-%k", GROUP:="users", OPTIONS="last_rule"
    ACTION=="add", KERNEL=="sd[b-z][0-9]", SYMLINK+="usbhd-%k", GROUP:="users", NAME:="%k"
    ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/mkdir -p /media/usbhd-%k"
    ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/ln -s /media/usbhd-%k /mnt/usbhd-%k"
    ACTION=="add", KERNEL=="sd[b-z][0-9]", PROGRAM=="/lib/udev/vol_id -t %N", RESULT=="vfat", RUN+="/bin/mount -t vfat -o rw,noauto,flush,dirsync,noexec,nodev,noatime,dmask=000,fmask=111 /dev/%k /media/
    usbhd-%k", OPTIONS="last_rule"
    ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/mount -t auto -o rw,noauto,async,dirsync,noexec,nodev,noatime /dev/%k /media/usbhd-%k", OPTIONS="last_rule"
    ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rm -f /mnt/usbhd-%k"
    ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/umount -l /media/usbhd-%k"
    ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rmdir /media/usbhd-%k", OPTIONS="last_rule"
    I think it could be simplified and modified for your backup device like this:
    SUBSYSTEMS=="usb", ATTRS(idVendor)=="XXXX", ATTRS(idProduct)=="YYYY", KERNEL=="sd[a-z]", NAME:="%k", SYMLINK:="backupdevice", OPTIONS="last_rule"
    SUBSYSTEMS=="usb", ATTRS(idVendor)=="XXXX", ATTRS(idProduct)=="YYYY", ACTION=="add", KERNEL=="sd[a-z]1", SYMLINK:="backuppartition", GROUP:="users", NAME:="%k"
    SUBSYSTEMS=="usb", ATTRS(idVendor)=="XXXX", ATTRS(idProduct)=="YYYY", ACTION=="add", KERNEL=="sd[a-z]1", RUN+="/bin/mount -t auto -o rw,noauto,async,dirsync,noexec,nodev,noatime /dev/%k /media/backup-drive"
    SUBSYSTEMS=="usb", ATTRS(idVendor)=="XXXX", ATTRS(idProduct)=="YYYY", ACTION=="add", KERNEL=="sd[a-z]1", RUN+="/usr/local/bin/backup-thumb.sh", OPTIONS="last_rule"
    SUBSYSTEMS=="usb", ATTRS(idVendor)=="XXXX", ATTRS(idProduct)=="YYYY", ACTION=="remove", KERNEL=="sd[a-z]1", RUN+="/bin/umount -l /media/backup-drive", OPTIONS="last_rule"
    assuming that you have a single partition backup drive formatted as ext3 (or at least it's the first partition).
    Also another assumption is that idVendor and idProduct are unique to your backup drive. If not you should add some extra ATTRS parameters that will ensure this combination is unique.
    The directory /media/backup-drive must already exist (remove your fstab line - it's not needed in this case because mount command is run directly from the udev rule).
    Replace all XXXX and YYYY with the values from lsusb for your backup device - plug it in, run lsusb and copy values which look like XXXX:YYYY near to the name of your backup device.
    Anyway, you can play with different options and try to modify it yourself. The automounting rules work for me very well for some time (including flush option). The backup rules you need to test yourself :-)
    Last edited by lanrat (2007-05-05 17:20:51)

  • [SOLVED]Udevd fails to recognize rules in /lib/udev/rules.d

    I've been having a few crashes since the update of udev earlier this week (so far only on my laptop where the Xserver hangs and requires a hard reboot to get anything working again).  While investigating the logs, I ran across the following errors:
    Oct 26 04:39:54 lswest-CULV [ 0.836513] udevd[74]: starting version 173
    Oct 26 04:39:54 lswest-CULV [ 17.450369] udevd[260]: starting version 174
    Oct 26 04:46:04 lswest-CULV [ 0.839752] udevd[74]: starting version 173
    Oct 26 04:46:04 lswest-CULV [ 8.778232] udevd[259]: starting version 174
    Oct 26 11:00:48 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/42-qemu-usb.rules': No such file or directory
    Oct 26 11:00:48 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/50-firmware.rules': No such file or directory
    Oct 26 11:00:48 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/50-udev-default.rules': No such file or directory
    Oct 26 11:00:48 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/60-cdrom_id.rules': No such file or directory
    Oct 26 11:00:48 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/60-persistent-alsa.rules': No such file or directory
    Oct 26 11:00:48 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/60-persistent-input.rules': No such file or directory
    Oct 26 11:00:48 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/60-persistent-serial.rules': No such file or directory
    Oct 26 11:00:48 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/60-persistent-storage-tape.rules': No such file or directory
    Oct 26 11:00:48 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/60-persistent-storage.rules': No such file or directory
    Oct 26 11:00:48 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/60-persistent-v4l.rules': No such file or directory
    Oct 26 11:00:48 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/61-accelerometer.rules': No such file or directory
    Oct 26 11:00:48 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/70-udev-acl.rules': No such file or directory
    Oct 26 11:00:48 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/75-net-description.rules': No such file or directory
    Oct 26 11:00:48 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/75-probe_mtd.rules': No such file or directory
    Oct 26 11:00:48 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/75-tty-description.rules': No such file or directory
    Oct 26 11:00:48 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/78-sound-card.rules': No such file or directory
    Oct 26 11:00:48 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/80-drivers.rules': No such file or directory
    Oct 26 11:01:16 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/42-qemu-usb.rules': No such file or directory
    Oct 26 11:01:16 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/50-firmware.rules': No such file or directory
    Oct 26 11:01:16 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/50-udev-default.rules': No such file or directory
    Oct 26 11:01:16 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/60-cdrom_id.rules': No such file or directory
    Oct 26 11:01:16 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/60-persistent-alsa.rules': No such file or directory
    Oct 26 11:01:16 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/60-persistent-input.rules': No such file or directory
    Oct 26 11:01:16 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/60-persistent-serial.rules': No such file or directory
    Oct 26 11:01:16 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/60-persistent-storage-tape.rules': No such file or directory
    Oct 26 11:01:16 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/60-persistent-storage.rules': No such file or directory
    Oct 26 11:01:16 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/60-persistent-v4l.rules': No such file or directory
    Oct 26 11:01:16 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/61-accelerometer.rules': No such file or directory
    Oct 26 11:01:16 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/70-udev-acl.rules': No such file or directory
    Oct 26 11:01:16 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/75-net-description.rules': No such file or directory
    Oct 26 11:01:16 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/75-probe_mtd.rules': No such file or directory
    Oct 26 11:01:16 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/75-tty-description.rules': No such file or directory
    Oct 26 11:01:16 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/78-sound-card.rules': No such file or directory
    Oct 26 11:01:16 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/80-drivers.rules': No such file or directory
    Oct 26 11:01:16 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/81-arch.rules': No such file or directory
    Oct 26 11:01:16 lswest-CULV udevd[259]: can not find '/lib/udev/rules.d/95-keyboard-force-release.rules': No such file or directory
    These errors have appeared since the 24th of October (the last marked update day for the udev package).  I'm also slightly concerned about the first 4 lines, where udevd "starts" version 173 and then version 174.  According to pacman -Q udev, only version 174 is installed.
    Upon investigating the folder, I find that all the "missing" files are present:
    [lswest@lswest-CULV: rules.d]% ls
    total 652K
    drwxr-xr-x 2 root root 4.0K Oct 26 11:01 ./
    drwxr-xr-x 5 root root 4.0K Oct 26 11:01 ../
    -r--r--r-- 1 root root 6.4K Aug 20 02:32 10-dm.rules
    -rw-r--r-- 1 root root 505 Aug 16 19:06 10-vboxdrv.rules
    -r--r--r-- 1 root root 1.3K Jul 7 2010 11-dm-lvm.rules
    -r--r--r-- 1 root root 1011 Nov 13 2009 13-dm-disk.rules
    -rw-r--r-- 1 root root 159K Nov 28 2010 40-gphoto.rules
    -rw-r--r-- 1 root root 26K Oct 4 11:56 40-usb-media-players.rules
    -rw-r--r-- 1 root root 764 Oct 19 23:43 42-qemu-usb.rules
    -rw-r--r-- 1 root root 1.8K Jul 30 18:31 45-libnjb.rules
    -rw-r--r-- 1 root root 219 Oct 19 23:43 50-firmware.rules
    -rw-r--r-- 1 root root 3.5K Oct 19 23:43 50-udev-default.rules
    -rw-r--r-- 1 root root 52K Jun 13 13:04 52-libmtp.rules
    -rw-r--r-- 1 root root 104K Oct 5 23:42 53-sane.rules
    -rw-r--r-- 1 root root 584 Oct 19 23:43 60-cdrom_id.rules
    -rw-r--r-- 1 root root 1.1K Aug 3 18:54 60-pcmcia.rules
    -rw-r--r-- 1 root root 616 Oct 19 23:43 60-persistent-alsa.rules
    -rw-r--r-- 1 root root 2.4K Oct 19 23:43 60-persistent-input.rules
    -rw-r--r-- 1 root root 947 Oct 19 23:43 60-persistent-serial.rules
    -rw-r--r-- 1 root root 6.0K Oct 19 23:43 60-persistent-storage.rules
    -rw-r--r-- 1 root root 1.4K Oct 19 23:43 60-persistent-storage-tape.rules
    -rw-r--r-- 1 root root 770 Oct 19 23:43 60-persistent-v4l.rules
    -rw-r--r-- 1 root root 46 Feb 9 2011 60-rfkill.rules
    -rw-r--r-- 1 root root 166 Oct 19 23:43 61-accelerometer.rules
    -rw-r--r-- 1 root root 369 Oct 17 15:34 61-gnome-bluetooth-rfkill.rules
    -rw-r--r-- 1 root root 2.2K Sep 14 09:07 64-md-raid.rules
    -rw-r--r-- 1 root root 40 Aug 12 18:32 65-kvm.rules
    -rw-r--r-- 1 root root 4.0K Oct 4 09:34 69-cd-sensors.rules
    -rw-r--r-- 1 root root 233 Jul 17 18:06 70-infrared.rules
    -rw-r--r-- 1 root root 2.6K Oct 19 23:43 70-udev-acl.rules
    -rw-r--r-- 1 root root 642 Oct 19 23:43 75-net-description.rules
    -rw-r--r-- 1 root root 254 Oct 19 23:43 75-probe_mtd.rules
    -rw-r--r-- 1 root root 642 Oct 19 23:43 75-tty-description.rules
    -rw-r--r-- 1 root root 3.3K Aug 3 10:00 77-mm-ericsson-mbm.rules
    -rw-r--r-- 1 root root 11K Aug 3 10:00 77-mm-longcheer-port-types.rules
    -rw-r--r-- 1 root root 379 Aug 3 10:00 77-mm-pcmcia-device-blacklist.rules
    -rw-r--r-- 1 root root 510 Aug 3 10:00 77-mm-platform-serial-whitelist.rules
    -rw-r--r-- 1 root root 1.6K Aug 3 10:00 77-mm-simtech-port-types.rules
    -rw-r--r-- 1 root root 3.0K Aug 3 10:00 77-mm-usb-device-blacklist.rules
    -rw-r--r-- 1 root root 1.6K Aug 3 10:00 77-mm-x22x-port-types.rules
    -rw-r--r-- 1 root root 9.3K Aug 3 10:00 77-mm-zte-port-types.rules
    -rw-r--r-- 1 root root 284 Sep 20 09:26 77-nm-olpc-mesh.rules
    -rw-r--r-- 1 root root 4.2K Oct 19 23:43 78-sound-card.rules
    -rw-r--r-- 1 root root 559 Oct 19 23:43 80-drivers.rules
    -rw-r--r-- 1 root root 667 Aug 3 10:00 80-mm-candidate.rules
    -rw-r--r-- 1 root root 9.3K Aug 26 18:47 80-udisks.rules
    -rw-r--r-- 1 root root 372 Oct 19 23:43 81-arch.rules
    -rw-r--r-- 1 root root 335 Apr 4 2011 85-regulatory.rules
    -rw-r--r-- 1 root root 602 Aug 4 17:39 85-usbmuxd.rules
    -rw-r--r-- 1 root root 131 Aug 17 09:43 90-alsa-restore.rules
    -rw-r--r-- 1 root root 83 Jan 10 2011 90-hal.rules
    -rw-r--r-- 1 root root 1.9K Aug 9 15:18 90-libgpod.rules
    -rw-r--r-- 1 root root 2.0K Oct 20 17:26 90-pulseaudio.rules
    -rw-r--r-- 1 root root 847 Oct 4 09:34 95-cd-devices.rules
    -r--r--r-- 1 root root 492 Nov 1 2009 95-dm-notify.rules
    -rw-r--r-- 1 root root 3.0K Oct 19 23:43 95-keyboard-force-release.rules
    -rw-r--r-- 1 root root 11K Oct 19 23:43 95-keymap.rules
    -rw-r--r-- 1 root root 155 Oct 19 23:43 95-udev-late.rules
    -rw-r--r-- 1 root root 2.8K Oct 3 13:17 95-upower-battery-recall-dell.rules
    -rw-r--r-- 1 root root 1.2K Oct 3 13:17 95-upower-battery-recall-fujitsu.rules
    -rw-r--r-- 1 root root 1020 Oct 3 13:17 95-upower-battery-recall-gateway.rules
    -rw-r--r-- 1 root root 1.6K Oct 3 13:17 95-upower-battery-recall-ibm.rules
    -rw-r--r-- 1 root root 774 Oct 3 13:17 95-upower-battery-recall-lenovo.rules
    -rw-r--r-- 1 root root 1.1K Oct 3 13:17 95-upower-battery-recall-toshiba.rules
    -rw-r--r-- 1 root root 1.6K Oct 3 13:17 95-upower-csr.rules
    -rw-r--r-- 1 root root 6.0K Oct 3 13:17 95-upower-hid.rules
    -rw-r--r-- 1 root root 354 Oct 3 13:17 95-upower-wup.rules
    -rw-r--r-- 1 root root 1.4K Aug 1 12:20 97-bluetooth-hid2hci.rules
    -rw-r--r-- 1 root root 28 Oct 7 2010 99-fuse.rules
    Can anyone confirm this?  If I get confirmation that this is indeed present for other users (and a bug, not a "feature"), I'll open a bug report for the udev package.
    Also, semi-related, in the post-install message from the udev package they refer you to the folder /etc/udev.d/rules, however, that directory structure doesn't exist on my system, and the old /etc/udev/rules.d is still present.
    I'd appreciate any information or input.  If any further information is required, I'll gladly supply it.
    Last edited by lswest (2011-10-26 09:54:58)

    Since the upgrade to 174, thunar doesn't mount anymore external hdd or usb. I removed my user from storage group.
    Searching for solutions I find out that I have the same errors in the logs that lswest has.
    /var/log/messages.log:
    Oct 29 10:29:46 localhost udevd[75]: starting version 174
    while /var/log/errors.log:
    Oct 29 11:42:14 localhost udevd[75]: can not find '/lib/udev/rules.d/42-qemu-usb.rules': No such file or directory
    Oct 29 11:42:14 localhost udevd[75]: can not find '/lib/udev/rules.d/50-firmware.rules': No such file or directory
    Oct 29 11:42:14 localhost udevd[75]: can not find '/lib/udev/rules.d/50-udev-default.rules': No such file or directory
    Oct 29 11:42:14 localhost udevd[75]: can not find '/lib/udev/rules.d/60-cdrom_id.rules': No such file or directory
    Oct 29 11:42:14 localhost udevd[75]: can not find '/lib/udev/rules.d/60-persistent-alsa.rules': No such file or directory
    Oct 29 11:42:14 localhost udevd[75]: can not find '/lib/udev/rules.d/60-persistent-input.rules': No such file or directory
    Oct 29 11:42:14 localhost udevd[75]: can not find '/lib/udev/rules.d/60-persistent-serial.rules': No such file or directory
    Oct 29 11:42:14 localhost udevd[75]: can not find '/lib/udev/rules.d/60-persistent-storage-tape.rules': No such file or directory
    Oct 29 11:42:14 localhost udevd[75]: can not find '/lib/udev/rules.d/60-persistent-storage.rules': No such file or directory
    Oct 29 11:42:14 localhost udevd[75]: can not find '/lib/udev/rules.d/60-persistent-v4l.rules': No such file or directory
    Oct 29 11:42:14 localhost udevd[75]: can not find '/lib/udev/rules.d/61-accelerometer.rules': No such file or directory
    Oct 29 11:42:14 localhost udevd[75]: can not find '/lib/udev/rules.d/70-udev-acl.rules': No such file or directory
    Oct 29 11:42:14 localhost udevd[75]: can not find '/lib/udev/rules.d/75-net-description.rules': No such file or directory
    Oct 29 11:42:14 localhost udevd[75]: can not find '/lib/udev/rules.d/75-probe_mtd.rules': No such file or directory
    Oct 29 11:42:14 localhost udevd[75]: can not find '/lib/udev/rules.d/75-tty-description.rules': No such file or directory
    Oct 29 11:42:14 localhost udevd[75]: can not find '/lib/udev/rules.d/78-sound-card.rules': No such file or directory
    Oct 29 11:42:14 localhost udevd[75]: can not find '/lib/udev/rules.d/80-drivers.rules': No such file or directory
    Oct 29 11:42:14 localhost udevd[75]: can not find '/lib/udev/rules.d/81-arch.rules': No such file or directory
    Oct 29 11:42:14 localhost udevd[75]: can not find '/lib/udev/rules.d/95-keyboard-force-release.rules': No such file or directory
    Oct 29 11:42:14 localhost udevd[75]: can not find '/lib/udev/rules.d/95-keymap.rules': No such file or directory
    Edit: a fresh installation of udev seems stopping error message flooding in errors.log, but I still can't automount drives and reboot/shutdown with dbus-send method.
    Last edited by oceans11 (2011-10-29 10:29:48)

  • [SOLVED] Udev: recognising plugging/unplugging of USB Audio Device

    Hi!
    I am trying to write an udev rule to detect if an usb audio device was plugged / unplugged to change my default audio device (in effect this udev rule should run a bash script..).
    Right now it looks like that:
    KERNEL=="pcmC[D0-9cp]*", DRIVERS=="usb", ACTION=="add", PROGRAM="/bin/bash -c '/home/me/dotfiles/soundconf.sh attached'"
    and I have a second rule for "remove" instead of add calling a different parameter.
    However, unfortunately the change is not being detected. my sound devices are listed in e.g. /proc/asound/card0/pcm0c etc for my first card and /proc/asound/card4/... for the second.
    They are also listed in /proc/asound/NAMEOFCARD (e.g. PCH).
    how can i reliably detect if one was plugged or unplugged?
    thanks !
    Last edited by replax (2013-11-27 22:50:00)

    hi!
    thanks!
    my output for "sudo udevadm monitor --kernel" is:
    monitor will print the received events for:
    KERNEL - the kernel uevent
    KERNEL[409.000749] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/input/input24/event18 (input)
    KERNEL[409.023556] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/input/input24 (input)
    KERNEL[409.023611] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/0003:262A:10E1.0005/hidraw/hidraw0 (hidraw)
    KERNEL[409.023632] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/0003:262A:10E1.0005 (hid)
    KERNEL[409.023648] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0 (usb)
    KERNEL[409.023829] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/pcmC1D1p (sound)
    KERNEL[409.023845] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/pcmC1D0p (sound)
    KERNEL[409.023859] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/controlC1 (sound)
    KERNEL[409.023869] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1 (sound)
    KERNEL[409.023885] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1 (usb)
    KERNEL[409.023899] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.3 (usb)
    KERNEL[409.024517] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1 (usb)
    KERNEL[411.633928] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1 (usb)
    KERNEL[411.634043] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0 (usb)
    KERNEL[411.648482] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/0003:262A:10E1.0006 (hid)
    KERNEL[411.649170] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/input/input25 (input)
    KERNEL[411.649320] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/input/input25/event18 (input)
    KERNEL[411.649347] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/0003:262A:10E1.0006/hidraw/hidraw0 (hidraw)
    KERNEL[411.657385] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1 (usb)
    KERNEL[411.680527] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1 (sound)
    KERNEL[411.680564] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/pcmC1D1p (sound)
    KERNEL[411.680737] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/pcmC1D0p (sound)
    KERNEL[411.680796] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/controlC1 (sound)
    KERNEL[411.680951] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.3 (usb)
    KERNEL[411.705251] change /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1 (sound)
    and my output for "sudo udevadm --udev --property" is:
    monitor will print the received events for:
    UDEV - the event which udev sends out after rule processing
    UDEV [409.001439] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/input/input24/event18 (
    input)
    ACTION=remove
    DEVLINKS=/dev/input/by-id/usb-HiFimeDIY_Audio_SA9023_USB_Audio-event-if00 /dev/input/by-path/pci-0000:00:1d.0-usb-0:1.2
    .1:1.0-event
    DEVNAME=/dev/input/event18
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/input/input24/event18
    ID_BUS=usb
    ID_INPUT=1
    ID_MODEL=SA9023_USB_Audio
    ID_MODEL_ENC=SA9023\x20USB\x20Audio
    ID_MODEL_ID=10e1
    ID_PATH=pci-0000:00:1d.0-usb-0:1.2.1:1.0
    ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_2_1_1_0
    ID_REVISION=0001
    ID_SERIAL=HiFimeDIY_Audio_SA9023_USB_Audio
    ID_TYPE=hid
    ID_USB_DRIVER=usbhid
    ID_USB_INTERFACES=:030000:010100:010200:
    ID_USB_INTERFACE_NUM=00
    ID_VENDOR=HiFimeDIY_Audio
    ID_VENDOR_ENC=HiFimeDIY\x20Audio
    ID_VENDOR_ID=262a
    MAJOR=13
    MINOR=82
    SEQNUM=2036
    SUBSYSTEM=input
    USEC_INITIALIZED=4690
    UDEV [409.024376] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/input/input24 (input)
    ACTION=remove
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/input/input24
    EV=1
    ID_BUS=usb
    ID_FOR_SEAT=input-pci-0000_00_1d_0-usb-0_1_2_1_1_0
    ID_INPUT=1
    ID_MODEL=SA9023_USB_Audio
    ID_MODEL_ENC=SA9023\x20USB\x20Audio
    ID_MODEL_ID=10e1
    ID_PATH=pci-0000:00:1d.0-usb-0:1.2.1:1.0
    ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_2_1_1_0
    ID_REVISION=0001
    ID_SERIAL=HiFimeDIY_Audio_SA9023_USB_Audio
    ID_TYPE=hid
    ID_USB_DRIVER=usbhid
    ID_USB_INTERFACES=:030000:010100:010200:
    ID_USB_INTERFACE_NUM=00
    ID_VENDOR=HiFimeDIY_Audio
    ID_VENDOR_ENC=HiFimeDIY\x20Audio
    ID_VENDOR_ID=262a
    MODALIAS=input:b0003v262Ap10E1e0100-e0,kramlsfw
    NAME="HiFimeDIY Audio SA9023 USB Audio"
    PHYS="usb-0000:00:1d.0-1.2.1/input0"
    PRODUCT=3/262a/10e1/100
    PROP=0
    SEQNUM=2037
    SUBSYSTEM=input
    TAGS=:seat:
    UNIQ=""
    USEC_INITIALIZED=634532
    UDEV [409.024487] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/0003:262A:10E1.0005/hid
    raw/hidraw0 (hidraw)
    ACTION=remove
    DEVNAME=/dev/hidraw0
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/0003:262A:10E1.0005/hidraw/hidraw0
    MAJOR=248
    MINOR=0
    SEQNUM=2038
    SUBSYSTEM=hidraw
    USEC_INITIALIZED=9023681
    UDEV [409.026487] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/0003:262A:10E1.0005 (hi
    d)
    ACTION=remove
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/0003:262A:10E1.0005
    HID_ID=0003:0000262A:000010E1
    HID_NAME=HiFimeDIY Audio SA9023 USB Audio
    HID_PHYS=usb-0000:00:1d.0-1.2.1/input0
    MODALIAS=hid:b0003g0001v0000262Ap000010E1
    SEQNUM=2039
    SUBSYSTEM=hid
    USEC_INITIALIZED=23875
    UDEV [409.026531] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/controlC1 (
    sound)
    ACTION=remove
    DEVLINKS=/dev/snd/by-id/usb-HiFimeDIY_Audio_SA9023_USB_Audio-01 /dev/snd/by-path/pci-0000:00:1d.0-usb-0:1.2.1:1.1
    DEVNAME=/dev/snd/controlC1
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/controlC1
    ID_BUS=usb
    ID_MODEL=SA9023_USB_Audio
    ID_MODEL_ENC=SA9023\x20USB\x20Audio
    ID_MODEL_ID=10e1
    ID_PATH=pci-0000:00:1d.0-usb-0:1.2.1:1.1
    ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_2_1_1_1
    ID_REVISION=0001
    ID_SERIAL=HiFimeDIY_Audio_SA9023_USB_Audio
    ID_TYPE=audio
    ID_USB_DRIVER=snd-usb-audio
    ID_USB_INTERFACES=:030000:010100:010200:
    ID_USB_INTERFACE_NUM=01
    ID_VENDOR=HiFimeDIY_Audio
    ID_VENDOR_ENC=HiFimeDIY\x20Audio
    ID_VENDOR_ID=262a
    MAJOR=116
    MINOR=13
    SEQNUM=2043
    SUBSYSTEM=sound
    TAGS=:uaccess:
    USEC_INITIALIZED=665890
    UDEV [409.026557] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.3 (usb)
    ACTION=remove
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.3
    DEVTYPE=usb_interface
    ID_MODEL_FROM_DATABASE=USB-2.0 4-Port HUB
    ID_VENDOR_FROM_DATABASE=Genesys Logic, Inc.
    INTERFACE=1/2/0
    MODALIAS=usb:v262Ap10E1d0001dc00dsc00dp00ic01isc02ip00in03
    PRODUCT=262a/10e1/1
    SEQNUM=2046
    SUBSYSTEM=usb
    TYPE=0/0/0
    USEC_INITIALIZED=665944
    UDEV [409.026573] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0 (usb)
    ACTION=remove
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0
    DEVTYPE=usb_interface
    ID_MODEL_FROM_DATABASE=USB-2.0 4-Port HUB
    ID_VENDOR_FROM_DATABASE=Genesys Logic, Inc.
    INTERFACE=3/0/0
    MODALIAS=usb:v262Ap10E1d0001dc00dsc00dp00ic03isc00ip00in00
    PRODUCT=262a/10e1/1
    SEQNUM=2040
    SUBSYSTEM=usb
    TYPE=0/0/0
    USEC_INITIALIZED=130
    UDEV [409.026616] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/pcmC1D0p (s
    ound)
    ACTION=remove
    DEVNAME=/dev/snd/pcmC1D0p
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/pcmC1D0p
    MAJOR=116
    MINOR=12
    SEQNUM=2042
    SUBSYSTEM=sound
    TAGS=:uaccess:
    USEC_INITIALIZED=5836
    UDEV [409.078843] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/pcmC1D1p (s
    ound)
    ACTION=remove
    DEVNAME=/dev/snd/pcmC1D1p
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/pcmC1D1p
    MAJOR=116
    MINOR=11
    SEQNUM=2041
    SUBSYSTEM=sound
    TAGS=:uaccess:
    USEC_INITIALIZED=5794
    UDEV [409.079039] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1 (sound)
    ACTION=remove
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1
    ID_BUS=usb
    ID_FOR_SEAT=sound-pci-0000_00_1d_0-usb-0_1_2_1_1_1
    ID_ID=usb-HiFimeDIY_Audio_SA9023_USB_Audio-01-Audio
    ID_MODEL=SA9023_USB_Audio
    ID_MODEL_ENC=SA9023\x20USB\x20Audio
    ID_MODEL_FROM_DATABASE=USB-2.0 4-Port HUB
    ID_MODEL_ID=10e1
    ID_PATH=pci-0000:00:1d.0-usb-0:1.2.1:1.1
    ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_2_1_1_1
    ID_REVISION=0001
    ID_SERIAL=HiFimeDIY_Audio_SA9023_USB_Audio
    ID_TYPE=audio
    ID_USB_DRIVER=snd-usb-audio
    ID_USB_INTERFACES=:030000:010100:010200:
    ID_USB_INTERFACE_NUM=01
    ID_VENDOR=HiFimeDIY_Audio
    ID_VENDOR_ENC=HiFimeDIY\x20Audio
    ID_VENDOR_FROM_DATABASE=Genesys Logic, Inc.
    ID_VENDOR_ID=262a
    SEQNUM=2044
    SOUND_INITIALIZED=1
    SUBSYSTEM=sound
    SYSTEMD_WANTS=sound.target
    TAGS=:seat:systemd:
    USEC_INITIALIZED=5712
    UDEV [409.079517] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1 (usb)
    ACTION=remove
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1
    DEVTYPE=usb_interface
    ID_MODEL_FROM_DATABASE=USB-2.0 4-Port HUB
    ID_VENDOR_FROM_DATABASE=Genesys Logic, Inc.
    INTERFACE=1/1/0
    MODALIAS=usb:v262Ap10E1d0001dc00dsc00dp00ic01isc01ip00in01
    PRODUCT=262a/10e1/1
    SEQNUM=2045
    SUBSYSTEM=usb
    TYPE=0/0/0
    USEC_INITIALIZED=642712
    UDEV [409.085432] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1 (usb)
    ACTION=remove
    BUSNUM=004
    DEVNAME=/dev/bus/usb/004/010
    DEVNUM=010
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1
    DEVTYPE=usb_device
    ID_BUS=usb
    ID_MODEL=SA9023_USB_Audio
    ID_MODEL_ENC=SA9023\x20USB\x20Audio
    ID_MODEL_FROM_DATABASE=USB-2.0 4-Port HUB
    ID_MODEL_ID=10e1
    ID_REVISION=0001
    ID_SERIAL=HiFimeDIY_Audio_SA9023_USB_Audio
    ID_USB_INTERFACES=:030000:010100:010200:
    ID_VENDOR=HiFimeDIY_Audio
    ID_VENDOR_ENC=HiFimeDIY\x20Audio
    ID_VENDOR_FROM_DATABASE=Genesys Logic, Inc.
    ID_VENDOR_ID=262a
    MAJOR=189
    MINOR=393
    PRODUCT=262a/10e1/1
    SEQNUM=2047
    SUBSYSTEM=usb
    TYPE=0/0/0
    USEC_INITIALIZED=619842
    UDEV [411.697540] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1 (usb)
    ACTION=add
    BUSNUM=004
    DEVNAME=/dev/bus/usb/004/011
    DEVNUM=011
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1
    DEVTYPE=usb_device
    ID_BUS=usb
    ID_MODEL=SA9023_USB_Audio
    ID_MODEL_ENC=SA9023\x20USB\x20Audio
    ID_MODEL_FROM_DATABASE=USB-2.0 4-Port HUB
    ID_MODEL_ID=10e1
    ID_REVISION=0001
    ID_SERIAL=HiFimeDIY_Audio_SA9023_USB_Audio
    ID_USB_INTERFACES=:030000:010100:010200:
    ID_VENDOR=HiFimeDIY_Audio
    ID_VENDOR_ENC=HiFimeDIY\x20Audio
    ID_VENDOR_FROM_DATABASE=Genesys Logic, Inc.
    ID_VENDOR_ID=262a
    MAJOR=189
    MINOR=394
    PRODUCT=262a/10e1/1
    SEQNUM=2048
    SUBSYSTEM=usb
    TYPE=0/0/0
    USEC_INITIALIZED=33928
    UDEV [411.699672] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.3 (usb)
    ACTION=add
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.3
    DEVTYPE=usb_interface
    DRIVER=snd-usb-audio
    ID_MODEL_FROM_DATABASE=USB-2.0 4-Port HUB
    ID_VENDOR_FROM_DATABASE=Genesys Logic, Inc.
    INTERFACE=1/2/0
    MODALIAS=usb:v262Ap10E1d0001dc00dsc00dp00ic01isc02ip00in03
    PRODUCT=262a/10e1/1
    SEQNUM=2059
    SUBSYSTEM=usb
    TYPE=0/0/0
    USEC_INITIALIZED=80939
    UDEV [411.699773] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0 (usb)
    ACTION=add
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0
    DEVTYPE=usb_interface
    ID_MODEL_FROM_DATABASE=USB-2.0 4-Port HUB
    ID_VENDOR_FROM_DATABASE=Genesys Logic, Inc.
    INTERFACE=3/0/0
    MODALIAS=usb:v262Ap10E1d0001dc00dsc00dp00ic03isc00ip00in00
    PRODUCT=262a/10e1/1
    SEQNUM=2049
    SUBSYSTEM=usb
    TYPE=0/0/0
    USEC_INITIALIZED=34043
    UDEV [411.699840] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1 (usb)
    ACTION=add
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1
    DEVTYPE=usb_interface
    ID_MODEL_FROM_DATABASE=USB-2.0 4-Port HUB
    ID_VENDOR_FROM_DATABASE=Genesys Logic, Inc.
    INTERFACE=1/1/0
    MODALIAS=usb:v262Ap10E1d0001dc00dsc00dp00ic01isc01ip00in01
    PRODUCT=262a/10e1/1
    SEQNUM=2054
    SUBSYSTEM=usb
    TYPE=0/0/0
    USEC_INITIALIZED=57387
    UDEV [411.701367] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/0003:262A:10E1.0006 (hi
    d)
    ACTION=add
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/0003:262A:10E1.0006
    HID_ID=0003:0000262A:000010E1
    HID_NAME=HiFimeDIY Audio SA9023 USB Audio
    HID_PHYS=usb-0000:00:1d.0-1.2.1/input0
    MODALIAS=hid:b0003g0001v0000262Ap000010E1
    SEQNUM=2050
    SUBSYSTEM=hid
    USEC_INITIALIZED=48481
    UDEV [411.701544] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1 (sound)
    ACTION=add
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1
    ID_FOR_SEAT=sound-pci-0000_00_1d_0-usb-0_1_2_1_1_1
    ID_PATH=pci-0000:00:1d.0-usb-0:1.2.1:1.1
    ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_2_1_1_1
    SEQNUM=2055
    SUBSYSTEM=sound
    SYSTEMD_WANTS=sound.target
    TAGS=:seat:systemd:
    USEC_INITIALIZED=80503
    UDEV [411.702560] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/input/input25 (input)
    ACTION=add
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/input/input25
    EV=1
    ID_BUS=usb
    ID_FOR_SEAT=input-pci-0000_00_1d_0-usb-0_1_2_1_1_0
    ID_INPUT=1
    ID_MODEL=SA9023_USB_Audio
    ID_MODEL_ENC=SA9023\x20USB\x20Audio
    ID_MODEL_ID=10e1
    ID_PATH=pci-0000:00:1d.0-usb-0:1.2.1:1.0
    ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_2_1_1_0
    ID_REVISION=0001
    ID_SERIAL=HiFimeDIY_Audio_SA9023_USB_Audio
    ID_TYPE=hid
    ID_USB_DRIVER=usbhid
    ID_USB_INTERFACES=:030000:010100:010200:
    ID_USB_INTERFACE_NUM=00
    ID_VENDOR=HiFimeDIY_Audio
    ID_VENDOR_ENC=HiFimeDIY\x20Audio
    ID_VENDOR_ID=262a
    MODALIAS=input:b0003v262Ap10E1e0100-e0,kramlsfw
    NAME="HiFimeDIY Audio SA9023 USB Audio"
    PHYS="usb-0000:00:1d.0-1.2.1/input0"
    PRODUCT=3/262a/10e1/100
    PROP=0
    SEQNUM=2051
    SUBSYSTEM=input
    TAGS=:seat:
    UNIQ=""
    USEC_INITIALIZED=49147
    UDEV [411.703227] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/pcmC1D0p (s
    ound)
    ACTION=add
    DEVNAME=/dev/snd/pcmC1D0p
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/pcmC1D0p
    MAJOR=116
    MINOR=12
    SEQNUM=2057
    SUBSYSTEM=sound
    TAGS=:uaccess:
    USEC_INITIALIZED=80672
    UDEV [411.704394] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/0003:262A:10E1.0006/hid
    raw/hidraw0 (hidraw)
    ACTION=add
    DEVNAME=/dev/hidraw0
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/0003:262A:10E1.0006/hidraw/hidraw0
    MAJOR=248
    MINOR=0
    SEQNUM=2053
    SUBSYSTEM=hidraw
    USEC_INITIALIZED=49353
    UDEV [411.705903] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/input/input25/event18 (
    input)
    ACTION=add
    DEVLINKS=/dev/input/by-id/usb-HiFimeDIY_Audio_SA9023_USB_Audio-event-if00 /dev/input/by-path/pci-0000:00:1d.0-usb-0:1.2
    .1:1.0-event
    DEVNAME=/dev/input/event18
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/input/input25/event18
    ID_BUS=usb
    ID_INPUT=1
    ID_MODEL=SA9023_USB_Audio
    ID_MODEL_ENC=SA9023\x20USB\x20Audio
    ID_MODEL_ID=10e1
    ID_PATH=pci-0000:00:1d.0-usb-0:1.2.1:1.0
    ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_2_1_1_0
    ID_REVISION=0001
    ID_SERIAL=HiFimeDIY_Audio_SA9023_USB_Audio
    ID_TYPE=hid
    ID_USB_DRIVER=usbhid
    ID_USB_INTERFACES=:030000:010100:010200:
    ID_USB_INTERFACE_NUM=00
    ID_VENDOR=HiFimeDIY_Audio
    ID_VENDOR_ENC=HiFimeDIY\x20Audio
    ID_VENDOR_ID=262a
    MAJOR=13
    MINOR=82
    SEQNUM=2052
    SUBSYSTEM=input
    USEC_INITIALIZED=49330
    UDEV [411.714557] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/controlC1 (
    sound)
    ACTION=add
    DEVLINKS=/dev/snd/by-id/usb-HiFimeDIY_Audio_SA9023_USB_Audio-01 /dev/snd/by-path/pci-0000:00:1d.0-usb-0:1.2.1:1.1
    DEVNAME=/dev/snd/controlC1
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/controlC1
    ID_BUS=usb
    ID_MODEL=SA9023_USB_Audio
    ID_MODEL_ENC=SA9023\x20USB\x20Audio
    ID_MODEL_ID=10e1
    ID_PATH=pci-0000:00:1d.0-usb-0:1.2.1:1.1
    ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_2_1_1_1
    ID_REVISION=0001
    ID_SERIAL=HiFimeDIY_Audio_SA9023_USB_Audio
    ID_TYPE=audio
    ID_USB_DRIVER=snd-usb-audio
    ID_USB_INTERFACES=:030000:010100:010200:
    ID_USB_INTERFACE_NUM=01
    ID_VENDOR=HiFimeDIY_Audio
    ID_VENDOR_ENC=HiFimeDIY\x20Audio
    ID_VENDOR_ID=262a
    MAJOR=116
    MINOR=13
    SEQNUM=2058
    SUBSYSTEM=sound
    TAGS=:uaccess:
    USEC_INITIALIZED=80812
    UDEV [411.759604] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/pcmC1D1p (s
    ound)
    ACTION=add
    DEVNAME=/dev/snd/pcmC1D1p
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/pcmC1D1p
    MAJOR=116
    MINOR=11
    SEQNUM=2056
    SUBSYSTEM=sound
    TAGS=:uaccess:
    USEC_INITIALIZED=80575
    UDEV [411.760476] change /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1 (sound)
    ACTION=change
    DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1
    ID_BUS=usb
    ID_FOR_SEAT=sound-pci-0000_00_1d_0-usb-0_1_2_1_1_1
    ID_ID=usb-HiFimeDIY_Audio_SA9023_USB_Audio-01-Audio
    ID_MODEL=SA9023_USB_Audio
    ID_MODEL_ENC=SA9023\x20USB\x20Audio
    ID_MODEL_FROM_DATABASE=USB-2.0 4-Port HUB
    ID_MODEL_ID=10e1
    ID_PATH=pci-0000:00:1d.0-usb-0:1.2.1:1.1
    ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_2_1_1_1
    ID_REVISION=0001
    ID_SERIAL=HiFimeDIY_Audio_SA9023_USB_Audio
    ID_TYPE=audio
    ID_USB_DRIVER=snd-usb-audio
    ID_USB_INTERFACES=:030000:010100:010200:
    ID_USB_INTERFACE_NUM=01
    ID_VENDOR=HiFimeDIY_Audio
    ID_VENDOR_ENC=HiFimeDIY\x20Audio
    ID_VENDOR_FROM_DATABASE=Genesys Logic, Inc.
    ID_VENDOR_ID=262a
    SEQNUM=2060
    SOUND_INITIALIZED=1
    SUBSYSTEM=sound
    SYSTEMD_WANTS=sound.target
    TAGS=:seat:systemd:
    USEC_INITIALIZED=80503
    the output of "sudo udevadm monitor" is:
    monitor will print the received events for:
    UDEV - the event which udev sends out after rule processing
    KERNEL - the kernel uevent
    KERNEL[10520.780009] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/input/input24/event17 (input)
    UDEV [10520.783295] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/input/input24/event17 (input)
    KERNEL[10520.789826] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/input/input24 (input)
    KERNEL[10520.789859] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/0003:262A:10E1.0005/hidraw/hidraw0 (hidraw)
    KERNEL[10520.789871] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/0003:262A:10E1.0005 (hid)
    KERNEL[10520.789895] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0 (usb)
    KERNEL[10520.789965] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/pcmC1D1p (sound)
    KERNEL[10520.789999] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/pcmC1D0p (sound)
    KERNEL[10520.790031] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/controlC1 (sound)
    KERNEL[10520.790473] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1 (sound)
    UDEV [10520.790483] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/0003:262A:10E1.0005/hidraw/hidraw0 (hidraw)
    KERNEL[10520.790494] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1 (usb)
    UDEV [10520.790521] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/input/input24 (input)
    KERNEL[10520.790533] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.3 (usb)
    UDEV [10520.790543] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/pcmC1D1p (sound)
    KERNEL[10520.790615] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1 (usb)
    UDEV [10520.790653] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/pcmC1D0p (sound)
    UDEV [10520.790723] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/controlC1 (sound)
    UDEV [10520.790843] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/0003:262A:10E1.0005 (hid)
    UDEV [10520.790870] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1 (sound)
    UDEV [10520.791022] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.3 (usb)
    UDEV [10520.791133] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1 (usb)
    UDEV [10520.791157] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0 (usb)
    UDEV [10520.795934] remove /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1 (usb)
    KERNEL[10523.411837] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1 (usb)
    KERNEL[10523.411961] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0 (usb)
    KERNEL[10523.425856] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/0003:262A:10E1.0006 (hid)
    KERNEL[10523.426126] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/input/input25 (input)
    KERNEL[10523.426179] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/input/input25/event17 (input)
    KERNEL[10523.426268] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/0003:262A:10E1.0006/hidraw/hidraw0 (hidraw)
    KERNEL[10523.433989] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1 (usb)
    KERNEL[10523.455486] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1 (sound)
    KERNEL[10523.455508] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/pcmC1D1p (sound)
    KERNEL[10523.455540] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/pcmC1D0p (sound)
    KERNEL[10523.455580] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/controlC1 (sound)
    KERNEL[10523.455608] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.3 (usb)
    UDEV [10523.463039] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1 (usb)
    UDEV [10523.464322] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0 (usb)
    UDEV [10523.464384] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1 (usb)
    UDEV [10523.464409] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.3 (usb)
    UDEV [10523.465345] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/0003:262A:10E1.0006 (hid)
    UDEV [10523.465380] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1 (sound)
    UDEV [10523.466303] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/input/input25 (input)
    UDEV [10523.466417] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/0003:262A:10E1.0006/hidraw/hidraw0 (hidraw)
    UDEV [10523.467311] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.0/input/input25/event17 (input)
    UDEV [10523.468387] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/pcmC1D1p (sound)
    UDEV [10523.468659] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/pcmC1D0p (sound)
    KERNEL[10523.468942] change /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1 (sound)
    UDEV [10523.474581] add /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1/controlC1 (sound)
    UDEV [10523.475757] change /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.1/4-1.2.1:1.1/sound/card1 (sound)
    please not that my usb soundcard is attached through a usb hub to my laptop and that it was attached when I ran the command, then removed it and attached it again.
    tried to use those udev rules:
    KERNEL=="pcmC1D1p", DRIVERS=="usb", ACTION=="add", RUN+="/bin/bash -c '/home/me/dotfiles/soundconf.sh attached'"
    KERNEL=="pcmC1D1p", DRIVERS=="usb", ACTION=="remove", RUN+="/bin/bash -c '/home/me/dotfiles/soundconf.sh detached'"
    to no avail unfortunately...
    thanks a lot for your patience and time !

  • Udev rules not applied during bootup

    I don't know if this problem is associated with the lates kernel-upgrade to 2.6.21 but I didn't have it before.
    My problem:
    I have an external USB-harddrive that gets mounted everytime I boot because it is listed in my fstab. To avoid confusion with other external storages (such as USB-sticks etc.) I worte an udev rule for it:
    # Externe USB-Festplatte von TrekStor
    BUS=="usb", KERNEL=="sd?1" SYSFS{serial}=="307541703010",SYMLINK+="externe"
    As I've said this worked well before but now I get a message during the booting process saying that /dev/externe couldn't be found. But it actually IS recognised by udev. I just have to do a
    mount -a
    after the booting process and everything works again.
    Does anyone have an idea what the problem could be? It seems to me that all the devices listed in fstab get mounted before the udev rules are applied.

    Ok, I solved my problem: I'm not mounting my USB-HD through fstab anymore. I'm using udev-rules as described here.
    Still I'd be interesting to know what went wrong.
    Last edited by mata_svada (2007-05-21 05:11:06)

  • Udev rule for mobile phone

    Hi.
    I want to sync my phone with my laptop but the udev rule don't want to work.
    I did it like descriped here: http://libsyncml.opensync.org/wiki/obex-guide
    # lsusb
    Bus 004 Device 001: ID 0000:0000
    Bus 003 Device 005: ID 0fce:d042 Sony Ericsson Mobile Communications AB
    Bus 003 Device 001: ID 0000:0000
    Bus 002 Device 001: ID 0000:0000
    Bus 001 Device 001: ID 0000:0000
    # vi /etc/udev/rules.d/w810i.rules
    BUS=="usb", SYSFS{idVendor}=="0fce", SYSFS{idProduct}=="d042", MODE="0660", GROUP="users"
    # udevcontrol reload_rules
    But i can't connect as user to the mobile - as root it works as expected.
    Any ideas?
    Thanks, Andreas

    I'm pretty sure it's the same problem as described in comments of this bug report: http://bugs.archlinux.org/task/9935#comment26467
    As a workaround maybe you can substitute the idVendor attribute with another(s).

Maybe you are looking for