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).
39 echo $0 failed for device $b >&2
45 sysfs_dir=$(mount | awk '$5 == "sysfs" {print $3}')
47 c=$(ls /${sysfs_dir}/block/sd* 2>/dev/null | wc -l)
50 echo $0 no block devices present >&2
55 echo "# Start of autogenerated scsi_id rules. Edit the NAME portions of these"
56 echo "# rules to your liking."
59 dump_ids | while read in
65 if [ $first_line = "yes" ]
68 echo "BUS=\"scsi\", PROGRAM=\"${scsi_id}\", RESULT=\"${id}\", NAME=\"${prefix}${name}%n\""
70 echo "# Further RESULT keys use the result of the last PROGRAM rule."
71 echo "# Be careful not to add any rules containing PROGRAM key between here"
72 echo "# and the end of this section"
75 # No PROGRAM, so just use the last result of PROGRAM. The
76 # following is the same as the above without the PROGRAM
78 echo "BUS=\"scsi\", RESULT=\"${id}\", NAME=\"${prefix}${name}%n\""
84 echo "# End of autogenerated scsi_id rules"