Chapter 32. The Hotplug System

Table of Contents

32.1. Devices and Interfaces
32.2. Hotplug Events
32.3. Hotplug Device Configuration
32.4. Automatic Module Loading
32.5. The Boot Script Coldplug
32.6. Error Analysis

Abstract

The hotplug system controls the initialization of most devices in a computer. It is not only used for devices that can be inserted and removed during operation, but for all devices that are detected while the system is booting. It works closely together with the sysfs file system and udev, which are described in Chapter 33, Dynamic Device Nodes with udev.

Until the kernel has been booted, only devices that are absolutely necessary, like the bus system, boot disks, and keyboard, are initialized. The kernel triggers hotplug events for all devices that were detected. The udevd daemon listens to these events and runs udev to create the device node and configure the device. For devices that cannot be detected automatically, like old ISA cards, a static configuration is used.

Apart from a few historic exceptions, most devices are initialized immediately as soon as they are accessible, either during system boot or when devices are hotplugged. During initialization, interfaces are registered with the kernel. This registration triggers further hotplug events that cause an automatic configuration of the respective interface.

In former versions of SUSE Linux, a static set of configuration data was used as the basis for initializing devices. Any hotplug events were handled by separate scripts, called agents. With this release of SUSE Linux the hotplug subsystem is integrated into udev, with udev rules provide the functionality of the former hotplug agents.

The general settings for the hotplug subsystem can be found in /etc/sysconfig/hotplug. All variables are commented. General device configuration is made depending on matching rules found in /etc/udev/rules.d (see Chapter 33, Dynamic Device Nodes with udev). Configuration files for specific devices are located in /etc/sysconfig/hardware. The hotplug event callback used in former version of SUSE Linux, /proc/sys/kernel/hotplug, is usually empty because udevd receives hotplug messages via a netlink socket.

32.1. Devices and Interfaces

The hotplug system configures not only devices but also interfaces. A device is commonly connected to a bus and provides the functionality required for an interface. An interface represents the user-visible abstraction of either the entire or a certain subset of a device. A device usually requires a device driver in the form of kernel modules to function properly. Additionally, some higher-level driver might be needed to provide the interface to the user. Interfaces are mostly represented by device nodes created by udev. The distinction of devices and interfaces is important for understanding the overall concept.

Devices entered in the sysfs file system are found under /sys/devices. Interfaces are located under /sys/class or /sys/block. All interfaces in sysfs should have a link to their devices. However, there are still some drivers that do not automatically add this link. Without that link, it is unknown to which device this interface belongs and a suitable configuration cannot be found.

Devices are addressed by means of a device description. This may be the device path in sysfs (/sys/devices/pci0000:00/0000:00:1e.0/0000:02:00.0), a description of the connection point (bus-pci-0000:02:00.0), an individual ID (id-32311AE03FB82538), or something similar. In the past, interfaces were addressed by means of their names. These names represented a simple numbering of the existing devices and might have changed when devices were added or removed.

Interfaces can also be addressed by means of a description of the associated device. Usually, the context indicates whether the description refers to the device itself or to its interface. Typical examples of devices, interfaces, and descriptions include:

PCI Network Card

A device that is connected to the PCI bus (/sys/devices/pci0000:00/0000:00:1e.0/0000:02:00.0 or bus-pci-0000:02:00.0) and has a network interface (eth0, id-00:0d:60:7f:0b:22 or bus-pci-0000:02:00.0). The network interface is used by network services or connected to a virtual network device, such as a tunnel or VLAN, which in turn has an interface.

PCI SCSI Controller

A device (/sys/devices/pci0000:20/0000:20:01.1/host1/1:0:0:0 or bus-scsi-1:0:0:0) that makes several physical interfaces available in the form of a bus (/sys/class/scsi_host/host1).

SCSI Hard Disk

A device (/sys/devices/pci0000:20/0000:20:01.1/host1/1:0:0:0 or bus-scsi-1:0:0:0) with several interfaces (/sys/block/sda*).