16.6. Consistent Names For Mass Storage Devices

SUSE LINUX comes with scripts that help you to 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 (make sure you 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 will trigger a hotplug block event which calls udev. First udev reads the rules to ascertain whether a symlink needs to be created.

If the driver is loaded via initrd, then 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 has to be activated through the YaST runlevel editor or with the command insserv boot.udev.

[Tip]Tip

There are a number of tools and programs which 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, then these programs will not work. However, YaST relies on these tools and therefore only works with the kernel device designations.