Join Us | Contact | Feedback

Udev on EzPlanet One

small logo

 

This document tries to reveal the secrets of udev and how it works on EzPlanet One.

Udev

udev was developed by Greg Kroah-Hartman <greg@kroah.com> with much help from Dan Stekloff <dsteklof@us.ibm.com>, Kay Sievers <kay.sievers@vrfy.org>, and many others.

The udev homepage and the Linux-hotplug-devel mailing list https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel are the main development sources.

What does Udev do?

udev provides a dynamic device directory containing only the files for actually present devices. It creates or removes device node files usually located in the /dev directory, or it renames network interfaces.

As part of the hotplug subsystem, udev is executed if a kernel device is added or removed from the system. On device creation, udev reads the sysfs directory of the given device to collect device attributes like label, serial number or bus device number. These attributes may be used as keys to determine a unique name for the device. udev maintains a database for devices present on the system. On device removal, udev queries its database for the name of the device file to be deleted.

udev gets called by hotplug, if a module is loaded, and a device is added or removed. udev looks in /sys, if the driver provides a "dev" file, which contains the major and minor number for a device node to communicate with the driver. After looking in the udev rules (/etc/udev/rules.d), which specify the device node filename and symlinks, a device node is created in /dev with the permissions, which are specified in /etc/udev/permissions.d.

After device node creation, removal, or network device renaming, udev executes the programs in the directory tree under /etc/dev.d/. The name of a program must end with .dev suffix, to be recognized. In addition to the hotplug environment variables, DEVNAME is exported to make the name of the created node, or the name the network device is renamed to, available to the executed program. The programs in every directory are sorted in lexical order, while the directories are searched in the following order:

  • /etc/dev.d/$(DEVNAME)/*.dev
  • /etc/dev.d/$(SUBSYSTEM)/*.dev
  • /etc/dev.d/default/*.dev

How is Udev integrated on EzPlanet One?

initrd / initfs

mkinitrd copies /sbin/udev.static to the initrd /sbin/udev and symlinks it to /sbin/udevstart.

After the kernel boots, it executes the nash script of the initrd. This mounts a tmpfs filesystem on /dev. Instead of hotplug /sbin/udev is called in the initrd phase. udevstart creates all device nodes for the devices, which are compiled in the kernel and for the modules, which are loaded by nash.

Problems

The whole udev and hotplug infrastructure is not available in initrd. Thus no hotplug scripts, udev rules and permissions and no /etc/dev.d scripts are executed for any hotplug event, which is sent from the kernel.

rc.sysinit

First, if selinux is loaded and enabled, the context of /dev is set. rc.sysinit calls /sbin/start_udev. start_udev mounts a tmpfs filesystem on /dev, if there is none already mounted. Then it creates some device nodes, which need module autoloading, or where there is no kernel module. After that /sbin/udevstart is called again, which simulates the hotplug events in the initrd phase, to apply the whole udev rules and permissions. After that rc.sysinit parses the ouput of /sbin/kmodule and loads every module. This should provide device nodes for all hardware found on your computer.

console user permissions

/etc/dev.d/default/pam_console.dev is called whenever a device node is created and calls /sbin/pam_console_setowner with the filename (and an optional symlink) of the device node. This sets the permissions for console users like specified in /etc/security/console.perms.

Customizing Udev on EzPlanetOne

Read the manpage of udev and udevinfo. Please try not to modify the files of rpm packages.

New rules

New rules should be placed in a file, which ends in ".rules" in /etc/udev/rules.d. Please do not use 50-udev.rules. The supported and preferred way is to create rules without the "NAME" tag, and only create "SYMLINK"s.

A nice document describing, how to write rules can be found on http://www.reactivated.net/udevrules.php.

Permissions

New permissions should be placed in a file, which ends in ".permissions" in /etc/udev/permissions.d. Please do not use 50-udev.permissions.

But I really want my device node!

Put them in /etc/udev/devices/ and they will get copied to /dev.

Updating to udev without /dev

The steps to upgrade without anaconda or a rescue CD are (NOT recommended):

  • start from a kernel-2.6
  • make sure /sys is mounted
  • install the new initscripts
  • install the new udev
  • execute /sbin/start_udev
  • install the new mkinitrd
  • install a new kernel
  • or mkinitrd for your existing kernel(s)

Udev without initrd

Install EzPlanet One as usual and reboot.

		# mkdir /tmp/dev
		# mount --move /dev /tmp/dev
		# /sbin/MAKEDEV null console zero
		# mount --move /tmp/dev /dev
		

Install your kernel without an initrd. Reboot.

You will get some SELINUX errors and syslogd will not work as expected.

 

Nvidia

Quick solution: If you do not need rhgb, just load the nvidia module in /etc/rc.local

If you have udev >= 032-5, load the nvidia module;

		# cp -a /dev/nvidia* /etc/udev/devices
		# chown root.root /etc/udev/devices/nvidia*
	

Palm Pilot

If you have udev >= 032-5:

		# ln -s ttyUSB1 /etc/udev/devices/pilot
	

ISDN

If you have udev >= 032-5:

		# /sbin/MAKEDEV -d /etc/udev/devices isdn

About Us | Site Map | Privacy Policy | Contact Us | © 2004 EzPlanet