15.5. Consistent Names for Mass Storage Devices

SUSE LINUX comes with scripts that help always assign the same designations to hard disks and other storage devices. /sbin/udev.get_persistent_device_name.sh is a wrapper script. First it calls /sbin/udev.get_unique_hardware_path.sh, which ascertains the hardware path for a specified device. /sbin/udev.get_unique_drive_id.sh also retrieves the serial number. Both outputs are then passed to udev, which creates the symbolic link to the device node under /dev. The wrapper can be used directly in the udev rules. Here is an example for SCSI, which can also be generalized to USB or IDE (write it as one line):

BUS="scsi", 
PROGRAM="/sbin/udev.get_persistent_device_name.sh", 
NAME="%k", SYMLINK="%c{1+}"

As soon as a driver has been loaded for a mass storage device, it registers with all the available hard disks with the kernel. Each of them triggers a hotplug block event that calls udev. First, udev reads the rules to ascertain 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.

[Tip]Tip

There are a number of tools and programs that rely on the fact that /dev/sda is a SCSI hard disk and /dev/hda is an IDE disk. If this is not the case, these programs will not work. YaST relies on these tools, so only works with the kernel device designations.