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:

83336

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-02-16
alot - 0.11-r2
Ebuild name:

mail-client/alot-0.11-r2

Description

Experimental terminal UI for net-mail/notmuch written in Python

Added to portage

2026-02-16

atuin - 18.12.1
Ebuild name:

app-shells/atuin-18.12.1

Description

Shell history manager supporting encrypted synchronisation

Added to portage

2026-02-16

cdemu - 3.3.0
Ebuild name:

app-cdr/cdemu-3.3.0

Description

Command-line tool for controlling cdemu-daemon

Added to portage

2026-02-16

cdemu-daemon - 3.3.0
Ebuild name:

app-cdr/cdemu-daemon-3.3.0

Description

Daemon of the CDEmu optical media image mounting suite

Added to portage

2026-02-16

cfv - 3.2.0
Ebuild name:

app-arch/cfv-3.2.0

Description

Command-line File Verify - versatile file checksum creator and verifier

Added to portage

2026-02-16

createrepo_c - 1.2.2-r1
Ebuild name:

app-arch/createrepo_c-1.2.2-r1

Description

C implementation of createrepo

Added to portage

2026-02-16

freenet - 0.7.5_p1506
Ebuild name:

net-p2p/freenet-0.7.5_p1506

Description

Freenet REference Daemon

Added to portage

2026-02-16

gcc - 16.0.1_p20260215
Ebuild name:

sys-devel/gcc-16.0.1_p20260215

Description

The GNU Compiler Collection

Added to portage

2026-02-16

gcdemu - 3.3.0
Ebuild name:

app-cdr/gcdemu-3.3.0

Description

Gtk+ GUI for controlling cdemu-daemon

Added to portage

2026-02-16

huggingface_hub - 1.3.7
Ebuild name:

sci-ml/huggingface_hub-1.3.7

Description

a client library to interact with the Hugging Face Hub

Added to portage

2026-02-16

immutabledict - 4.3.1
Ebuild name:

dev-python/immutabledict-4.3.1

Description

An immutable wrapper around dictionaries

Added to portage

2026-02-16

jsonschema-path - 0.4.0_beta6
Ebuild name:

dev-python/jsonschema-path-0.4.0_beta6

Description

JSONSchema Spec with object-oriented paths

Added to portage

2026-02-16

libmirage - 3.3.1
Ebuild name:

dev-libs/libmirage-3.3.1

Description

CD and DVD image access library

Added to portage

2026-02-16

librecad - 2.2.2_alpha1_pre20260215
Ebuild name:

media-gfx/librecad-2.2.2_alpha1_pre20260215

Description

Generic 2D CAD program

Added to portage

2026-02-16

maturin - 1.12.1
Ebuild name:

dev-util/maturin-1.12.1

Description

Build and publish crates with pyo3, rust-cpython and cffi bindings

Added to portage

2026-02-16

mumble - 1.6.0_pre20260215
Ebuild name:

net-voip/mumble-1.6.0_pre20260215

Description

Mumble is an open source, low-latency, high quality voice chat so

Added to portage

2026-02-16

murmur - 1.6.0_pre20260215
Ebuild name:

net-voip/murmur-1.6.0_pre20260215

Description

Mumble is an open source, low-latency, high quality voice chat so

Added to portage

2026-02-16

ninja-mode - 1.11.1-r2
Ebuild name:

app-emacs/ninja-mode-1.11.1-r2

Description

GNU Emacs mode for handling Ninja build files

Added to portage

2026-02-16

notmuch - 0.40
Ebuild name:

net-mail/notmuch-0.40

Description

Thread-based e-mail indexer, supporting quick search and tagging

Added to portage

2026-02-16

nzbget - 26.0
Ebuild name:

net-nntp/nzbget-26.0

Description

A command-line based binary newsgrabber supporting .nzb files

Added to portage

2026-02-16

p11-kit - 0.26.2
Ebuild name:

app-crypt/p11-kit-0.26.2

Description

Provides a standard configuration setup for installing PKCS11

Added to portage

2026-02-16

paperkey - 1.6
Ebuild name:

app-crypt/paperkey-1.6

Description

OpenPGP key archiver

Added to portage

2026-02-16

pathable - 0.5.0_beta6
Ebuild name:

dev-python/pathable-0.5.0_beta6

Description

Object-oriented paths

Added to portage

2026-02-16

platformdirs - 4.9.2
Ebuild name:

dev-python/platformdirs-4.9.2

Description

A small Python module for determining appropriate platform-specific d

Added to portage

2026-02-16

pymdown-extensions - 10.21
Ebuild name:

dev-python/pymdown-extensions-10.21

Description

Extensions for Python Markdown

Added to portage

2026-02-16

python-socks - 2.8.1
Ebuild name:

dev-python/python-socks-2.8.1

Description

SOCKS4, SOCKS5, HTTP tunneling functionality for Python

Added to portage

2026-02-16

rubber - 1.6.7-r1
Ebuild name:

dev-tex/rubber-1.6.7-r1

Description

LaTeX wrapper for automatically building documents

Added to portage

2026-02-16

sipp - 3.7.7
Ebuild name:

net-misc/sipp-3.7.7

Description

A free Open Source test tool / traffic generator for the SIP protocol

Added to portage

2026-02-16

smb4k - 4.0.6
Ebuild name:

net-misc/smb4k-4.0.6

Description

Advanced network neighborhood browser

Added to portage

2026-02-16

stalwart-cli - 0.15.5
Ebuild name:

net-mail/stalwart-cli-0.15.5

Description

Stalwart Mail Server command line utility

Added to portage

2026-02-16

stalwart-mail - 0.15.5
Ebuild name:

net-mail/stalwart-mail-0.15.5

Description

Stalwart Mail Server

Added to portage

2026-02-16

tifffile - 2026.2.15
Ebuild name:

dev-python/tifffile-2026.2.15

Description

Read and write TIFF files

Added to portage

2026-02-16

tox - 4.36.0
Ebuild name:

dev-python/tox-4.36.0

Description

virtualenv-based automation of test activities

Added to portage

2026-02-16

vimpc - 0.09.2_p20230330
Ebuild name:

media-sound/vimpc-0.09.2_p20230330

Description

ncurses based mpd client with vi-like key bindings

Added to portage

2026-02-16

vlc - 4.0.0_pre20260215
Ebuild name:

media-video/vlc-4.0.0_pre20260215

Description

Media player and framework with support for most multimedia files

Added to portage

2026-02-16

xmltodict - 1.0.3
Ebuild name:

dev-python/xmltodict-1.0.3

Description

Makes working with XML feel like you are working with JSON

Added to portage

2026-02-16

2026-02-15
amarok - 3.3.2-r1
Ebuild name:

media-sound/amarok-3.3.2-r1

Description

Advanced audio player based on KDE Frameworks

Added to portage

2026-02-15

android-studio - 2025.3.1.8
Ebuild name:

dev-util/android-studio-2025.3.1.8

Description

Android development environment based on IntelliJ IDEA

Added to portage

2026-02-15

anydesk - 7.1.4
Ebuild name:

net-misc/anydesk-7.1.4

Description

Feature rich multi-platform remote desktop application

Added to portage

2026-02-15

catalyst - 4.1.1
Ebuild name:

dev-util/catalyst-4.1.1

Description

Release metatool used for creating releases based on Gentoo Linux

Added to portage

2026-02-15

chromium - 145.0.7632.75
Ebuild name:

www-client/chromium-145.0.7632.75

Description

Open-source version of Google Chrome web browser

Added to portage

2026-02-15

etherape - 0.9.21
Ebuild name:

net-analyzer/etherape-0.9.21

Description

A graphical network monitor for Unix modeled after etherman

Added to portage

2026-02-15

filelock - 3.24.0
Ebuild name:

dev-python/filelock-3.24.0

Description

A platform independent file lock for Python

Added to portage

2026-02-15

gcc - 15.2.1_p20260214
Ebuild name:

sys-devel/gcc-15.2.1_p20260214

Description

The GNU Compiler Collection

Added to portage

2026-02-15

gdbus-codegen - 2.86.4
Ebuild name:

dev-util/gdbus-codegen-2.86.4

Description

GDBus code and documentation generator

Added to portage

2026-02-15

gentoo-sources - 6.12.71
Ebuild name:

sys-kernel/gentoo-sources-6.12.71

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2026-02-15

glib - 2.86.4
Ebuild name:

dev-libs/glib-2.86.4

Description

The GLib library of C routines

Added to portage

2026-02-15

glib-utils - 2.86.4
Ebuild name:

dev-util/glib-utils-2.86.4

Description

Build utilities for GLib using projects

Added to portage

2026-02-15

hsqldb - 2.7.4-r1
Ebuild name:

dev-db/hsqldb-2.7.4-r1

Description

HSQLDB - Lightweight 100% Java SQL Database Engine

Added to portage

2026-02-15

huggingface_hub - 0.36.2-r1
Ebuild name:

sci-ml/huggingface_hub-0.36.2-r1

Description

a client library to interact with the Hugging Face Hub

Added to portage

2026-02-15

huggingface_hub - 1.1.7
Ebuild name:

sci-ml/huggingface_hub-1.1.7

Description

a client library to interact with the Hugging Face Hub

Added to portage

2026-02-15

huggingface_hub - 1.2.4
Ebuild name:

sci-ml/huggingface_hub-1.2.4

Description

a client library to interact with the Hugging Face Hub

Added to portage

2026-02-15

indilib - 2.1.9
Ebuild name:

sci-libs/indilib-2.1.9

Description

INDI Astronomical Control Protocol library

Added to portage

2026-02-15

libgcrypt - 1.12.0-r3
Ebuild name:

dev-libs/libgcrypt-1.12.0-r3

Description

General purpose crypto library based on the code used in GnuPG

Added to portage

2026-02-15

libssh - 0.11.4
Ebuild name:

net-libs/libssh-0.11.4

Description

Access a working SSH implementation by means of a library

Added to portage

2026-02-15

mariadb-connector-odbc - 3.2.8
Ebuild name:

dev-db/mariadb-connector-odbc-3.2.8

Description

MariaDB Connector/ODBC

Added to portage

2026-02-15

mpd - 0.24.8
Ebuild name:

media-sound/mpd-0.24.8

Description

The Music Player Daemon (mpd)

Added to portage

2026-02-15

nh3 - 0.3.3
Ebuild name:

dev-python/nh3-0.3.3

Description

Ammonia HTML sanitizer Python binding

Added to portage

2026-02-15

ninja-mode - 1.12.0
Ebuild name:

app-emacs/ninja-mode-1.12.0

Description

GNU Emacs mode for handling Ninja build files

Added to portage

2026-02-15

ninja-mode - 1.12.1
Ebuild name:

app-emacs/ninja-mode-1.12.1

Description

GNU Emacs mode for handling Ninja build files

Added to portage

2026-02-15

nuitka - 4.0.1
Ebuild name:

dev-python/nuitka-4.0.1

Description

Python to native compiler

Added to portage

2026-02-15

openapi-spec-validator - 0.8.0_beta2
Ebuild name:

dev-python/openapi-spec-validator-0.8.0_beta2

Description

OpenAPI 2.0 (aka Swagger) and OpenAPI 3.0 spec valida

Added to portage

2026-02-15

par2cmdline-turbo - 1.4.0
Ebuild name:

app-arch/par2cmdline-turbo-1.4.0

Description

par2cmdline × ParPar speed focused par2cmdline fork

Added to portage

2026-02-15

pass - 2.0_p20260214
Ebuild name:

app-emacs/pass-2.0_p20260214

Description

Major mode for password-store

Added to portage

2026-02-15

platformdirs - 4.9.1
Ebuild name:

dev-python/platformdirs-4.9.1

Description

A small Python module for determining appropriate platform-specific d

Added to portage

2026-02-15

pmacct - 1.7.9
Ebuild name:

net-analyzer/pmacct-1.7.9

Description

A network tool to gather IP traffic information

Added to portage

2026-02-15

pycxx - 7.2.1
Ebuild name:

dev-python/pycxx-7.2.1

Description

Set of facilities to extend Python with C++

Added to portage

2026-02-15

pytest-django - 4.12.0
Ebuild name:

dev-python/pytest-django-4.12.0

Description

A Django plugin for pytest

Added to portage

2026-02-15

pytest-httpserver - 1.1.5
Ebuild name:

dev-python/pytest-httpserver-1.1.5

Description

HTTP server for pytest to test HTTP clients

Added to portage

2026-02-15

qcoro - 0.13.0
Ebuild name:

dev-libs/qcoro-0.13.0

Description

C++ Coroutine Library for Qt

Added to portage

2026-02-15

tomcat-native - 1.3.6
Ebuild name:

dev-java/tomcat-native-1.3.6

Description

Allows Tomcat to use certain native resources for better performance

Added to portage

2026-02-15

trio - 0.33.0
Ebuild name:

dev-python/trio-0.33.0

Description

Python library for async concurrency and I/O

Added to portage

2026-02-15

typeguard - 4.5.0
Ebuild name:

dev-python/typeguard-4.5.0

Description

Run-time type checker for Python

Added to portage

2026-02-15

vanilla-sources - 6.12.71
Ebuild name:

sys-kernel/vanilla-sources-6.12.71

Description

Full sources for the Linux kernel

Added to portage

2026-02-15

w3m - 0.5.6
Ebuild name:

www-client/w3m-0.5.6

Description

Text based WWW browser, supports tables and frames

Added to portage

2026-02-15

wireless-regdb - 20260204
Ebuild name:

net-wireless/wireless-regdb-20260204

Description

Wireless Regulatory database for Linux

Added to portage

2026-02-15

xl2tpd - 1.3.20
Ebuild name:

net-dialup/xl2tpd-1.3.20

Description

A modern version of the Layer 2 Tunneling Protocol (L2TP) daemon

Added to portage

2026-02-15

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