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:

70008

userrating:

average rating: 1.2 (8 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.0 (7 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
2024-11-12
bpftool - 7.5.0
Ebuild name:

dev-util/bpftool-7.5.0

Description

Tool for inspection and simple manipulation of eBPF programs and maps

Added to portage

2024-11-12

cpptoml - 0.1.1
Ebuild name:

dev-cpp/cpptoml-0.1.1

Description

Header-only library for parsing TOML

Added to portage

2024-11-12

edencommon - 2024.11.04.00
Ebuild name:

dev-cpp/edencommon-2024.11.04.00

Description

Shared library for Watchman and Eden projects

Added to portage

2024-11-12

fb303 - 2024.11.04.00
Ebuild name:

dev-cpp/fb303-2024.11.04.00

Description

Core set of Thrift functions querying stats and other information from

Added to portage

2024-11-12

fbthrift - 2024.11.04.00
Ebuild name:

dev-cpp/fbthrift-2024.11.04.00

Description

Facebook's branch of Apache Thrift (C++ bindings)

Added to portage

2024-11-12

fizz - 2024.11.04.00
Ebuild name:

dev-cpp/fizz-2024.11.04.00

Description

C++14 implementation of the TLS-1.3 standard

Added to portage

2024-11-12

folly - 2024.11.04.00
Ebuild name:

dev-cpp/folly-2024.11.04.00

Description

An open-source C++ library developed and used at Facebook

Added to portage

2024-11-12

kio-admin - 24.08.3
Ebuild name:

app-admin/kio-admin-24.08.3

Description

Manage files as administrator using the admin KIO protocol

Added to portage

2024-11-12

libbpf - 1.5.0
Ebuild name:

dev-libs/libbpf-1.5.0

Description

Stand-alone build of libbpf from the Linux kernel

Added to portage

2024-11-12

mvfst - 2024.11.04.00
Ebuild name:

dev-cpp/mvfst-2024.11.04.00

Description

An implementation of the QUIC transport protocol

Added to portage

2024-11-12

racket-mode - 1_p20241001
Ebuild name:

app-emacs/racket-mode-1_p20241001

Description

Emacs modes for Racket edit, REPL, check-syntax, debug, profile,

Added to portage

2024-11-12

racket-mode - 1_p20241031
Ebuild name:

app-emacs/racket-mode-1_p20241031

Description

Emacs modes for Racket edit, REPL, check-syntax, debug, profile,

Added to portage

2024-11-12

racket-mode - 9999
Ebuild name:

app-emacs/racket-mode-9999

Description

Emacs modes for Racket edit, REPL, check-syntax, debug, profile, and mor

Added to portage

2024-11-12

rainbow-delimiters - 2.1.5
Ebuild name:

app-emacs/rainbow-delimiters-2.1.5

Description

Highlight nested parentheses, brackets, and braces according to

Added to portage

2024-11-12

ruff - 0.7.3
Ebuild name:

dev-util/ruff-0.7.3

Description

An extremely fast Python linter, written in Rust

Added to portage

2024-11-12

terminatorx - 4.2.0-r1
Ebuild name:

media-sound/terminatorx-4.2.0-r1

Description

Realtime audio synthesizer allowing you to 'scratch' on sampled au

Added to portage

2024-11-12

wangle - 2024.11.04.00
Ebuild name:

dev-cpp/wangle-2024.11.04.00

Description

A framework providing common abstractions for building services

Added to portage

2024-11-12

watchman - 2024.11.04.00
Ebuild name:

dev-util/watchman-2024.11.04.00

Description

A file watching service

Added to portage

2024-11-12

2024-11-11
activesupport - 8.0.0
Ebuild name:

dev-ruby/activesupport-8.0.0

Description

Utility Classes and Extension to the Standard Library

Added to portage

2024-11-11

aiohttp - 3.11.0_rc0
Ebuild name:

dev-python/aiohttp-3.11.0_rc0

Description

HTTP client/server for asyncio

Added to portage

2024-11-11

ansible-lint - 24.9.2
Ebuild name:

app-admin/ansible-lint-24.9.2

Description

Checks ansible playbooks for practices and behaviour that can be impr

Added to portage

2024-11-11

aws-partitions - 1.1003.0
Ebuild name:

dev-ruby/aws-partitions-1.1003.0

Description

Provides interfaces to enumerate AWS partitions, regions, and serv

Added to portage

2024-11-11

borgmatic - 1.9.1
Ebuild name:

app-backup/borgmatic-1.9.1

Description

Automatically create, prune and verify backups with borgbackup

Added to portage

2024-11-11

c-ares - 1.34.3
Ebuild name:

net-dns/c-ares-1.34.3

Description

C library that resolves names asynchronously

Added to portage

2024-11-11

calibre - 7.21.0
Ebuild name:

app-text/calibre-7.21.0

Description

Ebook management application

Added to portage

2024-11-11

ccls - 0.20241108
Ebuild name:

dev-util/ccls-0.20241108

Description

C/C++/ObjC language server

Added to portage

2024-11-11

chromium - 131.0.6778.33
Ebuild name:

www-client/chromium-131.0.6778.33

Description

Open-source version of Google Chrome web browser

Added to portage

2024-11-11

eclean-kernel - 2.99.10
Ebuild name:

app-admin/eclean-kernel-2.99.10

Description

Remove outdated built kernels

Added to portage

2024-11-11

fontbox - 2.0.32
Ebuild name:

dev-java/fontbox-2.0.32

Description

An open source Java library for parsing font files

Added to portage

2024-11-11

freeciv - 3.1.3
Ebuild name:

games-strategy/freeciv-3.1.3

Description

Multiplayer strategy game (Civilization Clone)

Added to portage

2024-11-11

gcc - 15.0.0_pre20241110
Ebuild name:

sys-devel/gcc-15.0.0_pre20241110

Description

The GNU Compiler Collection

Added to portage

2024-11-11

git-sources - 6.12_rc7
Ebuild name:

sys-kernel/git-sources-6.12_rc7

Description

The very latest -git version of the Linux kernel

Added to portage

2024-11-11

gmpy2 - 2.2.1
Ebuild name:

dev-python/gmpy2-2.2.1

Description

Python bindings for GMP, MPC, MPFR and MPIR libraries

Added to portage

2024-11-11

gpgme - 1.24.0
Ebuild name:

app-crypt/gpgme-1.24.0

Description

GnuPG Made Easy is a library for making GnuPG easier to use

Added to portage

2024-11-11

hatchling - 1.26.1
Ebuild name:

dev-python/hatchling-1.26.1

Description

Modern, extensible Python build backend

Added to portage

2024-11-11

hypothesis - 6.118.7
Ebuild name:

dev-python/hypothesis-6.118.7

Description

A library for property based testing

Added to portage

2024-11-11

icu - 76.1-r1
Ebuild name:

dev-libs/icu-76.1-r1

Description

International Components for Unicode

Added to portage

2024-11-11

icu-layoutex - 76.1-r1
Ebuild name:

dev-libs/icu-layoutex-76.1-r1

Description

External layout part of International Components for Unicode

Added to portage

2024-11-11

icu-le-hb - 2.0.0
Ebuild name:

dev-libs/icu-le-hb-2.0.0

Description

ICU Layout Engine API on top of HarfBuzz shaping library

Added to portage

2024-11-11

inline-snapshot - 0.14.0
Ebuild name:

dev-python/inline-snapshot-0.14.0

Description

Create and update inline snapshots in your Python tests

Added to portage

2024-11-11

iptables - 1.8.11
Ebuild name:

net-firewall/iptables-1.8.11

Description

Linux kernel (2.4+) firewall, NAT and packet mangling tools

Added to portage

2024-11-11

jansi - 1.18
Ebuild name:

dev-java/jansi-1.18

Description

A library that allows you to use ANSI escape sequences in your console output

Added to portage

2024-11-11

jbig2-imageio - 3.0.4
Ebuild name:

dev-java/jbig2-imageio-3.0.4

Description

PDFBox JBIG2 ImageIO plugin

Added to portage

2024-11-11

jedi - 0.19.2
Ebuild name:

dev-python/jedi-0.19.2

Description

Autocompletion library for Python

Added to portage

2024-11-11

jinja2 - 3.1.4
Ebuild name:

dev-python/jinja2-3.1.4

Description

A full-featured template engine for Python

Added to portage

2024-11-11

jja - 0.9.1-r2
Ebuild name:

games-board/jja-0.9.1-r2

Description

swiss army knife for chess file formats

Added to portage

2024-11-11

libdisplay-info - 0.1.1-r1
Ebuild name:

media-libs/libdisplay-info-0.1.1-r1

Description

EDID and DisplayID library

Added to portage

2024-11-11

libdisplay-info - 0.2.0-r1
Ebuild name:

media-libs/libdisplay-info-0.2.0-r1

Description

EDID and DisplayID library

Added to portage

2024-11-11

libndp - 1.9-r1
Ebuild name:

net-libs/libndp-1.9-r1

Description

Library for Neighbor Discovery Protocol

Added to portage

2024-11-11

libreswan - 5.1-r1
Ebuild name:

net-vpn/libreswan-5.1-r1

Description

IPsec implementation for Linux, fork of Openswan

Added to portage

2024-11-11

libxml2 - 2.11.9
Ebuild name:

dev-libs/libxml2-2.11.9

Description

XML C parser and toolkit

Added to portage

2024-11-11

libxml2 - 2.12.9
Ebuild name:

dev-libs/libxml2-2.12.9

Description

XML C parser and toolkit

Added to portage

2024-11-11

libxml2 - 2.13.4
Ebuild name:

dev-libs/libxml2-2.13.4

Description

XML C parser and toolkit

Added to portage

2024-11-11

libxslt - 1.1.42
Ebuild name:

dev-libs/libxslt-1.1.42

Description

XSLT libraries and tools

Added to portage

2024-11-11

mixlib-shellout - 3.3.4
Ebuild name:

dev-ruby/mixlib-shellout-3.3.4

Description

Run external commands on Unix or Windows

Added to portage

2024-11-11

mrouted - 4.6
Ebuild name:

net-misc/mrouted-4.6

Description

IP multicast routing daemon

Added to portage

2024-11-11

net-imap - 0.4.18
Ebuild name:

dev-ruby/net-imap-0.4.18

Description

Ruby client api for Internet Message Access Protocol

Added to portage

2024-11-11

nokogiri - 1.16.7
Ebuild name:

dev-ruby/nokogiri-1.16.7

Description

Nokogiri is an HTML, XML, SAX, and Reader parser

Added to portage

2024-11-11

openpgp-keys-apache-pdfbox - 20141029
Ebuild name:

sec-keys/openpgp-keys-apache-pdfbox-20141029

Description

OpenPGP keys used by pdfbox.apache.org

Added to portage

2024-11-11

openpgp-keys-icu - 20241110
Ebuild name:

sec-keys/openpgp-keys-icu-20241110

Description

OpenPGP keys used by ICU

Added to portage

2024-11-11

openpgp-keys-wget - 20241111
Ebuild name:

sec-keys/openpgp-keys-wget-20241111

Description

OpenPGP keys used by GNU wget

Added to portage

2024-11-11

openttd - 14.1
Ebuild name:

games-simulation/openttd-14.1

Description

A clone of Transport Tycoon Deluxe

Added to portage

2024-11-11

pdfbox - 2.0.32
Ebuild name:

dev-java/pdfbox-2.0.32

Description

Java library and utilities for working with PDF documents

Added to portage

2024-11-11

perf - 6.11.7
Ebuild name:

dev-util/perf-6.11.7

Description

Userland tools for Linux Performance Counters

Added to portage

2024-11-11

rainbow-mode - 1.0.6
Ebuild name:

app-emacs/rainbow-mode-1.0.6

Description

Colorize strings that represent colors inside Emacs buffers

Added to portage

2024-11-11

raku-mode - 0.2.1_p20211121
Ebuild name:

app-emacs/raku-mode-0.2.1_p20211121

Description

Major mode for editing Raku code

Added to portage

2024-11-11

reazon - 0.4.1
Ebuild name:

app-emacs/reazon-0.4.1

Description

GNU Emacs implementation of miniKanren, logic programming language

Added to portage

2024-11-11

redo+ - 1.19
Ebuild name:

app-emacs/redo+-1.19

Description

Redo/undo system for Emacs

Added to portage

2024-11-11

rocksdb - 9.7.4
Ebuild name:

dev-libs/rocksdb-9.7.4

Description

Embeddable, persistent key-value store for fast storage

Added to portage

2024-11-11

sqlite - 3.47.0-r1
Ebuild name:

dev-db/sqlite-3.47.0-r1

Description

SQL database engine

Added to portage

2024-11-11

telegram-desktop-bin - 5.7.2
Ebuild name:

net-im/telegram-desktop-bin-5.7.2

Description

Official desktop client for Telegram (binary package)

Added to portage

2024-11-11

wget - 1.25.0
Ebuild name:

net-misc/wget-1.25.0

Description

Network utility to retrieve files from the WWW

Added to portage

2024-11-11

xmpbox - 2.0.32
Ebuild name:

dev-java/xmpbox-2.0.32

Description

An open source Java tool that implements Adobe's XMP(TM) specification

Added to portage

2024-11-11

xtrans - 1.5.2
Ebuild name:

x11-libs/xtrans-1.5.2

Description

X.Org xtrans library

Added to portage

2024-11-11

zipp - 3.21.0
Ebuild name:

dev-python/zipp-3.21.0

Description

Backport of pathlib-compatible object wrapper for zip files

Added to portage

2024-11-11

rdf newsfeed | rss newsfeed | Atom newsfeed
- Powered by LeopardCMS - Running on Gentoo -
Copyright 2004-2020 Sascha Nitsch Unternehmensberatung GmbH
Valid XHTML1.1 : Valid CSS : buttonmaker
- Level Triple-A Conformance to Web Content Accessibility Guidelines 1.0 -
- Copyright and legal notices -
Time to create this page: 55.4 ms