auf.kante
Gunnar macht sich selbststaendig und fliegt auf
die Schnauze
wird erfolgreich. Wer mag darf zuschauen.
Gunnar is starting his business. He will certainly
fail succeed. You may watch.
auf.kante
USB sticks
Last changed:
Content:

 

As long as USB sticks have a serial number they can be uniquely identified and mapped to a specific location.

Usually the sticks provide an "sda" and one or several "sdaX" devices.

To map only the "sdaX" to a unique identifier, I use the following script:

> cat /etc/udev/scripts/check_block_device.sh
#! /bin/bash
#

## Check that the devpath contains "block" for block device
## and verify that the kernel would give the device a number
## higher than 0 (like sda1)
if [ "x${DEVPATH/\/block\/*/yes}" = "xyes" -a ${1} -ge 1 ]; then
    exit 0
fi

exit 1

Now I can set a specific rules in the rules.d directory:

cat /etc/udev/rules.d/20-usb-sticks.rules
# /etc/udev/udev.rules:  device naming rules for udev
#
# USB stick rules for Gunnar Wrobel

SYSFS{serial}="1194551889523", PROGRAM="/etc/udev/scripts/check_block_device.sh %n", NAME="sticks/medion0", SYMLINK="sda%n", OWNER="root", GROUP="users", MODE="660"

Back to udev