Udev changes (was Re: ALSA modules and restore volumes)

Duncan Webb duncan-lfs at linuxowl.com
Thu Oct 27 01:08:51 PDT 2005


Matthew Burgess wrote:

> Forwarding from blfs-dev, where an ALSA related thread went just a 
> little off-topic for BLFS :)
>
> Thanks Alexander, I'll try to get these changes in a.s.a.p.
>
> Matthew Burgess wrote:
>
>> I'll have to bite the bullet and see to getting all the module 
>> hotplugging related bugs sorted out
>
>
> This means just the following steps:
>
> 1) Upgrade udev to 071 to resolve the udev_run_hotplugd installation bug
>
> 2) Add these two rules to LFS default rules file:
>
> ENV{UDEVD_EVENT}=="1", RUN+="/sbin/udev_run_hotplugd"
> RUN+="/sbin/udev_run_devd"

Don't think that RUN+="/sbin/udev_run_devd" is requires for LFS as it 
doesn't use devfs any more.

>
> 3) Change instructions to:
>
> make EXTRAS=extras/run_directory/
> make EXTRAS=extras/run_directory/ install
> cp ../udev-config-5.rules /etc/udev/rules.d/25-lfs.rules
> install -m644 -D docs/writing_udev_rules/index.html \
>         /usr/share/doc/udev-071/index.html
>
> After that ends up in the book, we can try eliminating the hotplug
> package gradually. E.g., for a start, build the firmware helper in
> EXTRAS and use it instead of hotplug's firmware.agent.
>
> Some cleanup of the current rules file is also needed. E.g., I would
> change the following rules:
>
> KERNEL=="dm-*", GROUP="disk",   MODE="0640"
> KERNEL=="card*", NAME="dri/card%n", GROUP="video"
>
> to
>
> KERNEL=="dm-*", NAME=""
> KERNEL=="card*", NAME=""
>
> in order for udev to completely ignore the corresponding devices. 
> Rationale:
>
> dm: /dev/dm-* is not the proper name for such devices. Both "dmsetup"
> and lvm2-related programs make the corresponding devices automatically
> and with proper names, without udev and associated races.
>
> card*: the X server makes those devices anyway without any help from
> udev. I don't want udev to step on its back (aka race with permissions)
> and recreate the devices.

I think that you can also add:
Add the rules to /etc/udev/rules.d/60-hotplug.rules
#
# usbfs-like device nodes
SUBSYSTEM="usb_device", PROGRAM="/bin/sh -c 'X=%k X=$${X#usbdev} 
B=$${X%%%%.*} D=$${X#*.}; echo bus/usb/$$B/$$D'", SYMLINK+="%c"
 
# be backward compatible for a while with the /etc/dev.d and 
/etc/hotplug.d/ systems
# run /etc/hotplug.d/ stuff only if we came from a hotplug event, not 
for udevstart
ENV{UDEVD_EVENT}=="1", RUN+="/sbin/udev_run_hotplugd"

I'm not 100% sure but I think that pciutils (plus 
pcimodules-pciutils-2.1.11.diff patch) and usbutils are also needed.
Build usbutils with:
./configure \
  --prefix=/usr \
  --sysconfdir=/etc \ #may not re required
  --datadir=/usr/share \
  --enable-usbmodules

To log hotplug events you could also add:
in /etc/hotplug/hotplug.functions change the lines:
if [ -t 1 or -z "$LOGGER" ]; then
to
if [ -z "$LOGGER" ]; then
 
and
$LOGGER -t $(basename $0)"[$$]" "$@"
to
$LOGGER -p local1.info -t $(basename $0)"[$$]" "$@"
 
Add to /etc/syslog.conf
local1.* -/var/log/hotplug.log
or
local1.* -/var/log/hotplug/messages.log
The syslog needs to be started after mounting the file systems rw and 
before hotplugging.

Works for me.
Duncan

BTW Acpid is also quite useful for laptops and powering down by a quick 
press of the power button.




More information about the lfs-dev mailing list