from small one page howto to huge articles all in one place

search text in:




Other .linuxhowtos.org sites: www.linuxhowtos.org
toolsntoys.linuxhowtos.org



Last additions:
How to make X listen on port 6000

How to make X listen on port 6000

words:

34

views:

82920

userrating:

average rating: 1.2 (52 votes) (1=very good 6=terrible)


May, 25th 2007:
April, 26th 2007:
Apr, 10th. 2007:
Druckversion . pdf icon
You are here: Misc

Gentoo udev Guide


1. What is udev?


The /dev Directory


When Linux-users talk about the hardware on their system in the vicinity of people who believe Linux is some sort of virus or brand of coffee, the use of "slash dev slash foo" will return a strange look for sure. But for the fortunate user (and that includes you) using /dev/hda1 is just a fast way of explaining that we are talking about the primary master IDE, first partition. Or aren't we?
We all know what a device file is. Some even know why device files have special numbers when we take a closer look at them when we issue ls -l in /dev. But what we always take for granted is that the primary master IDE disk is referred to as /dev/hda. You might not see it this way, but this is a flaw by design.
Think about hotpluggable devices like USB, IEEE1394, hot-swappable PCI, ... What is the first device? And for how long? What will the other devices be named when the first one disappears? How will that affect ongoing transactions? Wouldn't it be fun that a printing job is suddenly moved from your supernew laserprinter to your almost-dead matrix printer because your mom decided to pull the plug of the laserprinter which happened to be the first printer?


Enter udev. The goals of the udev project are both interesting and needed:
- Runs in userspace
- Dynamically creates/removes device files
- Provides consistent naming
- Provides a user-space API
To provide these features, udev is developed in three separate projects: namedev, libsysfs and, of course, udev.

namedev


Namedev allows you to define the device naming separately from the udev program. This allows for flexible naming policies and naming schemes developed by separate entities. This device naming subsystem provides a standard interface that udev can use.
Currently only a single naming scheme is provided by namedev; the one provided by LANANA, used by the majority of Linux systems currently and therefore very suitable for the majority of Linux users.
Namedev uses a 5-step procedure to find out the name of a given device. If the device name is found in one of the given steps, that name is used. The steps are:
- label or serial number
- bus device number
- bus topology
- statically given name
- kernel provided name

The label or serial number step checks if the device has a unique identifier. For instance USB devices have a unique USB serial number; SCSI devices have a unique UUID. If namedev finds a match between this unique number and a given configuration file, the name provided in the configuration file is used.
The bus device number step checks the device bus number. For non-hot-swappable environments this procedure is sufficient to identify a hardware device. For instance PCI bus numbers rarely change in the lifetime of a system. Again, if namedev finds a match between this position and a given configuration file, the name provided in that configuration file is used.
Likewise the bus topology is a rather static way of defining devices as long as the user doesn't switch devices. When the position of the device matches a given setting provided by the user, the accompanying name is used.
The fourth step, statically given name, is a simple string replacement. When the kernel name (the default name) matches a given replacement string, the substitute name will be used.
The final step (kernel provided name) is a catch-all: this one takes the default name provided by the kernel. In the majority of cases this is sufficient as it matches the device naming used on current Linux systems.

libsysfs


udev interacts with the kernel through the sysfs pseudo filesystem. The libsysfs project provides a common API to access the information given by the sysfs filesystem in a generic way. This allows for querying all kinds of hardware without having to make assumptions on the kind of hardware.

udev


Every time the kernel notices an update in the device structure, it calls the /sbin/hotplug program. Hotplug runs the applications linked in the /etc/hotplug.d/default directory where you will also find a symlink to the udev application. Hotplug directs the information given by the kernel to the udev application which performs the necessary actions on the /dev structure (creating or deleting device files).

2. Using udev on Gentoo


Requirements


udev is meant to be used in combination with a 2.6 kernel (like development-sources or gentoo-dev-sources). If you're using such a kernel then you just have to make sure that you have a recent sys-apps/baselayout version. That's all you need.
Code Listing 2.1: Installing udev
# emerge udev

udev will install hotplug-base as one of it's dependencies. You do not need to install hotplug unless you want your modules automatically loaded when you plug devices in. hotplug also handles the automated bringup of network devices and firmware downloading.
Code Listing 2.2: Installing optional hotplug scripts
# emerge hotplug

If you want modules loaded for devices that have been plugged in before you boot, use the coldplug package:
Code Listing 2.3: Installing the coldplug package
# emerge coldplug

Kernelwise, if you're using the default set by genkernel then you're all set. Otherwise be sure to activate the following options:
Code Listing 2.4: Required kernel options
General setup --->   
[*] Support for hot-pluggable devices

File systems --->
Pseudo filesystems --->
[*] /proc file system support
[*] Virtual memory file system support (former shm fs)

You can leave the /dev file system support (OBSOLETE) active if you wish but you have to make sure that "Automatically mount at boot" is disabled:
Code Listing 2.5: Don't automatically mount devfsd
File systems --->   
Pseudo Filesystems --->
[*] /dev file system support (OBSOLETE)
[ ] Automatically mount at boot

Configuration


If you want to use the udev-tweaks Gentoo added to make your life comfortable, then read no more. Gentoo will use udev but keep a static /dev so that you will never have any missing device nodes. The Gentoo init scripts won't run the devfsd daemon and will deactivate devfs when you boot up.

But if you are a die-hard and want to run a udev-only, no-tweaked system as is intended by the udev development (including the difficulties of missing device nodes because udev doesn't support them yet), by all means, read on :)

We'll deactivate the rules that save the device file nodes: edit the RC_DEVICE_TARBALL variable in /etc/conf.d/rc and set it to no:
Code Listing 2.6: /etc/conf.d/rc
RC_DEVICE_TARBALL="no"

If you have included devfs support in your kernel, you can deactivate it in the bootloader configuration: add gentoo=nodevfs as a kernel parameter. If you want to use devfs and deactivate udev, add gentoo=noudev as kernel parameter.

3. Known Issues


Missing device node files at boot


If you can't boot successfully because you get an error about /dev/null not found, or because the initial console is missing, the problem is that you lack some device files that must be available before /dev is mounted and handled by udev. This is common on Gentoo machines installed from old media.

If you run sys-apps/baselayout-1.8.12 or later, this problem is alleviated since the boot process should still manage to complete. However, to get rid of those annoying warnings, you should create the missing device nodes as described below.

To see which devices nodes are present before the /dev filesystem is mounted, run the following commands:
Code Listing 3.1: Listing device nodes available at boot
# mkdir test   
# mount --bind / test
# cd test/dev
# ls

The devices needed for a successful boot are /dev/null and /dev/console. If they didn't show up in the previous test, you have to create them manually. Issue the following commands in the test/dev/ directory:
Code Listing 3.2: Creating necessary device node files
# mknod -m 660 console c 5 1   
# mknod -m 660 null c 1 3

When you're finished, don't forget to unmount the test/ directory:
Code Listing 3.3: Unmounting the test/ directory
# cd ../..   
# umount test
# rmdir test

udev and nvidia


If you use the proprietary driver from nVidia and the X server fails to start on a udev-only system, then make sure you have:

the nvidia module listed in /etc/modules.autoload.d/kernel-2.6
a version of nvidia-kernel equal to or greater than media-video/nvidia-kernel-1.0.5336-r2
a version of baselayout equal to or greater than sys-apps/baselayout-1.8.12

LVM2 Names Disappear


When you use udev and LVM2 together, you might notice that your created volume groups and logical volumes have disappeared. Well, they haven't, but they are unfortunately named /dev/dm-# with # being 0, 1, ...

To fix this, edit /etc/udev/rules.d/50-udev.rules and uncomment the following line:
Code Listing 3.4: Uncomment this line from /etc/udev/rules.d/50-udev.rules
KERNEL="dm-[0-9]*",     PROGRAM="/sbin/devmap_name %M %m", NAME="%k", SYMLINK="%c"

No Consistent Naming between DevFS and udev


Even though our intention is to have a consistent naming scheme between both dynamical device management solutions, sometimes naming differences do occur. One reported clash is with a HP Smart Array 5i RAID controller (more precisely the cciss kernel module). With udev, the devices are named /dev/cciss/cXdYpZ with X, Y and Z regular numbers. With devfs, the devices are /dev/hostX/targetY/partZ or symlinked from /dev/cciss/cXdY.

If this is the case, don't forget to update your /etc/fstab and bootloader configuration files accordingly.

Other issues


If device nodes are not created when a module is loaded from /etc/modules.autoload.d/kernel-2.6 but they appear when you load the module manually with modprobe then you should try upgrading to sys-apps/baselayout-1.8.12 or later.

Support for the framebuffer devices (/dev/fb/*) comes with the kernel starting from version 2.6.6-rc2.

For kernels older than 2.6.4 you have to explicitly include support for the /dev/pts filesystem.
Code Listing 3.5: Enabling the /dev/pts filesystem
File systems --->   
Pseudo filesystems --->
[*] /dev/pts file system for Unix98 PTYs

4. Resources & Acknowledgements


The udev talk on the Linux Symposium (Ottawa, Ontario Canada - 2003) given by Greg Kroah-Hartman (IBM Corporation) provided a solid understanding on the udev application.

Decibel's UDEV Primer is an in-depth document about udev and Gentoo.

Writing udev rules by fellow Gentoo developer Daniel Drake is an excellent document to learn how to customize your udev installation.
rate this article:
current rating: average rating: 1.3 (33 votes) (1=very good 6=terrible)
Your rating:
Very good (1) Good (2) ok (3) average (4) bad (5) terrible (6)

back



Support us on Content Nation

New Packages

- as rdf newsfeed
- as rss newsfeed
- as Atom newsfeed
2026-01-23
akonadi - 25.12.1-r1
Ebuild name:

kde-apps/akonadi-25.12.1-r1

Description

Storage service for PIM data and libraries for PIM apps

Added to portage

2026-01-23

akonadi-calendar - 25.12.1-r1
Ebuild name:

kde-apps/akonadi-calendar-25.12.1-r1

Description

Library for akonadi calendar integration

Added to portage

2026-01-23

akonadi-calendar-tools-common - 25.12.1-r1
Ebuild name:

kde-apps/akonadi-calendar-tools-common-25.12.1-r1

Description

Added to portage

2026-01-23

akonadi-contacts - 25.12.1-r1
Ebuild name:

kde-apps/akonadi-contacts-25.12.1-r1

Description

Library for akonadi contact integration

Added to portage

2026-01-23

akonadi-import-wizard - 25.12.1-r1
Ebuild name:

kde-apps/akonadi-import-wizard-25.12.1-r1

Description

Assistant to import PIM data from other applications into

Added to portage

2026-01-23

akonadi-mime - 25.12.1-r1
Ebuild name:

kde-apps/akonadi-mime-25.12.1-r1

Description

Library for akonadi mime types

Added to portage

2026-01-23

akonadi-search - 25.12.1-r1
Ebuild name:

kde-apps/akonadi-search-25.12.1-r1

Description

Libraries and daemons to implement searching in Akonadi

Added to portage

2026-01-23

akonadiconsole - 25.12.1-r1
Ebuild name:

kde-apps/akonadiconsole-25.12.1-r1

Description

Application for debugging Akonadi Resources

Added to portage

2026-01-23

akregator - 25.12.1-r1
Ebuild name:

kde-apps/akregator-25.12.1-r1

Description

News feed aggregator

Added to portage

2026-01-23

bazelisk - 1.28.1
Ebuild name:

dev-build/bazelisk-1.28.1

Description

A user-friendly launcher for Bazel written in Go

Added to portage

2026-01-23

blueprint-compiler - 0.19.0
Ebuild name:

dev-util/blueprint-compiler-0.19.0

Description

Compiler for Blueprint, a markup language for GTK user interface

Added to portage

2026-01-23

calendarjanitor - 25.12.1-r1
Ebuild name:

kde-apps/calendarjanitor-25.12.1-r1

Description

Tool to scan calendar data for buggy instances

Added to portage

2026-01-23

calendarsupport - 25.12.1-r1
Ebuild name:

kde-apps/calendarsupport-25.12.1-r1

Description

Calendar support library

Added to portage

2026-01-23

closure-compiler-bin - 20260120
Ebuild name:

dev-lang/closure-compiler-bin-20260120

Description

JavaScript optimizing compiler

Added to portage

2026-01-23

devcontainer - 0.81.1
Ebuild name:

app-containers/devcontainer-0.81.1

Description

Reference implementation of the Development Containers specifica

Added to portage

2026-01-23

ensurepip-setuptools - 80.10.1
Ebuild name:

dev-python/ensurepip-setuptools-80.10.1

Description

Shared setuptools wheel for ensurepip Python module

Added to portage

2026-01-23

eventviews - 25.12.1-r1
Ebuild name:

kde-apps/eventviews-25.12.1-r1

Description

Calendar viewer for KDE PIM

Added to portage

2026-01-23

fastfetch - 2.58.0
Ebuild name:

app-misc/fastfetch-2.58.0

Description

Fast neofetch-like system information tool

Added to portage

2026-01-23

git-cliff - 2.11.0
Ebuild name:

dev-vcs/git-cliff-2.11.0

Description

A highly customizable changelog generator

Added to portage

2026-01-23

grantlee-editor - 25.12.1-r1
Ebuild name:

kde-apps/grantlee-editor-25.12.1-r1

Description

Utilities and tools to manage themes in KDE PIM applications

Added to portage

2026-01-23

grantleetheme - 25.12.1-r1
Ebuild name:

kde-apps/grantleetheme-25.12.1-r1

Description

Library for Grantlee plugins

Added to portage

2026-01-23

incidenceeditor - 25.12.1-r1
Ebuild name:

kde-apps/incidenceeditor-25.12.1-r1

Description

Incidence editor for KOrganizer

Added to portage

2026-01-23

joplin-desktop - 3.5.12
Ebuild name:

app-office/joplin-desktop-3.5.12

Description

Secure note taking and to-do app with synchronization capabilities

Added to portage

2026-01-23

kaddressbook - 25.12.1-r1
Ebuild name:

kde-apps/kaddressbook-25.12.1-r1

Description

Address book application based on KDE Frameworks

Added to portage

2026-01-23

kalarm - 25.12.1-r1
Ebuild name:

kde-apps/kalarm-25.12.1-r1

Description

Application to manage alarms and other timer based alerts for the deskto

Added to portage

2026-01-23

kate - 25.12.1-r1
Ebuild name:

kde-apps/kate-25.12.1-r1

Description

Multi-document editor with network transparency, Plasma integration and mo

Added to portage

2026-01-23

kate-addons - 25.12.1-r1
Ebuild name:

kde-apps/kate-addons-25.12.1-r1

Description

Addons used by Kate

Added to portage

2026-01-23

kate-lib - 25.12.1-r1
Ebuild name:

kde-apps/kate-lib-25.12.1-r1

Description

Shared library used by Kate/Kwrite and Kate-Addons

Added to portage

2026-01-23

kcalutils - 25.12.1-r1
Ebuild name:

kde-apps/kcalutils-25.12.1-r1

Description

Library providing utility functions for the handling of calendar data

Added to portage

2026-01-23

kdepim-addons - 25.12.1-r1
Ebuild name:

kde-apps/kdepim-addons-25.12.1-r1

Description

Plugins for KDE Personal Information Management Suite

Added to portage

2026-01-23

kdepim-meta - 25.12.1-r1
Ebuild name:

kde-apps/kdepim-meta-25.12.1-r1

Description

KDE PIM - merge this to pull in all kdepim-derived packages

Added to portage

2026-01-23

kdepim-runtime - 25.12.1-r1
Ebuild name:

kde-apps/kdepim-runtime-25.12.1-r1

Description

Runtime plugin collection to extend the functionality of KDE PIM

Added to portage

2026-01-23

kdf - 25.12.1-r1
Ebuild name:

kde-apps/kdf-25.12.1-r1

Description

KDE free disk space utility

Added to portage

2026-01-23

keditbookmarks - 25.12.1-r1
Ebuild name:

kde-apps/keditbookmarks-25.12.1-r1

Description

Bookmarks editor based on KDE Frameworks

Added to portage

2026-01-23

kopeninghours - 25.12.1-r1
Ebuild name:

dev-libs/kopeninghours-25.12.1-r1

Description

Library for parsing and evaluating OSM opening hours expressions

Added to portage

2026-01-23

kosmindoormap - 25.12.1-r1
Ebuild name:

dev-libs/kosmindoormap-25.12.1-r1

Description

Data Model and Extraction System for Travel Reservation informati

Added to portage

2026-01-23

kpublictransport - 25.12.1-r1
Ebuild name:

dev-libs/kpublictransport-25.12.1-r1

Description

Library for accessing public transport timetables and other in

Added to portage

2026-01-23

libtsm - 4.4.1
Ebuild name:

dev-libs/libtsm-4.4.1

Description

Terminal Emulator State Machine

Added to portage

2026-01-23

merkuro - 25.12.1-r1
Ebuild name:

app-office/merkuro-25.12.1-r1

Description

Calendar application using Akonadi

Added to portage

2026-01-23

open-vmdk - 0.3.13
Ebuild name:

app-emulation/open-vmdk-0.3.13

Description

Tools for creating and converting OVA virtual appliance files

Added to portage

2026-01-23

osm - 9999
Ebuild name:

app-emacs/osm-9999

Description

OpenStreetMap tile-based viewer for GNU Emacs

Added to portage

2026-01-23

outline-magic - 0.9
Ebuild name:

app-emacs/outline-magic-0.9

Description

Outline mode extensions for Emacs

Added to portage

2026-01-23

package-build - 4.0.0
Ebuild name:

app-emacs/package-build-4.0.0

Description

Tools for assembling a package archive

Added to portage

2026-01-23

package-lint - 0.26
Ebuild name:

app-emacs/package-lint-0.26

Description

Linting library for Emacs Lisp package metadata

Added to portage

2026-01-23

reason - 3.17.3
Ebuild name:

dev-ml/reason-3.17.3

Description

Simple, fast & type safe language that leverages JavaScript and OCaml

Added to portage

2026-01-23

rpi-eeprom - 28.12_p1
Ebuild name:

dev-embedded/rpi-eeprom-28.12_p1

Description

Updater for Raspberry Pi 4/5 bootloader and the VL805 USB controll

Added to portage

2026-01-23

setuptools - 80.10.1
Ebuild name:

dev-python/setuptools-80.10.1

Description

Collection of extensions to Distutils

Added to portage

2026-01-23

tempel - 1.10
Ebuild name:

app-emacs/tempel-1.10

Description

Templates with in-buffer field editing for GNU Emacs

Added to portage

2026-01-23

vertico - 2.7
Ebuild name:

app-emacs/vertico-2.7

Description

Vertical interactive completion

Added to portage

2026-01-23

xxhash - 0.8.3-r2
Ebuild name:

dev-libs/xxhash-0.8.3-r2

Description

Extremely fast non-cryptographic hash algorithm

Added to portage

2026-01-23

2026-01-22
awscli - 1.44.22
Ebuild name:

app-admin/awscli-1.44.22

Description

Universal Command Line Environment for AWS

Added to portage

2026-01-22

boto3 - 1.42.32
Ebuild name:

dev-python/boto3-1.42.32

Description

The AWS SDK for Python

Added to portage

2026-01-22

botocore - 1.42.32
Ebuild name:

dev-python/botocore-1.42.32

Description

Low-level, data-driven core of boto 3

Added to portage

2026-01-22

cargo-nextest - 0.9.122
Ebuild name:

dev-util/cargo-nextest-0.9.122

Description

Next-generation test runner for Rust

Added to portage

2026-01-22

cargo-tarpaulin - 0.35.1
Ebuild name:

dev-util/cargo-tarpaulin-0.35.1

Description

Cargo-Tarpaulin is a tool to determine code coverage achieved via t

Added to portage

2026-01-22

cfn-lint - 1.43.4
Ebuild name:

dev-python/cfn-lint-1.43.4

Description

CloudFormation Linter

Added to portage

2026-01-22

cmocka - 2.0.2
Ebuild name:

dev-util/cmocka-2.0.2

Description

Unit testing framework for C

Added to portage

2026-01-22

dbeaver-bin - 25.3.3
Ebuild name:

dev-db/dbeaver-bin-25.3.3

Description

Free universal database tool (community edition)

Added to portage

2026-01-22

eggdrop - 1.10.1
Ebuild name:

net-irc/eggdrop-1.10.1

Description

An IRC bot extensible with C or TCL

Added to portage

2026-01-22

ensurepip-wheel - 0.46.2
Ebuild name:

dev-python/ensurepip-wheel-0.46.2

Description

Shared wheel wheel for use in pip tests

Added to portage

2026-01-22

gherkin-official - 38.0.0
Ebuild name:

dev-python/gherkin-official-38.0.0

Description

Gherkin parser/compiler for Python

Added to portage

2026-01-22

krita - 6.0.0_alpha_pre20260121
Ebuild name:

media-gfx/krita-6.0.0_alpha_pre20260121

Description

Free digital painting application. Digital Painting, Creati

Added to portage

2026-01-22

marknote - 1.4.0
Ebuild name:

app-text/marknote-1.4.0

Description

Markdown editor with a wide range of formating options for everyday notes

Added to portage

2026-01-22

mongodb-compass-bin - 1.49.0
Ebuild name:

dev-db/mongodb-compass-bin-1.49.0

Description

GUI for MongoDB

Added to portage

2026-01-22

oath-toolkit - 2.6.13
Ebuild name:

sys-auth/oath-toolkit-2.6.13

Description

Toolkit for using one-time password authentication with HOTP/TOTP algo

Added to portage

2026-01-22

openpgp-keys-libseccomp - 20260122
Ebuild name:

sec-keys/openpgp-keys-libseccomp-20260122

Description

OpenPGP key used for sys-libs/libseccomp

Added to portage

2026-01-22

openpgp-keys-oath-toolkit - 20260122
Ebuild name:

sec-keys/openpgp-keys-oath-toolkit-20260122

Description

OpenPGP keys used for sys-auth/oath-toolkit

Added to portage

2026-01-22

packaging - 26.0
Ebuild name:

dev-python/packaging-26.0

Description

Core utilities for Python packages

Added to portage

2026-01-22

pandoc-mode - 2.35
Ebuild name:

app-emacs/pandoc-mode-2.35

Description

GNU Emacs minor mode for interacting with Pandoc

Added to portage

2026-01-22

pandoc-mode - 2.90.2
Ebuild name:

app-emacs/pandoc-mode-2.90.2

Description

GNU Emacs minor mode for interacting with Pandoc

Added to portage

2026-01-22

pass-otp - 1.2.0-r3
Ebuild name:

app-admin/pass-otp-1.2.0-r3

Description

A pass extension for managing one-time-password (OTP) tokens

Added to portage

2026-01-22

pcl - 1.14.1-r3
Ebuild name:

sci-libs/pcl-1.14.1-r3

Description

2D/3D image and point cloud processing

Added to portage

2026-01-22

pycparser - 3.0
Ebuild name:

dev-python/pycparser-3.0

Description

C parser and AST generator written in Python

Added to portage

2026-01-22

skrooge - 26.1.20
Ebuild name:

app-office/skrooge-26.1.20

Description

Personal finances manager, aiming at being simple and intuitive

Added to portage

2026-01-22

sqlalchemy - 2.0.46
Ebuild name:

dev-python/sqlalchemy-2.0.46

Description

Python SQL toolkit and Object Relational Mapper

Added to portage

2026-01-22

upterm - 0.22.0
Ebuild name:

app-misc/upterm-0.22.0

Description

Instant Terminal Sharing

Added to portage

2026-01-22

wheel - 0.46.2
Ebuild name:

dev-python/wheel-0.46.2

Description

A built-package format for Python

Added to portage

2026-01-22

rdf newsfeed | rss newsfeed | Atom newsfeed
Copyright 2004-2025 Sascha Nitsch Unternehmensberatung GmbH
- Copyright and legal notices -
Time to create this page: 61.2 ms