3 # This script generates and sends to stdout a set of udev.rules for use
4 # with all scsi block devices on your system. It creates a udev key NAME
5 # with prefix defaulting to "disk-", and appends the current kernel name
6 # and the udev kernel number (the partition number, empty for the entire
9 # Managing these is probably better done via a gui interface.
11 # You can edit and append the output to your /etc/udev/udev.rules file.
12 # You probably want to to change names to be non-kernel defaults, so as to
13 # avoid confusion if a configuration change modifies /sys/block/sd*
16 # /etc/scsi_id.config must be properly configured. If you are using this
17 # script, you probably want a single line enabling scsi_id for all
22 # The above assumes you will not attach block devices that do not
23 # properly support the page codes used by scsi_id, this is especially true
24 # of many USB mass storage devices (mainly flash card readers).
30 sysfs_dir=$(mount | awk '$5 == "sysfs" {print $3}')
31 if [ "$sysfs_dir" = "" ]
34 echo "Using sysfs mount point \"$sysfs_dir\"" >&2
37 c=$(ls /${sysfs_dir}/block/sd* 2>/dev/null | wc -l)
40 echo $0 no block devices present >&2
45 echo "# Start of autogenerated scsi_id rules. Edit the NAME portions of these"
46 echo "# rules to your liking."
54 id=$($scsi_id -s /block/$name)
57 echo $0 failed for device $name exiting >&2
60 if [ $first_line = "yes" ]
63 echo "BUS=\"scsi\", PROGRAM=\"${scsi_id}\", RESULT=\"${id}\", NAME=\"${prefix}${name}%n\""
65 echo "# Further RESULT keys use the result of the last PROGRAM rule."
66 echo "# Be careful not to add any rules containing PROGRAM key between here"
67 echo "# and the end of this section"
70 # No PROGRAM, so just use the last result of PROGRAM. The
71 # following is the same as the above without the PROGRAM
73 echo "BUS=\"scsi\", RESULT=\"${id}\", NAME=\"${prefix}${name}%n\""
79 echo "# End of autogenerated scsi_id rules"