Linux HOWTOs

About | Home | Search


HOWTO: udev
Description: Allows users to have a dynamic /dev directory, persistent device names
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# udev 100
# ========
# Slackware 10.0's 'udev' package includes version 026, 10.1's includes 050,
# and 10.2's includes 064
#
# -=> !! READ THIS !! <=-
# You may want to stick with the package that comes with Slackware because
# of all of the dependencies and inter-operation between other things.
# If you break /dev, you break Linux's ability to talk to devices - like
# your hard drive and such.  Keep a boot-floppy/CD handy.
#
# If you choose to go with the Slackware package instead, here it is:
# current
# 10.2
# 10.1
# You should check 'patches' (10.1, 10.2) to make sure there isn't an updated version
# there.

# Before installing a new version of udev, you may want to remove the old
# version by running 'make uninstall' as root from the source directory. 
# This will ensure that old files are not left behind that are not used by
# the current version.  Make sure you back up your files first though, at
# least /etc/udev.

# Prerequisites:
# Linux kernel >= 2.6.15 with sysfs (CONFIG_SYSFS) and unix domain socket
# Linux kernel >= 2.6.15 with sysfs (CONFIG_SYSFS), unix domain socket
#  (CONFIG_UNIX), and networking (CONFIG_NET) enabled
# proc filesystem mounted on /proc
# sysfs filesystem mounted on /sys

cd
test -f installed/udev-100.tar.bz2 && mv installed/udev-100.tar.bz2 .
test ! -f udev-100.tar.bz2 &&
 wget http://www.us.kernel.org/pub/linux/utils/kernel/hotplug/\
udev-100.tar.bz2

# Verify tarball w/ md5sum:
# (this came from my gpg-verified tarball)
echo "f1f7e7d8f9a438b7a63d0d6443961d1c  udev-100.tar.bz2" | md5sum -c

# Verify tarball w/ sha1sum:
# (this also came from my gpg-verified tarball)
echo "9c7cdca01db5e842761b2578fc59ab86b8609bb0  udev-100.tar.bz2" | \
 sha1sum -c

# Verify tarball w/ gpg:
( gpg --list-keys 517D0F0E > /dev/null 2>&1 || gpg --recv-keys 517D0F0E ) &&
 wget -nc http://www.us.kernel.org/pub/linux/utils/kernel/hotplug/\
udev-100.tar.bz2.sign &&
  gpg --verify udev-100.tar.bz2.sign && rm udev-100.tar.bz2.sign

mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "udev-*" -exec rm -r {} \;
tar xjvf ~/udev-100.tar.bz2
cd udev-100
test $UID = 0 && chown -R root:root .
make \
 USE_LOG=true \
 EXTRAS="extras/ata_id extras/cdrom_id extras/dasd_id extras/edd_id \
         extras/firmware extras/floppy extras/path_id extras/scsi_id \
         extras/usb_id extras/volume_id"

# Read every udev-related document you can find before you attempt to have
# udev actually running and managing /dev.  You may need to change things
# in /etc/udev/rules.d to get the appropriate symlinks and permissions set
# for when you reboot.  I created a /etc/udev/rules.d/10-local.rules for my
# non-default settings.
#
# Here are some things you may want to read:
# less ~/src/udev-100/README
# less ~/src/udev-100/RELEASE-NOTES
# less ~/src/udev-100/FAQ
# man udev
# man udevd
# http://www.us.kernel.org/pub/linux/utils/kernel/hotplug/udev.html
# http://en.wikipedia.org/wiki/Udev
# http://www.reactivated.net/writing_udev_rules.html
# http://webpages.charter.net/decibelshelp/LinuxHelp_UDEVPrimer.html
# http://fedora.redhat.com/docs/udev/
# http://www.gentoo.org/doc/en/udev-guide.xml

# Become root to install it
su

# The best mailing list to read for info about udev is the
# linux-hotplug-devel list:
# https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
# Back up udev files (not including binaries, man pages, etc.), if there are
# any:
test -d /etc/udev &&
 ( mkdir -p -m 0700 ~/backup
   tar cjvf ~/backup/udev-`date +%Y%m%d`.tar.bz2 /etc/rc.d/rc.udev \
    /etc/udev )

# Remove the Slackware package
test -x /sbin/removepkg && /sbin/removepkg udev

# If you already have a /etc/udev/udev.conf, 'make install' will not
# overwrite it.  You may want to check it out (less etc/udev/udev.conf)
# or even install it in place of your old one.  If you want to test udev
# with a different root (instead of /dev) specify udev_root in udev.conf
test -f /etc/udev/udev.conf &&
 mv -f /etc/udev/udev.conf /etc/udev/udev.conf.old
/usr/bin/install -c -m 644 etc/udev/udev.conf /etc/udev/

# If you already have a /etc/udev/rules.d/50-udev.rules, 'make install'
# will not overwrite it either.  You may want to check out the sample ones
# under etc/udev/ like etc/udev/slackware/udev.rules  If you want to install
# it over your old one, run this.
#
# Open it up in a text editor and change DRIVER to DRIVERS on line 48 to
# shut up the error that you may get in syslog.
test -f /etc/udev/rules.d/50-udev.rules &&
 mv -f /etc/udev/rules.d/50-udev.rules /etc/udev/rules.d/50-udev.rules.old
/usr/bin/install -c -m 644 etc/udev/slackware/udev.rules \
 /etc/udev/rules.d/50-udev.rules

# Grab a /lib/udev helper scripts from "slackware-current".  These are
# called out of 50-udev.rules via RUN, IMPORT{program}, PROGRAM, etc.:
for script in cdrom-symlinks.sh floppy-extra-devs.sh input-device.sh \
 modalias_ieee1394 nethelper.sh; do
  wget -N ftp://ftp.slackware.com/pub/slackware/slackware-current/source/\
a/udev/config/scripts/${script} -O /lib/udev/${script}
  test -s /lib/udev/${script} && chmod 755 /lib/udev/${script}
done

# The /lib/udev/devices directory is where you should put nodes and
# symlinks that must be in /dev when udev is initialized
( cd /lib/udev/devices
  test ! -c ./null && mknod -m 666 ./null c 1 3
  test ! -c ./zero && mknod -m 666 ./zero c 1 5 )

# WARNING: this will not only install it, but kill a running udevd
# and (re-)start it
make install \
 EXTRAS="extras/ata_id extras/cdrom_id extras/dasd_id extras/edd_id \
         extras/firmware extras/floppy extras/path_id extras/scsi_id \
         extras/usb_id extras/volume_id"

# udev looks for /lib/udev/firmware_helper, not firmware.sh
ln -s /lib/udev/firmware.sh /lib/udev/firmware_helper

# If you have a /etc/udev/permissions.d left over from an old version of
# udev, you can remove that.  You can specify owner and group in udev's
# rules file(s).
test -d /etc/udev/permissions.d && rm -r /etc/udev/permissions.d

# This binary and symlink are no longer necessary as of 047:
rm -f /sbin/wait_for_sysfs
test -L /etc/hotplug.d/default/05-wait_for_sysfs.hotplug &&
 rm /etc/hotplug.d/default/05-wait_for_sysfs.hotplug

# Use of /etc/dev.d is no longer recommended
test -d /etc/dev.d && rm -r /etc/dev.d

# This part is for installing an init script to start udev on boot-up.
#
# In Slackware 10.0, the script that starts-up /etc/rc.d/rc.udev on boot-up
# is /etc/rc.d/rc.S  I opened up mine and moved the part that starts udev to
# just after the "Check root filesystem" part.  If you don't do that, you'll
# see complaints on boot-up about rc.udev trying to create symlinks to
# a few things in /proc, but since the root filesystem is mounted read-only
# at that point, it'll fail.  If you move it below the part that re-mounts
# it read-write, then that won't be a problem any more.
#
( cd /etc/rc.d
  test -f rc.udev &&
   ( mv -f rc.udev rc.udev.old
     chmod 600 rc.udev.old )
  wget http://englanders.cc/pub/linux/misc/rc.udev
  chmod 700 ./rc.udev )

# Make sure everything in the source directory is owned by your
# non-root user can remove the source directory later
chown -R $USER .

# Become yourself again
exit

cd
mkdir -p -m 0700 installed
rm -f installed/udev-*.tar.*
mv udev-100.tar.bz2 installed/

Back to the list


Last updated: Wed, 29 Apr 2020 22:04:50 -0400
Jason Englander <jason at englanders dot us>