EzDevInfo.com

udev interview questions

Top udev frequently asked interview questions

Update udev after fdisk run

How to update /dev directory after creation of new partition on a disk? I have the udev installed, it works perfectly except this. The new devices appear only on reboot.


Source: (StackOverflow)

How to check if a udev rule fired?

I am trying to acquaint myself with udev, under Ubuntu 13.10.

Here is my first simple 95.usbbackup.rules rule:

ACTION=="add", SUBSYSTEMS="usb", RUN+="/usr/local/bin/my_backup.sh"

and here is the script (which has been chmodded +x) my_backup.sh :

#!/bin/bash
touch /tmp/test

Nothing at all happens when I plug in external drives. How can I check (a log, a command, anything) if the rule fired?

Thanks a lot


Source: (StackOverflow)

Advertisements

3g modem is not recognized as an ethernet device without rebooting

I have two CentOS5 servers with kernel versions 3.4.52 and Huawei e353 usb 3g modem. When I plug the modem to my server usb_modeswitch runs and I can see the modem as an ethernet device with ifconfig -a command on the properly working server. But other server is not working properly. I can't see any ethernet after I plug the modem device.

  • All of servers have the same versions of the usb_modeswitch rpm.

before runnig usb_modeswitch

 working properly                     not working properly
 # lsusb | grep 12d1                  # lsusb | grep 12d1
 Bus 001 Device 005: ID 12d1:1f01     Bus 001 Device 005: ID 12d1:1f01`

after running usb_modeswitch

 working properly                     not working properly
 # lsusb | grep 12d1                  # lsusb | grep 12d1
 Bus 001 Device 005: ID 12d1:14db     Bus 001 Device 005: ID 12d1:14db

 # rpm -qa | grep modesw              # rpm -qa | grep modesw
 usb_modeswitch-data-20130610-1.lbr   usb_modeswitch-data-20130610-1.lbr
 usb_modeswitch-1.2.6-2               usb_modeswitch-1.2.6-2`
  • have compared /etc/udev directories of the two servers with diff but there isn't any difference

There is an interesting thing about the not properly working server. After I reboot the server while the usb 3g modem plugged, the modem works properly and I can see it as an ethernet device with the ifconfig -a command. So I thought that if i can reload udev, I would see the modem as an ethernet device so I run the following commands:

/sbin/udevcontrol reload_rules
/sbin/start_udev 

But it did not solve the problem. And also I thought that the two servers may have been builded with different kernel parameters. So I compared the output of sysctl -a on each server.

 # diff config_workingProperly config_notWorkingProperly -y 

CONFIG_TREE_PREEMPT_RCU=y                    | CONFIG_TREE_RCU=y
CONFIG_PREEMPT_RCU=y                         | # CONFIG_PREEMPT_RCU is not set
# CONFIG_INLINE_SPIN_UNLOCK_IRQ is not set   | CONFIG_INLINE_SPIN_UNLOCK_IRQ=y
# CONFIG_INLINE_READ_UNLOCK is not set       | CONFIG_INLINE_READ_UNLOCK=y
# CONFIG_INLINE_READ_UNLOCK_IRQ is not set   | CONFIG_INLINE_READ_UNLOCK_IRQ=y
# CONFIG_INLINE_WRITE_UNLOCK is not set      | CONFIG_INLINE_WRITE_UNLOCK=y
# CONFIG_INLINE_WRITE_UNLOCK_IRQ is not set  | CONFIG_INLINE_WRITE_UNLOCK_IRQ=y
# CONFIG_PREEMPT_NONE is not set             | CONFIG_PREEMPT_NONE=y
CONFIG_PREEMPT=y                             | # CONFIG_PREEMPT is not set
# CONFIG_BLK_DEV_FD is not set               | CONFIG_BLK_DEV_FD=m
# CONFIG_IDE_GD is not set                   | CONFIG_IDE_GD=m
# CONFIG_BLK_DEV_IDECD is not set            | CONFIG_IDE_GD_ATA=y
# CONFIG_BLK_DEV_SR_VENDOR is not set        | CONFIG_BLK_DEV_SR_VENDOR=y
CONFIG_JFS_FS=m                              | # CONFIG_JFS_FS is not set
# CONFIG_CUSE is not set                     | CONFIG_CUSE=y
CONFIG_ISO9660_FS=m                          | CONFIG_ISO9660_FS=y
CONFIG_UDF_FS=m                              | CONFIG_UDF_FS=y
CONFIG_FAT_FS=m                              | CONFIG_FAT_FS=y
CONFIG_MSDOS_FS=m                            | CONFIG_MSDOS_FS=y
CONFIG_VFAT_FS=m                             | CONFIG_VFAT_FS=y
CONFIG_SQUASHFS=m                            | CONFIG_SQUASHFS=y
# CONFIG_SQUASHFS_XATTR is not set           | CONFIG_SQUASHFS_XATTR=y
# CONFIG_SQUASHFS_LZO is not set             | CONFIG_SQUASHFS_LZO=y
# CONFIG_SQUASHFS_XZ is not set              | CONFIG_SQUASHFS_XZ=y
CONFIG_CRC_ITU_T=m                           | CONFIG_CRC_ITU_T=y
# CONFIG_RCU_BOOST is not set                <
CONFIG_UNINLINE_SPIN_UNLOCK=y                <
CONFIG_PREEMPT_COUNT=y                       <
CONFIG_JFS_POSIX_ACL=y                       <
CONFIG_JFS_SECURITY=y                        <
# CONFIG_JFS_DEBUG is not set                <
CONFIG_JFS_STATISTICS=y                      <
CONFIG_DEBUG_PREEMPT=y                       <
CONFIG_RCU_CPU_STALL_VERBOSE=y               <
# CONFIG_PREEMPT_TRACER is not set           <
                                             > CONFIG_OPTPROBES=y
                                             > CONFIG_IDE_ATAPI=y
                                             > # CONFIG_IDE_GD_ATAPI is not set
                                             > CONFIG_BLK_DEV_IDECD=m
                                             > CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS=y
                                             > # CONFIG_LEDS_TRIGGER_IDE_DISK is not set

So what might be causing the problem? Why can't the other server identify my 3g modem as an ethernet device without rebooting?


Source: (StackOverflow)

What problems does udev actually solve?

For that matter, what exactly was wrong with a bunch of static files in /dev? It's apparently unsatisfactory enough for developers to have reinvented this wheel by my count 3 times now (devfs -> udev + HAL -> udev), and now apparently it's going into the Grand Unified Init Program too, so four times.

I remember when I first started using Linux years ago being surprised that despite claims that "everything is a file", there's no /dev/eth0 (that later made sense, since it isn't a char or block device -- though a "packet" device type would be interesting...). Given that, why is the program that handles the char and block device file tree also responsible for network devices? I've seen vague references to "flexibility", but what does this add over what, say, ifconfig(8) does by just looking in /proc/net/dev? I know, for instance, NetworkManager won't be in Net or OpenBSD any time soon because it depends on udev, which neither team wants to write; what I don't understand is why a program that at least nominally is there to manage the /dev tree is apparently the only way to expose network devices that are already exposed multiple ways by the kernel (and none of them in /dev!).

Is it just because of hotplugging? Were there problems with the kernel just listening to the physical buses and loading the appropriate modules on an "device added" message? Or, God forbid, the actual administrator doing so? I do remember back in the early 2000's my servers would sometimes initialize their network cards in an unexpected order, and I suppose it makes sense to have that naming be decided in userland (though it wasn't terribly hard to fix back then), but this seems like a sledgehammer for a cockroach. (Or maybe that problem hits use cases I'm not thinking about much harder than rackmounted servers or PCs, which are my experience.)

So, to state my question plainly: what problems does udev actually solve, and how did devfs, HAL, and/or a plain old file fail to solve them? Is there a particular reason for that many different things (hotplugging, general device management, network device management, device naming, driver priority, etc.) to all be one program?


Source: (StackOverflow)

udev rule to auto load keyboard layout when usb keyboard plugged in

im trying to load a new keyboard layout when I plug in a usb keyboard but my udev rule isnt working.

SUBSYSTEM=="input", ATTR{idVendor}=="062a", ATTR{idProduct}=="0201", GOTO="usb_xmodmap_auto"

LABEL="usb_xmodmap_auto"
ACTION=="add", RUN+="/usr/bin/xmodmap ~/.usbXmodmap"
ACTION=="remove", RUN+="/usr/bin/xmodmap ~/.pndXmodmap"

I have reloaded the rules using:

>sudo udevadm control --reload-rules

and by restarting the system but when I plug in the usb keyboard the orginal xmodmap is still loaded and thus the keyboard layout is wrong, but if i run the command in the terminal

>/usr/bin/xmodmap ~/.usbXmodmap
or
>/usr/bin/xmodmap ~/.pndXmodmap

they work just fine.

hope soneone can help.

Edit:

just to help more I ran some udevadm tests:

>udevadm test --action=add /devices/platform/ehci-omap.0/usb1/1-2/1-2.3/1-2.3:1.1/input/input10

outputs:

run_command: calling: test
udevadm_test: version 151
This program is for debugging only, it does not run any program,
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.

[...]
parse_file: reading '/etc/udev/rules.d/usb-keyboard.rules' as rules file
udev_rules_new: rules use 100572 bytes tokens (8381 * 12 bytes), 21523 bytes buffer
udev_rules_new: temporary index used 35380 bytes (1769 * 20 bytes)
udev_device_new_from_syspath: device 0x3b4d8 has devpath '/devices/platform/ehci-omap.0/usb1/1-2/1-2.3/1-2.3:1.1/input/input10'
udev_rules_apply_to_event: RUN '/sbin/modprobe -b $env{MODALIAS}' /etc/udev/rules.d/80-drivers.rules:5
udev_rules_apply_to_event: RUN 'socket:@/org/freedesktop/hal/udev_event' /etc/udev/rules.d/90-hal.rules:2
udev_rules_apply_to_event: RUN '/sbin/modprobe $env{MODALIAS}' /etc/udev/rules.d/local.rules:31
udev_rules_apply_to_event: RUN 'socket:/org/kernel/udev/monitor' /etc/udev/rules.d/run.rules:2
udev_rules_apply_to_event: RUN '/usr/bin/xmodmap ~/.usbXmodmap' /etc/udev/rules.d/usb-keyboard.rules:4
udevadm_test: UDEV_LOG=6
udevadm_test: DEVPATH=/devices/platform/ehci-omap.0/usb1/1-2/1-2.3/1-2.3:1.1/input/input10
udevadm_test: PRODUCT=3/62a/201/110
udevadm_test: NAME="USB-compliant keyboard"
udevadm_test: PHYS="usb-ehci-omap.0-2.3/input1"
udevadm_test: UNIQ=""
udevadm_test: EV==1f
udevadm_test: KEY==837fff 2c3027 bf004444 0 0 1fe3 c04 a27c000 267bfa d941dfed 9e0000 0 0 0
udevadm_test: REL==143
udevadm_test: ABS==1 0
udevadm_test: MSC==10
udevadm_test: MODALIAS=input:b0003v062Ap0201e0110-e0,1,2,3,4,k71,72,73,74,77,80,82,83,85,86,87,88,89,8A,8B,8C,8E,8F,90,96,98,9B,9C,9E,9F,A1,A3,A4,A5,A6,A7,A8,A9,AB,AC,AD,AE,B1,B2,B5,CE,CF,D0,D1,D2,D5,D9,DB,E2,EA,EB,100,101,105,106,107,108,109,10A,10B,10C,162,166,16A,16E,178,179,17A,17B,17C,17D,17F,180,181,182,185,18C,18D,192,193,195,1A0,1A1,1A2,1A3,1A4,1A5,1A6,1A7,1A8,1A9,1AA,1AB,1AC,1AD,1AE,1B0,1B1,1B7,r0,1,6,8,a20,m4,lsfw
udevadm_test: ACTION=add
udevadm_test: SUBSYSTEM=input
udevadm_test: run: '/sbin/modprobe -b input:b0003v062Ap0201e0110-e0,1,2,3,4,k71,72,73,74,77,80,82,83,85,86,87,88,89,8A,8B,8C,8E,8F,90,96,98,9B,9C,9E,9F,A1,A3,A4,A5,A6,A7,A8,A9,AB,AC,AD,AE,B1,B2,B5,CE,CF,D0,D1,D2,D5,D9,DB,E2,EA,EB,100,101,105,106,107,108,109,10A,10B,10C,162,166,16A,16E,178,179,17A,17B,17C,17D,17F,180,181,182,185,18C,18D,192,193,195,1A0,1A1,1A2,1A3,1A4,1A5,1A6,1A7,1A8,1A9,1AA,1AB,1AC,1AD,1AE,1B0,1B1,1B7,r0,1,6,8,a20,m4,lsfw'
udevadm_test: run: 'socket:@/org/freedesktop/hal/udev_event'
udevadm_test: run: '/sbin/modprobe input:b0003v062Ap0201e0110-e0,1,2,3,4,k71,72,73,74,77,80,82,83,85,86,87,88,89,8A,8B,8C,8E,8F,90,96,98,9B,9C,9E,9F,A1,A3,A4,A5,A6,A7,A8,A9,AB,AC,AD,AE,B1,B2,B5,CE,CF,D0,D1,D2,D5,D9,DB,E2,EA,EB,100,101,105,106,107,108,109,10A,10B,10C,162,166,16A,16E,178,179,17A,17B,17C,17D,17F,180,181,182,185,18C,18D,192,193,195,1A0,1A1,1A2,1A3,1A4,1A5,1A6,1A7,1A8,1A9,1AA,1AB,1AC,1AD,1AE,1B0,1B1,1B7,r0,1,6,8,a20,m4,lsfw'
udevadm_test: run: 'socket:/org/kernel/udev/monitor'
udevadm_test: run: '/usr/bin/xmodmap ~/.usbXmodmap'

and

>udevadm test --action=remove /devices/platform/ehci-omap.0/usb1/1-2/1-2.3/1-2.3:1.1/input/input10

outputs:

run_command: calling: test
udevadm_test: version 151
This program is for debugging only, it does not run any program,
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.

[...]
parse_file: reading '/etc/udev/rules.d/usb-keyboard.rules' as rules file
udev_rules_new: rules use 100572 bytes tokens (8381 * 12 bytes), 21523 bytes buffer
udev_rules_new: temporary index used 35380 bytes (1769 * 20 bytes)
udev_device_new_from_syspath: device 0x3b4d8 has devpath '/devices/platform/ehci-omap.0/usb1/1-2/1-2.3/1-2.3:1.1/input/input10'
udev_rules_apply_to_event: RUN 'socket:@/org/freedesktop/hal/udev_event' /etc/udev/rules.d/90-hal.rules:2
udev_rules_apply_to_event: RUN 'socket:/org/kernel/udev/monitor' /etc/udev/rules.d/run.rules:2
udev_rules_apply_to_event: RUN '/usr/bin/xmodmap ~/.pndXmodmap' /etc/udev/rules.d/usb-keyboard.rules:5
udevadm_test: UDEV_LOG=6
udevadm_test: DEVPATH=/devices/platform/ehci-omap.0/usb1/1-2/1-2.3/1-2.3:1.1/input/input10
udevadm_test: PRODUCT=3/62a/201/110
udevadm_test: NAME="USB-compliant keyboard"
udevadm_test: PHYS="usb-ehci-omap.0-2.3/input1"
udevadm_test: UNIQ=""
udevadm_test: EV==1f
udevadm_test: KEY==837fff 2c3027 bf004444 0 0 1fe3 c04 a27c000 267bfa d941dfed 9e0000 0 0 0
udevadm_test: REL==143
udevadm_test: ABS==1 0
udevadm_test: MSC==10
udevadm_test: MODALIAS=input:b0003v062Ap0201e0110-e0,1,2,3,4,k71,72,73,74,77,80,82,83,85,86,87,88,89,8A,8B,8C,8E,8F,90,96,98,9B,9C,9E,9F,A1,A3,A4,A5,A6,A7,A8,A9,AB,AC,AD,AE,B1,B2,B5,CE,CF,D0,D1,D2,D5,D9,DB,E2,EA,EB,100,101,105,106,107,108,109,10A,10B,10C,162,166,16A,16E,178,179,17A,17B,17C,17D,17F,180,181,182,185,18C,18D,192,193,195,1A0,1A1,1A2,1A3,1A4,1A5,1A6,1A7,1A8,1A9,1AA,1AB,1AC,1AD,1AE,1B0,1B1,1B7,r0,1,6,8,a20,m4,lsfw
udevadm_test: ACTION=remove
udevadm_test: SUBSYSTEM=input
udevadm_test: run: 'socket:@/org/freedesktop/hal/udev_event'
udevadm_test: run: 'socket:/org/kernel/udev/monitor'
udevadm_test: run: '/usr/bin/xmodmap ~/.pndXmodmap'

which seems to show it should work, but it doesnt hope this helps get an answer.


Source: (StackOverflow)

Using udev rules to run a script on USB insertion

I'm trying to set up a script to run every time I plug in a USB device. I created the file /etc/udev/rules.d/90-local.rules and added the following rule:

ACTION=="add", SUBSYSTEM=="usb", KERNEL=="sd*", SYSFS{model}=="Cruzer*", RUN+="sh /home/jesse/Documents/Scripts/cruzer.sh"

The problem is that when the drive is connected, nothing happens. The script, for debugging purposes, is rigged to send a notification with notify-send, which is installed and works fine from the terminal.

The path to the script is correct, as I've run that exact command in the terminal without any troubles.


Source: (StackOverflow)

Assigning USB hub to specific seat in multiseat configuration

On my debian-based machine, I have a working multiseat configuration.

One annoying detail that so far I couldn't fix is that any USB hardware I connect is always assigned to the primary seat.

Scouring the internet, it seems that the solution to this problem is to attach a USB hub to the machine and assign the "ownership" of it to the secondary seat. This way, any device attached to the hub will be controlled to the secondary seat. However, I'm a bit confused about how to assign the ownership.

lsusb allowed me to track the bus position of the hub:

Bus 002 Device 004: ID 1a40:0201 Terminus Technology Inc. Hub

I will be most grateful if somebody will guide me from here...

PS: Initially I thought I had to tweak the xorg.conf settings, but reading the conf.xorg documentation I couldn't find anything relevant. In some other post I also read about using udev, but again... I failed to find a clear how-to on how to achieve this.


Source: (StackOverflow)

systemd-udevd[381]: failed to execute '/lib/udev/socket:@/org/fre edesktop/hal/udev_event'

After upgrading to ubuntu 14.04 I see this in dmesg

[    1.538887] systemd-udevd[105]: starting version 204
[   19.074098] systemd-udevd[310]: starting version 204
[   19.271342] systemd-udevd[381]: failed to execute '/lib/udev/socket:@/org/freedesktop/hal/udev_event' 'socket:@/org/freedesktop/hal/udev_event': No such file or directory
[   19.279385] systemd-udevd[395]: failed to execute '/lib/udev/socket:@/org/freedesktop/hal/udev_event' 'socket:@/org/freedesktop/hal/udev_event': No such file or directory
[...]

How can one fix this?


Source: (StackOverflow)

Script in udev rule doesn’t run

I'm running Ubuntu 9.10 (Karmic Koala) on a laptop and would like NumLock to automatically toggle depending on whether my USB keyboard is plugged in (numlock on) or unplugged (numlock off).

To accomplish this, I first installed the "numlockx" package. numlockx on and numlockx off works fine.

To hook into the device system, I thought I'd use udev. I have read "Writing udev rules", but I'm having trouble getting the udev rule to work.

First, here's an example of the dmesg output:

[20906.985102] usb 3-2: new low speed USB device using uhci_hcd and address 6
[20907.166403] usb 3-2: configuration #1 chosen from 1 choice
[20907.192904] input: Microsoft Natural® Ergonomic Keyboard 4000 as /devices/pci0000:00/0000:00:1a.0/usb3/3-2/3-2:1.0/input/input20
[20907.193100] microsoft 0003:045E:00DB.000B: input,hidraw1: USB HID v1.11 Keyboard [Microsoft Natural® Ergonomic Keyboard 4000] on usb-0000:00:1a.0-2/input0
[20907.217810] input: Microsoft Natural® Ergonomic Keyboard 4000 as /devices/pci0000:00/0000:00:1a.0/usb3/3-2/3-2:1.1/input/input21
[20907.217979] microsoft 0003:045E:00DB.000C: input,hidraw2: USB HID v1.11 Device [Microsoft Natural® Ergonomic Keyboard 4000] on usb-0000:00:1a.0-2/input1

I used udevadm info to gather the device info:

> udevadm info -a -p /devices/pci0000:00/0000:00:1a.0/usb3/3-2/3-2:1.1/input/input21

  looking at device '/devices/pci0000:00/0000:00:1a.0/usb3/3-2/3-2:1.1/input/input21':
    KERNEL=="input21"
    SUBSYSTEM=="input"
    DRIVER==""
    ATTR{phys}=="usb-0000:00:1a.0-2/input1"
    ATTR{uniq}==""
    ATTR{modalias}=="input:b0003v045Ep00DBe0111-e0,1,2,3,4,14,k71,72,73,74,75,77,79,7A,7B,7C,7D,7E,7F,80,81,82,83,84,85,86,87,88,89,8A,8B,8C,8E,90,96,98,9B,9C,9E,9F,A1,A3,A4,A5,A6,A7,A8,A9,AB,AC,AD,AE,B0,B1,B2,B3,B4,B5,B6,B8,B9,BA,BB,BC,BD,BE,BF,C0,C1,C2,CE,CF,D0,D1,D2,D5,D9,DB,DF,E2,E7,E8,E9,EA,EB,F0,100,162,166,16A,16E,178,179,17A,17B,17C,17D,17F,180,181,182,185,18C,18D,192,193,195,1A0,1A1,1A2,1A3,1A4,1A5,1A6,1A7,1A8,1A9,1AA,1AB,1AC,1AD,1AE,1B0,1B1,1B7,r6,a20,m4,lsfw"

  looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb3/3-2/3-2:1.1':
    KERNELS=="3-2:1.1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usbhid"
    ATTRS{bInterfaceNumber}=="01"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bNumEndpoints}=="01"
    ATTRS{bInterfaceClass}=="03"
    ATTRS{bInterfaceSubClass}=="00"
    ATTRS{bInterfaceProtocol}=="00"
    ATTRS{modalias}=="usb:v045Ep00DBd0173dc00dsc00dp00ic03isc00ip00"
    ATTRS{supports_autosuspend}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb3/3-2':
    KERNELS=="3-2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 2"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="a0"
    ATTRS{bMaxPower}=="100mA"
    ATTRS{urbnum}=="532"
    ATTRS{idVendor}=="045e"
    ATTRS{idProduct}=="00db"
    ATTRS{bcdDevice}=="0173"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{speed}=="1.5"
    ATTRS{busnum}=="3"
    ATTRS{devnum}=="6"
    ATTRS{version}==" 2.00"
    ATTRS{maxchild}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="Microsoft"

  looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb3':
    KERNELS=="usb3"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bMaxPower}=="  0mA"
    ATTRS{urbnum}=="127"
    ATTRS{idVendor}=="1d6b"
    ATTRS{idProduct}=="0001"
    ATTRS{bcdDevice}=="0206"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{speed}=="12"
    ATTRS{busnum}=="3"
    ATTRS{devnum}=="1"
    ATTRS{version}==" 1.10"
    ATTRS{maxchild}=="2"
    ATTRS{quirks}=="0x0"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="Linux 2.6.31-16-generic uhci_hcd"
    ATTRS{product}=="UHCI Host Controller"
    ATTRS{serial}=="0000:00:1a.0"
    ATTRS{authorized_default}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:1a.0':
    KERNELS=="0000:00:1a.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="uhci_hcd"
    ATTRS{vendor}=="0x8086"
    ATTRS{device}=="0x2937"
    ATTRS{subsystem_vendor}=="0x1558"
    ATTRS{subsystem_device}=="0x0860"
    ATTRS{class}=="0x0c0300"
    ATTRS{irq}=="16"
    ATTRS{local_cpus}=="ff"
    ATTRS{local_cpulist}=="0-7"
    ATTRS{modalias}=="pci:v00008086d00002937sv00001558sd00000860bc0Csc03i00"
    ATTRS{broken_parity_status}=="0"
    ATTRS{msi_bus}==""

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

So I created a file called /etc/udev/rules.d/usb-keyboard.rules:

# Turn on NumLock when keyboard is plugged in.
ACTION=="add", ATTRS{manufacturer}=="Microsoft", SUBSYSTEM=="input", RUN+="/usr/bin/numlockx on"

# Turn off NumLock when keyboard is unplugged.
ACTION=="remove", ATTRS{manufacturer}=="Microsoft", SUBSYSTEM=="input", RUN+="/usr/bin/numlockx off"

I have used udevadm test to verify that the rules are correct:

> udevadm test --action=add /devices/pci0000:00/0000:00:1a.0/usb3/3-2/3-2:1.1/input/input21
run_command: calling: test
udevadm_test: version 147

[...]
parse_file: reading '/etc/udev/rules.d/usb-keyboard.rules' as rules file
udev_rules_new: rules use 180864 bytes tokens (15072 * 12 bytes), 31614 bytes buffer
udev_rules_new: temporary index used 49760 bytes (2488 * 20 bytes)
udev_device_new_from_syspath: device 0x28d7d80 has devpath '/devices/pci0000:00/0000:00:1a.0/usb3/3-2/3-2:1.1/input/input21'
udev_rules_apply_to_event: RUN '/sbin/modprobe -b $env{MODALIAS}' /lib/udev/rules.d/80-drivers.rules:5
udev_rules_apply_to_event: RUN 'socket:@/org/freedesktop/hal/udev_event' /lib/udev/rules.d/90-hal.rules:2
udev_device_new_from_syspath: device 0x28d8560 has devpath '/devices/pci0000:00/0000:00:1a.0/usb3/3-2/3-2:1.1'
udev_device_new_from_syspath: device 0x28d8708 has devpath '/devices/pci0000:00/0000:00:1a.0/usb3/3-2'
udev_rules_apply_to_event: RUN '/usr/bin/numlockx on' /etc/udev/rules.d/usb-keyboard.rules:7
udevadm_test: UDEV_LOG=6
udevadm_test: DEVPATH=/devices/pci0000:00/0000:00:1a.0/usb3/3-2/3-2:1.1/input/input21
udevadm_test: PRODUCT=3/45e/db/111
udevadm_test: NAME="Microsoft Natural® Ergonomic Keyboard 4000"
udevadm_test: PHYS="usb-0000:00:1a.0-2/input1"
udevadm_test: UNIQ=""
udevadm_test: EV==10001f
udevadm_test: KEY==837fff 2c3027 bf004444 0 0 1 10f84 8a27c007 ff7f7bfa d9415fff febeffdf ffefffff ffffffff fffffffe
udevadm_test: REL==40
udevadm_test: ABS==1 0
udevadm_test: MSC==10
udevadm_test: MODALIAS=input:b0003v045Ep00DBe0111-e0,1,2,3,4,14,k71,72,73,74,75,77,79,7A,7B,7C,7D,7E,7F,80,81,82,83,84,85,86,87,88,89,8A,8B,8C,8E,90,96,98,9B,9C,9E,9F,A1,A3,A4,A5,A6,A7,A8,A9,AB,AC,AD,AE,B0,B1,B2,B3,B4,B5,B6,B8,B9,BA,BB,BC,BD,BE,BF,C0,C1,C2,CE,CF,D0,D1,D2,D5,D9,DB,DF,E2,E7,E8,E9,EA,EB,F0,100,162,166,16A,16E,178,179,17A,17B,17C,17D,17F,180,181,182,185,18C,18D,192,193,195,1A0,1A1,1A2,1A3,1A4,1A5,1A6,1A7,1A8,1A9,1AA,1AB,1AC,1AD,1AE,1B0,1B1,1B7,r6,a20,m4,lsfw
udevadm_test: ACTION=add
udevadm_test: SUBSYSTEM=input
udevadm_test: run: '/sbin/modprobe -b input:b0003v045Ep00DBe0111-e0,1,2,3,4,14,k71,72,73,74,75,77,79,7A,7B,7C,7D,7E,7F,80,81,82,83,84,85,86,87,88,89,8A,8B,8C,8E,90,96,98,9B,9C,9E,9F,A1,A3,A4,A5,A6,A7,A8,A9,AB,AC,AD,AE,B0,B1,B2,B3,B4,B5,B6,B8,B9,BA,BB,BC,BD,BE,BF,C0,C1,C2,CE,CF,D0,D1,D2,D5,D9,DB,DF,E2,E7,E8,E9,EA,EB,F0,100,162,166,16A,16E,178,179,17A,17B,17C,17D,17F,180,181,182,185,18C,18D,192,193,195,1A0,1A1,1A2,1A3,1A4,1A5,1A6,1A7,1A8,1A9,1AA,1AB,1AC,1AD,1AE,1B0,1B1,1B7,r6,a20,m4,lsfw'
udevadm_test: run: 'socket:@/org/freedesktop/hal/udev_event'
udevadm_test: run: '/usr/bin/numlockx on'

And here's the "remove" test:

> udevadm test --action=remove /devices/pci0000:00/0000:00:1a.0/usb3/3-2/3-2:1.1/input/input21

run_command: calling: test
udevadm_test: version 147

[...]
parse_file: reading '/etc/udev/rules.d/usb-keyboard.rules' as rules file
udev_rules_new: rules use 180864 bytes tokens (15072 * 12 bytes), 31614 bytes buffer
udev_rules_new: temporary index used 49760 bytes (2488 * 20 bytes)
udev_device_new_from_syspath: device 0xd2fd80 has devpath '/devices/pci0000:00/0000:00:1a.0/usb3/3-2/3-2:1.1/input/input21'
udev_rules_apply_to_event: RUN 'socket:@/org/freedesktop/hal/udev_event' /lib/udev/rules.d/90-hal.rules:2
udev_device_new_from_syspath: device 0xd2fff8 has devpath '/devices/pci0000:00/0000:00:1a.0/usb3/3-2/3-2:1.1'
udev_device_new_from_syspath: device 0xd30690 has devpath '/devices/pci0000:00/0000:00:1a.0/usb3/3-2'
udev_rules_apply_to_event: RUN '/usr/bin/numlockx off' /etc/udev/rules.d/usb-keyboard.rules:10
udevadm_test: UDEV_LOG=6
udevadm_test: DEVPATH=/devices/pci0000:00/0000:00:1a.0/usb3/3-2/3-2:1.1/input/input21
udevadm_test: PRODUCT=3/45e/db/111
udevadm_test: NAME="Microsoft Natural® Ergonomic Keyboard 4000"
udevadm_test: PHYS="usb-0000:00:1a.0-2/input1"
udevadm_test: UNIQ=""
udevadm_test: EV==10001f
udevadm_test: KEY==837fff 2c3027 bf004444 0 0 1 10f84 8a27c007 ff7f7bfa d9415fff febeffdf ffefffff ffffffff fffffffe
udevadm_test: REL==40
udevadm_test: ABS==1 0
udevadm_test: MSC==10
udevadm_test: MODALIAS=input:b0003v045Ep00DBe0111-e0,1,2,3,4,14,k71,72,73,74,75,77,79,7A,7B,7C,7D,7E,7F,80,81,82,83,84,85,86,87,88,89,8A,8B,8C,8E,90,96,98,9B,9C,9E,9F,A1,A3,A4,A5,A6,A7,A8,A9,AB,AC,AD,AE,B0,B1,B2,B3,B4,B5,B6,B8,B9,BA,BB,BC,BD,BE,BF,C0,C1,C2,CE,CF,D0,D1,D2,D5,D9,DB,DF,E2,E7,E8,E9,EA,EB,F0,100,162,166,16A,16E,178,179,17A,17B,17C,17D,17F,180,181,182,185,18C,18D,192,193,195,1A0,1A1,1A2,1A3,1A4,1A5,1A6,1A7,1A8,1A9,1AA,1AB,1AC,1AD,1AE,1B0,1B1,1B7,r6,a20,m4,lsfw
udevadm_test: ACTION=remove
udevadm_test: SUBSYSTEM=input
udevadm_test: run: 'socket:@/org/freedesktop/hal/udev_event'
udevadm_test: run: '/usr/bin/numlockx off'

The problem is that when the keyboard is plugged in or unplugged, the NumLock status doesn't change. I have tried restarting the udev service, with no luck. Are my udev rules wrong? Am I going about this the wrong way?


Source: (StackOverflow)

Why is Google Chrome not starting after replacing udev with systemd-tools?

I recently updated my system via sudo pacman -Syu. Afterwards, I proceeded to open Google Chrome, but it failed. When I tried to start it via the terminal I got the error.

/usr/bin/google-chrome: error while loading shared libraries: libudev.so.0: cannot open shared object file: No such file or directory

What is going on?


Source: (StackOverflow)

Where can I find the command "udevinfo" on Debian?

I'm trying to fix a problem with my webcam in Wheezy, and I need some information about the drive with the command udevinfo. The problem is: where is this executable?

if I run sudo udevinfo the result is:

udevinfo: command not found

Any suggestion?


Source: (StackOverflow)

Use UUID in udev rules and mount usb drive on /media/$UUID

I want to mount the usb drive in /media based on the UUID of the disk. How can I use the UUID of a usb drive in a udev rules file and what is a udev rule to mount the usb drive with the UUID number as the folder name.

The blkid command outputs the UUID of a disk but only upon mounting.


Source: (StackOverflow)

udev rules ignore_device

I'm on Fedora 18. In /etc/udev/rules.d, I've added new rule (70-stm32.rules) with following content:

SUBSYSTEM=="block", ENV{ID_MODEL}=="STM32_STLink", OPTIONS=="ignore_device"

Then restarted udev:

systemctl restart systemd-udevd.service

But device still seem to be recognized and mounted as USB drive.

Where is my mistake?

I want to ignore following device

udevadm info /dev/sdb
P: /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.0/host8/target8:0:0/8:0:0:0/block/sdb
N: sdb
S: disk/by-id/usb-STM32_STM32_STLink-0:0
S: disk/by-path/pci-0000:00:14.0-usb-0:3:1.0-scsi-0:0:0:0
S: disk/by-uuid/A8D9-2F05
E: DEVLINKS=/dev/disk/by-id/usb-STM32_STM32_STLink-0:0 /dev/disk/by-path/pci-0000:00:14.0-usb-0:3:1.0-scsi-0:0:0:0 /dev/disk/by-uuid/A8D9-2F05
E: DEVNAME=/dev/sdb
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.0/host8/target8:0:0/8:0:0:0/block/sdb
E: DEVTYPE=disk
E: ID_BUS=usb
E: ID_FS_TYPE=vfat
E: ID_FS_USAGE=filesystem
E: ID_FS_UUID=A8D9-2F05
E: ID_FS_UUID_ENC=A8D9-2F05
E: ID_FS_VERSION=FAT16
E: ID_INSTANCE=0:0
E: ID_MODEL=STM32_STLink
E: ID_MODEL_ENC=STM32\x20STLink
E: ID_MODEL_ID=3744
E: ID_PATH=pci-0000:00:14.0-usb-0:3:1.0-scsi-0:0:0:0
E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_3_1_0-scsi-0_0_0_0
E: ID_REVISION=0100
E: ID_SERIAL=STM32_STM32_STLink-0:0
E: ID_TYPE=disk
E: ID_USB_DRIVER=usb-storage
E: ID_USB_INTERFACES=:080650:
E: ID_USB_INTERFACE_NUM=00
E: ID_VENDOR=STM32
E: ID_VENDOR_ENC=STM32\x20\x20\x20
E: ID_VENDOR_ID=0483
E: MAJOR=8
E: MINOR=16
E: MPATH_SBIN_PATH=/sbin
E: SUBSYSTEM=block
E: TAGS=:systemd:
E: USEC_INITIALIZED=33484404

Source: (StackOverflow)

How to rescan and remount drives on Ubuntu Hardy or Jaunty?

When I connect an USB drive to an Ununtu Hardy and Jaunty system, the system mounts the partitions found on the drive, and opens a Nautilus window for each mounted partitions. Within Nautilus, I am able to unmount partitions.

What I need is a command or action which forces the system to rescan the available drives and partitions, and automount each not mounted partition, including those which I've manually unmounted from Nautilus. sudo /etc/init.d/udev restart or ... reload doesn't do this.

As of now, I just unplug the USB drive, and commect it again, which will force a scan and a mount on that drive. But I want to do force the rescan and remount without unplugging anything, preferably without the user having the know device or drive names.


Source: (StackOverflow)

udev: waiting for uevents to be processed on my Gentoo

During the startup I see machine executing this thing for about 30 seconds:

udev: waiting for uevents to be processed

Then I get a quick message which says something like:

devfs: timeout (50 seconds)

I can't see the whole thing because after that system starts up very fast including Xfce.

What logs and configs do I need to provide for further investigation?

$uname -a

Linux genta 3.6.6-gentoo #1 SMP Sun Nov 11 11:02:23 NOVT 2012 i686 Genuine Intel(R) CPU T2300 @ 1.66GHz GenuineIntel GNU/Linux

Thank you!

UPD: rc-status

genta / # rc-status sysinit
Runlevel: sysinit
 dmesg                                                             [  started  ]
 udev                                                              [  started  ]
 devfs                                                             [  started  ]
genta / # rc-status boot
Runlevel: boot
 hwclock                                                           [  started  ]
 modules                                                           [  started  ]
 fsck                                                              [  started  ]
 root                                                              [  started  ]
 mtab                                                              [  started  ]
 localmount                                                        [  started  ]
 sysctl                                                            [  started  ]
 bootmisc                                                          [  started  ]
 hostname                                                          [  started  ]
 termencoding                                                      [  started  ]
 keymaps                                                           [  started  ]
 net.lo                                                            [  started  ]
 swap                                                              [  started  ]
 urandom                                                           [  started  ]
 procfs                                                            [  started  ]

UPD 2: kernel-config

genta / # cat /etc/kernels/kernel-config-x86_64-3.6.6-gentoo | grep 'DEVTMPFS\|UEVENT'
CONFIG_UEVENT_HELPER_PATH="/usr/bin/udevadm"
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y

Source: (StackOverflow)