Udev Persistent Device Paths
Tape Drives
This document is not a guide to writing udev rules. It is only a
guide to utilizing udev persistent device paths in Arkeia Software.
The information in this document may differ from your Linux environment.
Fiber Channel and SAS device assignments can change based on the booting sequence when the bus is scanned for devices.
EXAMPLE:
Tape Drive 1 is on /dev/st0
Tape Drive 2 is on /dev/st1
When the server is rebooted, the device path assignments can change.
Tape Drive 1 is now on /dev/st1
Tape Drive 2 is now on /dev/st0
Typically Linux udev creates persistent tape drive mappings by default as part of the udev rules file.
These paths can be used in Arkeia Software to prevent the device assignment flip-flop as seen in the above example.
nst (none rewind) paths are not supported.
RHEL = /etc/udev/rules.d/50-udev.rules
SLES = /lib/udev/rules.d/60-persistent-storage-tape.rules
ls -la /dev/tape/by-id/*
lrwxrwxrwx 1 root root 10 Feb 28 07:02 /dev/tape/by-id/scsi-3500e09e00012378f-nst -> ../../nst0
lrwxrwxrwx 1 root root 9 Feb 28 07:02 /dev/tape/by-id/scsi-3500e09e00012378f-st -> ../../st0
lrwxrwxrwx 1 root root 10 Feb 28 07:02 /dev/tape/by-id/scsi-3500e09e00012378e-nst -> ../../nst1
lrwxrwxrwx 1 root root 9 Feb 28 07:02 /dev/tape/by-id/scsi-3500e09e00012378e-st -> ../../st1
Based on the output above, configure your Arkeia Tape drives to use persistent paths.
Tape Drive 1 = /dev/tape/by-id/scsi-3500e09e00012378f-st
Tape Drive 2 = /dev/tape/by-id/scsi-3500e09e00012378e-st
Warning!!! Continue ONLY if you do not have
/dev/tape/by-id paths. Modifying existing persistent udev paths may
cause corruption.
If your system does not list the persistent path to your st0 and st1
device, then you can created your own udev rule for tapes.
Located your tape drive paths using dmesg
dmesg | grep tape
st 6:0:10:0: Attached scsi tape st0
st 6:0:11:0: Attached scsi tape st1
Now use the udevadm or udevinfo command to query the devices
udevadm -a -p $(udevadm info -q path -n /dev/st0)
udevadm -a -p $(udevadm info -q path -n /dev/st1)
OR
udevinfo udevinfo -a -p /sys/class/scsi_tape/st0
udevinfo udevinfo -a -p /sys/class/scsi_tape/st1
Create the udev rules file for the tape drive persistent path as long as it does not conflict with any default udev rules.
vi /etc/udev/rules.d/99-persistent-tape.rules
# Create persistent device names "/dev/tape0 and /dev/tape1" for
# the Tape Drives which are on st0 and st1
#
# The non-persistent name is created in /dev/st*
# The info for the attributes etc to use here come from this command:
# (at the bash prompt) > udevadm -a -p $(udevadm info -q path -n /dev/stN)
# where N is an ever-changing number;
#
# These rules are based on the hardware device that is connected to the tape library
KERNEL=="sg*", SUBSYSTEM=="scsi_generic", KERNELS=="6:0:9:0", SYMLINK+="library0"
KERNEL=="st0", SUBSYSTEM=="scsi", KERNELS=="6:0:10:0", SYMLINK+="tape0", MODE="0660"
KERNEL=="st1", SUBSYSTEM=="scsi", KERNELS=="6:0:11:0", SYMLINK+="tape1", MODE="0660"
# type 8 devices are "Medium Changers"
KERNEL=="sg*", IMPORT{parent}=="ID_*"
KERNEL=="sg*", SUBSYSTEM=="scsi_generic", SYSFS{type}=="8", ENV{ID_SERIAL}=="", IMPORT{program}="scsi_id -g -u -x -s %p -d $tempnode"
KERNEL=="sg*", SUBSYSTEM=="scsi_generic", SYSFS{type}=="8", ENV{ID_SERIAL}=="", IMPORT{program}="scsi_id -g -u -x -a -s %p -d $tempnode"
KERNEL=="sg*", SUBSYSTEM=="scsi_generic", SYSFS{type}=="8", ENV{ID_SERIAL}=="?*", SYMLINK+="tape/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
# tape devices
SUBSYSTEM=="ide", SYSFS{media}=="tape", ACTION=="add", \
RUN+="modprobe $env{UDEV_MODPROBE_DBG} ide-scsi idescsi_nocd=1"
KERNEL=="st*", GROUP="disk", MODE="0660"
KERNEL=="nst*", GROUP="disk", MODE="0660"
KERNEL=="nst[0-9]*", IMPORT{parent}=="ID_*"
KERNEL=="nst[0-9]*", SUBSYSTEM=="scsi_tape", ENV{ID_SERIAL}=="", IMPORT{program}="scsi_id -u -g -x -s %p -d $tempnode"
KERNEL=="nst[0-9]*", SUBSYSTEM=="scsi_tape", ENV{ID_SERIAL}=="", IMPORT{program}="scsi_id -u -g -x -a -s %p -d $tempnode"
KERNEL=="nst[0-9]*", SUBSYSTEM=="scsi_tape", ENV{ID_SERIAL}=="?*", SYMLINK+="tape/by-id/$env{ID_BUS}-$env{ID_SERIAL}-nst"
KERNEL=="st[0-9]*", IMPORT{parent}=="ID_*"
KERNEL=="st[0-9]*", SUBSYSTEM=="scsi_tape", ENV{ID_SERIAL}=="", IMPORT{program}="scsi_id -u -g -x -s %p -d $tempnode"
KERNEL=="st[0-9]*", SUBSYSTEM=="scsi_tape", ENV{ID_SERIAL}=="", IMPORT{program}="scsi_id -u -g -x -a -s %p -d $tempnode"
KERNEL=="st[0-9]*", SUBSYSTEM=="scsi_tape", ENV{ID_SERIAL}=="?*", SYMLINK+="tape/by-id/$env{ID_BUS}-$env{ID_SERIAL}-st"
# by-path (shortest physical path)
KERNEL=="*[!0-9]|sr*", ENV{ID_TYPE}=="?*", IMPORT{program}="/lib/udev/path_id %p", SYMLINK+="disk/by-path/$env{ID_PATH}"
KERNEL=="st*", IMPORT{program}="path_id %p", SYMLINK+="tape/by-path/$env{ID_PATH}"
#####################################
# Persistent block device stuff - end
#####################################
# st/osst: 1 TYPE_TAPE
# sg: 8 changer
ACTION=="add", SUBSYSTEM=="scsi_device" RUN+="modprobe sg"
ACTION=="add", KERNEL=="sg[0-9]*", BUS=="scsi", SYSFS{type}=="8", \
SYMLINK+="changer changer-%k", MODE="0660", GROUP="disk"
ACTION=="add", SUBSYSTEM=="scsi_device", SYSFS{type}=="1", SYSFS{device/vendor}=="On[sS]tream", \
SYSFS{model}=="ADR*", RUN+="modprobe st"
ACTION=="add", SUBSYSTEM=="scsi_device", SYSFS{type}=="1", SYSFS{device/vendor}!="On[sS]tream", \
RUN+="modprobe st"
Set the parameters of the file to 644
chmod 644 /etc/udev/rules.d/99-persistent-tape.rules
Restart udev or reboot the server then check the device paths.
/etc/init.d/udev-post reload
or
reboot
Check the device paths
ls -la /dev/* |grep tape
0 lrwxrwxrwx 1 root root 3 Mar 16 14:04 /dev/tape0 -> st0
0 lrwxrwxrwx 1 root root 3 Mar 16 14:04 /dev/tape1 -> st1
ls -la /dev/tape/by-id/*
lrwxrwxrwx 1 root root 10 Mar 22 09:08 /dev/tape/by-id/scsi-3500e09e00012378f-nst -> ../../nst0
lrwxrwxrwx 1 root root 9 Mar 22 09:08 /dev/tape/by-id/scsi-3500e09e00012378f-st -> ../../st0
ls -la /dev/tape/by-path/*
lrwxrwxrwx 1 root root 9 Mar 22 09:08 /dev/tape/by-path/pci-0000:04:01.0-scsi-0:0:10:0-st -> ../../st0
lrwxrwxrwx 1 root root 10 Mar 22 09:08 /dev/tape/by-path/pci-0000:04:01.0-scsi-0:0:10:0-sta -> ../../st0a
lrwxrwxrwx 1 root root 10 Mar 22 09:08 /dev/tape/by-path/pci-0000:04:01.0-scsi-0:0:10:0-stl -> ../../st0l
lrwxrwxrwx 1 root root 10 Mar 22 09:08 /dev/tape/by-path/pci-0000:04:01.0-scsi-0:0:10:0-stm -> ../../st0m
Tape Library
Tape Libraries may not have a persistent paths created by udev.
If your HBA as a static assignment, then you can create a udev
rule which will create a persistent device path.
Located your library device path using dmesg
dmesg | grep "type 8"
scsi 4:0:0:1: Attached scsi generic sg1 type 8
Now use the udevadm command to query the device
udevadm -a -p $(udevadm info -q path -n /dev/sg1)
OR
udevinfo udevinfo -a -p /sys/class/scsi_generic/sg1
Create the udev rules file for the tape library persistent path
vi /etc/udev/rules.d/100-persistent-library.rules
# Create persistent device names "/dev/library1" for
# the Tape Library robotics interface, aka changer, aka loader.
#
# The non-persistent name is created in /dev/sg*
# The info for the attributes etc to use here come from this command:
# (at the bash prompt) > udevadm -a -p $(udevadm info -q path -n /dev/sgN)
# where N is an ever-changing number;
#
# These rules are based on the hardware device that is connected to the tape library
# hardware, ie the FC HBA which is a qlogic card living at the pci address
# that is referenced by the "KERNELS" identifier/tag.
KERNEL=="sg*", SUBSYSTEM=="scsi_generic", KERNELS=="4:0:0:1", SYMLINK+="library1"
# type 8 devices are "Medium Changers"
KERNEL=="sg*", IMPORT{parent}=="ID_*"
KERNEL=="sg*", SUBSYSTEM=="scsi_generic", SYSFS{type}=="8", ENV{ID_SERIAL}=="", IMPORT{program}="scsi_id -g -u -x -s %p -d $tempnode"
KERNEL=="sg*", SUBSYSTEM=="scsi_generic", SYSFS{type}=="8", ENV{ID_SERIAL}=="", IMPORT{program}="scsi_id -g -u -x -a -s %p -d $tempnode"
KERNEL=="sg*", SUBSYSTEM=="scsi_generic", SYSFS{type}=="8", ENV{ID_SERIAL}=="?*", SYMLINK+="tape/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
# by-path (shortest physical path)
KERNEL=="*[!0-9]|sr*", ENV{ID_TYPE}=="?*", IMPORT{program}="/lib/udev/path_id %p", SYMLINK+="disk/by-path/$env{ID_PATH}"
KERNEL=="sg*", IMPORT{program}="path_id %p", SYMLINK+="tape/by-path/$env{ID_PATH}"
#####################################
# Persistent block device stuff - end
#####################################
# sg: 8 changer
ACTION=="add", SUBSYSTEM=="scsi_device" RUN+="modprobe sg"
ACTION=="add", KERNEL=="sg[0-9]*", BUS=="scsi", SYSFS{type}=="8", \
SYMLINK+="changer changer-%k", MODE="0660", GROUP="disk"
Set the parameters of the file to 644
chmod 644 /etc/udev/rules.d/100-persistent-library.rules
Restart udev
/etc/init.d/udev-post reload
Check the device paths
ls -la /dev/tape/by-id/*
lrwxrwxrwx 1 root root 10 Mar 1 11:05 /dev/tape/by-id/scsi-DELL_TL4000_000002305301 -> ../../sg1
lrwxrwxrwx 1 root root 10 Feb 28 07:02 /dev/tape/by-id/scsi-3500e09e00012378f-nst -> ../../nst0
lrwxrwxrwx 1 root root 9 Feb 28 07:02 /dev/tape/by-id/scsi-3500e09e00012378f-st -> ../../st0
lrwxrwxrwx 1 root root 10 Feb 28 07:02 /dev/tape/by-id/scsi-3500e09e00012378e-nst -> ../../nst1
lrwxrwxrwx 1 root root 9 Feb 28 07:02 /dev/tape/by-id/scsi-3500e09e00012378e-st -> ../../st1
Based on the output above, configure your Arkeia Tape Library to use persistent paths.
Library = /dev/tape/by-id/scsi-DELL_TL4000_000002305301
OR
Library = /dev/library1