Chapter 18. The Hotplug System

Table of Contents

18.1. Devices and Interfaces
18.2. Hotplug Events
18.3. Hotplug Agents
18.4. Automatic Module Loading
18.5. Hotplug with PCI
18.6. The Boot Script Coldplug
18.7. Error Analysis


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 19, 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 calls the respective hotplug scripts to initialize these devices. For devices that cannot be detected automatically or whose events were lost during early boot time, there is coldplug. It replays recorded events or scans the system for uninitialized devices and uses static configurations for old devices like ISA.

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 hot plugged. 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. Now, the system looks at each available device and searches for suitable configuration data or generates it.

The most important hotplug functions are configured in two files. The first of these, /etc/sysconfig/hotplug, contains variables that influence the behavior of hotplug and coldplug. All variables are commented. The second file, /proc/sys/kernel/hotplug, contains the name of the executable program called by the kernel. Device configurations are located in /etc/sysconfig/hardware. Starting with SUSE LINUX 9.3, this file is usually empty because udevd receives hotplug messages via a netlink socket.

18.1. Devices and Interfaces

The hotplug system not only administers devices, but also interfaces. A device is linked to either a bus or an interface. A bus can be regarded as a multiple interface. An interface links devices to each other or to an application. There are also virtual devices, such as network tunnels. Devices usually require drivers in the form of kernel modules. 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*).

SUSE LINUX Administration Guide 9.3