YOUR FEEDBACK
Rapid Module Development for DotNetNuke
MICHEAL SMITH wrote: GO TO THE LINK, U HAVE EVERYTHING U WANT THERE. MICHEAL...


2007 West
GOLD SPONSORS:
Active Endpoints
Your SOA Needs BPEL for Orchestration
BEA
Virtualized SOA: Adaptive Infrastructure for Demanding Applications
Nexaweb
Overcoming Bandwidth Challenges with Nexaweb
TIBCO
What is Service Virtualization?
SILVER SPONSORS:
WSO2
Using Web Services Technologies and FOSS Solutions
Click For 2007 East
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
TOP LINKS YOU MUST CLICK ON


Linux.SYS-CON.com: Device Management with udev and HAL on Fedora Core 4
Hotplugging everything on Fedora Core 4

Digg This!

Page 1 of 2   next page »

This article discusses the implementation details for the new device management methods udev and HAL, now used on all Fedora Core 3 and 4 systems for all devices. It's time to relearn how devices are managed!

On Fedora Core 4, device files are no longer handled in a static way. Instead they're now dynamically generated as needed by udev and managed by HAL (Hardware Abstraction Layer). Previously a device file was created for each possible device, leading to a very large number of device files in the /etc/dev directory. Now, your system will detect only those devices it uses and create device files for those only, giving you a much smaller listing of device files. Both udev and HAL are hotplug systems, with udev used for creating devices and HAL designed for providing information about them, as well as managing the configuration for removable devices such as those with file systems like USB card readers and CD-ROMs.

Managing devices is at the same time easier but much more complex. You have to use udev and HAL to configure devices, though much of this is now automatic. Device information is maintained in a special device file system called sysfs located at /sys. This is a virtual file system like /proc and is used to keep track of all devices supported by the kernel.

In this article, I'll cover the initial basics of udev and HAL configuration and device management. The goal is to give you a sense of how devices are now managed on Fedora Core 4 and where to go to find the rules that now determine how devices are created.

udev: Device Files
Devices are now treated as hotplugged, meaning they can be easily attached and removed. Their configuration is dynamically detected and does not rely on manual administrative settings. The hotplug tool used to detect device files is udev, user devices. Each time your system is booted, udev will automatically detect your devices and generate device files for them in the /etc/dev directory. This means that the /etc/dev directory and its files are re-created each time you boot. It is a dynamic directory, no longer static. udev uses a set of rules to direct how device files are to be generated, including any corresponding symbolic links. These are located in the /etc/udev/rules.d files. As part of the hotplug system, udev will automatically detect kernel devices that are added or removed from the system. When the device interface is first created, its corresponding sysfs file is located and read, determining any additional attributes such as serial numbers and device major and minor numbers that can be used to uniquely identify the device. These can be used as keys in udev rules to create the device interface. Once the device is created, it's listed in the udev database, which keeps track of currently installed devices.

As /etc/dev is now dynamic, any changes you would make manually to the /etc/dev directory will be lost when you reboot. This includes the creation of any symbolic links such as /dev/cdrom that many software applications use. Instead, such symbolic links have to be configured in udev rules files located in the /etc/udev/rules.d directory. Default rules are already in place for the commonly used symbolic links, but you can create rules to add your own.

udev rules
udev uses the udev rules.d files to dynamically create your device files. The rules files already present in the rules.d directory have been provided for your Fedora Core distribution and are designed specifically for it. You should never modify these rules. To customize your setup, create your own separate rules files in /etc/udev/rules.d. In your rules file you would normally define only symlinks, using SYMLINK fields alone, as described in the following sections. These set up symbolic links to devices, letting you access them with other device names. NAME fields are used to create the original device interface, a task usually left to udev.

Each line maps a device attribute to a device name, as well as specifying any symbolic names (links). Attributes are specified using keys, of which there may be more than one. If all the keys match a device, then the associated name is used for it and a device file of that name will be generated. Instead of listing a device name, a program or script may be specified instead to generate the name. This is often the case for CD-ROM devices, where the device name could be a cdrecorder, cdrom, or dvdrom.

The key fields, such as KERNEL, support pattern matching to specify collections of devices. These operate as standard filename expansion operations: *, ?, [ ]". For example, mouse* will match all devices beginning with the pattern "mouse". The following field uses the KERNEL key to match on all mouse devices as listed by the kernel:

KERNEL="mouse*"

The next key will match on all printer devices numbered lp0 through lp9. It uses brackets to specify a range of numbers or characters, in this case 0 through 9, [0-9]:

KERNEL="lp[0-9]*"

The NAME, SYMLINK, and PROGRAM fields support string substitution codes similar to the way printf codes work. Such a code is preceded by a % symbol. The code allows several possible devices and names to be referenced in the same rule. For example, %k references the kernel name for a device.

The udev Man page provides many examples of udev rules using various fields. On Fedora Core 4, the 50-udev.rules file holds rules that primarily use KERNEL keys to designate devices. The KERNEL key is followed by either a NAME field to specify the device filename or a SYMLINK field to set up a symbolic link for a device file. The following rule uses the KERNEL key to match on all mouse devices as listed by the kernel. Corresponding device names are placed in the /dev/input directory, and the name used is the kernel name for the device (%k):

KERNEL="mouse*", NAME="input/%k"

You can use more then one key in a rule. The following rule uses both a BUS key and a KERNEL key to set up device files for USB printers, whose kernel names will be used to create device files in /dev/usb:

BUS="usb", KERNEL="lp[0-9]*", NAME="usb/%k"

Symbolic Links
Certain device files are really symbolic links bearing common device names that are often linked to the actual device file used. A symbolic link is another name for a file that is used like a shortcut, referencing that file. Common devices such as printer, CD-ROM, hard drive, SCSI, and sound devices, along with many others, will have corresponding symbolic links. For example, a /dev/cdrom symbolic link links to the actual device file used for your CD-ROM.

Symbolic links are created by udev using the SYMLINK field. The symbolic links for a device can be listed either with the same rule creating a device file or in a separate rule that will specify only a symbolic link. Rules that specify a symbolic link only will have just a SYMLINK field with no NAME field. In this case the symbolic link is kept on a list awaiting the creation of its device. This allows you to add other symbolic links for a device in other rules files. For example, you could create your own rules file with symbolic links for devices. Such a file would have rules that used just SYMLINK fields for devices. Rules with NAME fields would be still be handled by the original udev rule files like 50-rules.udev.


Page 1 of 2   next page »

About Richard Petersen
Richard Petersen holds a M.L.I.S. in Library and Information Studies. He currently teaches Unix and C/C++ courses at the University of California, Berkeley.

LinuxWorld News Desk wrote: LinuxWorld: Device Management with udev and HAL on Fedora Core 4. This article discusses the implementation details for the new device management methods udev and HAL, now used on all Fedora Core 3 and 4 systems for all devices. It's time to relearn how devices are managed!
read & respond »
LATEST LINUX STORIES
Kevin Hoffman's Review of Iron Man
I took the advice of a friend of mine and steered clear of the 'normal' movie theaters and went a little out of the way to go to a DLP movie theater. The experience of comparing a regular movie theater to a DLP movie theater is like comparing standard def analog TV with a 1080i HDTV si
3rd International Virtualization Conference & Expo: Themes & Topics
From Application Virtualization to Xen, a round-up of the virtualization themes & topics being discussed in NYC June 23-24, 2008 by the world-class speaker faculty at the 3rd International Virtualization Conference & Expo being held by SYS-CON Events in The Roosevelt Hotel, in midtown
Verizon Becomes a Counter-Android Linux Convert
Verizon Wireless is snubbing Google's Linux-based Android initiative to go with the LiMo Foundation's mobile Linux spec for its next wave of mobile phones expected next year. Along with Verizon, Mozilla signed up - giving the consortium its first major open source ISV - and a key one f
Adaptec Launches New Series 2 RAID Controller For Linux Users
Adaptec unveiled a new family of entry-level Unified Serial RAID controllers. The new low-profile Series 2 RAID controllers, built on the same Adaptec dual core RAID-on-Chip (ROC) architecture used in its successful Series 5 RAID controllers, provide significant performance enhancement
JavaOne 2008: Sun Challenges Linux
Sun's mule train has finally pulled into Indiana after three years on the road. Indiana is the Linux-friendly Fedora-like OpenSolaris project meant to move the Solaris-shy Linux community off Linux and on to Solaris tempted by Solaris widgetry like the highly scalable, rollback-easy, 1
Curl Announces Support for Ubuntu for Enterprise RIA Platform
Curl announced it has released the availability of an Ubuntu Installer for the Curl Rich Internet Application (RIA) platform. Curl is a Rich Internet Application platform that competes with Adobe AIR/Flex, Silverlight, and Ajax. Curl has been shipping with Linux support for RedHat 9, S
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE