Hot answers tagged udev
8
Udev uses the inotify mechanism to watch for changes in the rules directory, in both the library and in the local configuration trees (typically located at /lib/udev/rules.d and /etc/udev/rules.d). So you don't need to do anything when you change a rules file.
You only need to notify the udev daemon explicitly if you're doing something unusual, for example ...
6
One possibility is to add your own udev rule for this partition, that overrides the default ones. On Ubuntu 10.04 /lib/udev/rules.d/80-udisks.rules has some default rules that make udisks ignore some partitions (e.g. partitions that are known to be rescue partitions etc.) which might be an inspiration...
On Ubuntu 10.04 your own rules should go into ...
6
Responding to the "[a] way to tell that a monitor has been plugged in" part of the question:
The support still varies quite a bit, but with recent kernels there is some support for generating udev events when a display hotplug occurs. With kernel 2.6.38 and ATI X1400 hardware, I get an event the first time I connect a VGA display but no events on subsequent ...
6
For the first part of the question, I've looked and couldn't find a better way to detach a USB driver than what you're already doing with libusb.
As for the second part of the question, udev can react to driver loading, but not force a specific driver to be assigned to a device.
Every driver in the Linux kernel is responsible for one or more devices. The ...
6
Firstly, make sure that dbus and consolekit are running -- usually this means prepending ck-launch-session dbus-launch to your exec statement.
You will also want to check that your user is in the storage group (you can check with groups). Most distributions ship with the storage group's policies configured on install, but in case they aren't, you may want ...
6
The walk is over the different software components (drivers) that handle the device; this corresponds by and large to the hardware devices and buses that are involved in connecting to the device. This is mostly unrelated to the physical arrangement of the devices: most of them are inside the same chip anyway.
Taking this example from the top:
First we ...
5
This is Linux specific:
A hotplug event handler will register with the kernel to receive hotplug events either over a netlink socket or by echoing its path to /proc/sys/kernel/hotplug. It will then receive information over the socket (netlink) or via being launched with environment variables (/proc.../hotplug).
Usually, udev is this handler. When udev gets ...
5
Put a line like this in a file in /etc/udev/rules.d:
KERNEL=="sd*", ATTRS{vendor}=="Yoyodyne", ATTRS{model}=="XYZ42", ATTRS{serial}=="123465789", RUN+="/pathto/script"
Add a clause like NAME="subdir/mydisk%n" if you want to use a custom entry path under /dev.
Run udevadm -a -n sdb to see what attributes you can match against (attribute=="value").
5
udev outputs logging information to /var/log/messages, but by default it only logs errors, and it happens you've constructed a command that doesn't do what you want, but also doesn't error out. The >> redirection is handled by your shell, and udev doesn't run the command through a shell, so it's literally running the binary /bin/echo and passing it the ...
5
Yes, by changing to a different syslog channel, provided you understand how syslog works:
From udev manual:
udev_log
The logging priority which can be set to err ,info or the corre-
sponding numerical syslog(3) value. The default value is err.
So now you could edit /etc/udev/udev.conf and change this value.
5
On CentOS, I don't get udev messages when I plug in a simple USB thumbstick. Instead I get:
[sdb] Assuming drive cache: write through
a couple of times.
But this isn't udev, or syslog mentioning this to you on the console. You could know this for sure yourself, by killing syslogd or rsyslogd (Please make sure this isn't a production server, which I hope ...
4
I'm using this simple (homemade) script that keeps polling RandR and switches between LVDS1 and VGA1 when VGA gets connected/disconnected.
It's a dirty solution, yet it's working just fine.
It's customized for my setup: you'll most likely need to change RandR output names (LVDS1 and VGA1) and unlike me you'll probably be fine with your RandR default mode ...
4
Regarding a tool which can store monitor configuration profiles on a per-user and per-display basis, autorandr will do exactly that. https://github.com/wertarbyte/autorandr.
My laptop has an NVIDIA card, so I use the disper backend instead of xrandr: http://willem.engen.nl/projects/disper/. Autorandr will use disper as the backend to manage your monitors if ...
4
With the help of the guys who commented on my question, I figured out what was wrong and fixed it in the script.
Here now the updated routines how to get automatic screen switching with your laptop to work. You need acpid, kms and udev.
Create the following rules for acpi and udev
/etc/acpi/events/lidclose
# Pass all events to our one handler script
...
4
From systemd v197 predictable network names were introduced.
With systemd 197 we have added native support for a number of different naming policies into systemd/udevd proper and made a scheme similar to biosdevname's (but generally more powerful, and closer to kernel-internal device identification schemes) the default.1
You can use ip link to show all ...
4
'live' watching can be done via udevadm:
udevadm monitor --subsystem-match=usb --property
or
udevadm monitor --subsystem-match=usb --property --udev
to filter only udev events. If you want to grep for a particular property you will have to un-buffer udevadm output (with tools like stdbuf, script, unbuffer...):
stdbuf -i 0 -o 0 -e 0 udevadm monitor ...
3
Unless the device itself has a means of authentication (a fingerprint reader?), you can't know who plugged it in.
What you can do, and which may or may not suit your purposes, is to determine who is logged in on the console. This requires specific OS support, and there could be no user logged in on the console, or several, or there could be a single user ...
3
xrandr is executed, but fails. You should read its error messages, they would tell you what's wrong. You could just put all the output from your script in the log file, by adding this line just after the #! line:
exec >/home/hoppe/udev.out 2>&1
You'll find that the message is:
Can't open display
Like any other X program, xrandr talks to the ...
3
I would start by looking at hwinfo:
$ hwinfo --monitor
51: None 00.0: 10000 Monitor
[Created at fb.71]
Unique ID: rdCR.EY_qmtb9YY0
Hardware Class: monitor
Model: "Generic Monitor"
Vendor: "Generic"
Device: "Monitor"
Resolution: 1920x1200@77Hz
Driver Info #0:
Max. Resolution: 1920x1200
Vert. Sync ...
3
Any device nodes you create in /lib/udev/devices will be copied into /dev/ at system start:
DESCRIPTION
udevd listens to kernel uevents. For every event, udevd
executes matching instructions specified in udev rules. See
udev(7).
On startup the content of the directory /lib/udev/devices is
copied to /dev. If kernel modules specify static ...
3
This is all feasible with udev. Have a look at UAM, which seems to address most of the issues you've mentioned, but actually does mount automatically. If you like, you could make use of the great capabilities it provides, but modify it so that the media are not mounted automatically. You could also contact the author and suggest your non-automatic mounting ...
3
I used the udev rule suggested above along with a shell script that looks like
#!/bin/sh
dmode="$(cat /sys/class/drm/card0-VGA-1/status)"
export DISPLAY=:0
export XAUTHORITY=/home/yourusername/.Xauthority ...
3
Automounting in a Fedora installation with Gnome as the desktop environment is done by nautilus. You can turn this feature on / off by tweaking the key /apps/nautilus/preferences/media_automount in gconf-editor. However, I don't think it is configurable. In the olden times, this was done by gnome-volume-manager which called gnome-mount. There you could tweak ...
3
I've seen that flawed method around the webs and it's too generic in scope, as previous answer mentioned. It's also not dynamic enough, what if multiple USB devices were plugged in? This problem is common and solutions are around. You did not mention your distro, so I can't tell you which scripts are available packaged. I will mention them anyway, as ...
3
Mailing list archives:
http://www.spinics.net/lists/hotplug/
Git repository:
http://git.kernel.org/?p=linux/hotplug/udev.git;a=summary
Documentation:
http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev/
It's also in the source.
3
You can change logging priority to "info" level or even "debug" by:
udevadm control --log-priority=info
Then you will see all logs in your system log.
When you are done, bring it to default "err". See in /etc/udev/udev.conf what is your default logging level.
3
If you loosen the requirement for using ttyUSB0 - ttyUSB31, then you may just have a possibility. What I've done is let udev create symlinks to the device nodes assigned by the kernel. You cannot reliably hardwire a physical device to use ttyUSB0, you can however reliably add a symlink ttyUSB001 to point to whichever device node you want. The trick here is ...
2
I am not aware of such a tool and I guess that not a lot of hardware support the generation of such events (an Intel related discussion).
And polling would not be a very elegant solution - would waste CPU cycles and energy.
2
If you know the device node of the specific device (e.g. /dev/sdb), you can look it up with the following command:
udevadm info -a -p $(udevadm info -q path -n /dev/sdb)
Usually, if you're trying to create a custom rule in /etc/udev/rules.d/51-android.rules for android devices, writing lsusb in your terminal will display something like Bus 002 Device 004: ...
2
I recompiled the kernel making sure that neither of CONFIG_SYSFS_DEPRECATED nor CONFIG_SYSFS_DEPRECATED_V2 were set.
However, after a few retries with CONFIG_IDE not set (and a kernel which failed to find any harddrives), it turned out I had to CONFIG_IDE set as well as some more kernel config options found 'under' the deprecated ATA/ATAPI support. Again, ...
Only top voted, non community-wiki answers of a minimum length are eligible