33.5. Persistent Names for Mass Storage Devices

SUSE Linux comes with predefined rules that allow you always to assign the same designations to hard disks and other storage devices, no matter in which order they are initialized. Unique device attributes, like hardware serial numbers, UUIDs or file system labels, can be read with small helper programs that come with udev. The helper programs make specific device information available to the udev rule processing. As a simplified example, the first rule imports the values gathered from the SCSI device in the udev environment. The second rule uses the imported values to create a persistent symlink.

KERNEL="sd*[!0-9]", IMPORT="/sbin/scsi_id -g -x -s $p -d %N"
KERNEL="sd*[!0-9]", SYMLINK+="$env{ID_TYPE}/by-id/$env{ID_BUS}-$env{ID_SERIAL}"

As soon as a driver for a mass storage device has been loaded, it registers all the available hard disks with the kernel. Each of them triggers a hotplug block event that calls udev. Then udev reads the rules to determine whether a symlink needs to be created.

If the driver is loaded via initrd, the hotplug events are lost. However, all the information is stored in sysfs. The udevstart utility finds all the device files under /sys/block and /sys/class and starts udev.

There is also a start script boot.udev, which recreates all the device nodes during the boot process. However, the start script must be activated through the YaST runlevel editor or with the command insserv boot.udev.