I tried creating a new rules file based on the existing tape rules but I
didn't have any luck making it work and I didn't know how to debug what I'd
done.  I ended up creating this bash script to create the symlinks and it
worked so I think I'll call it good:

*#!/bin/bash*

*#create persistent device paths for tape drive control devices*

*n=($(ls /dev | grep sg[0123456789]))*

*for i in "${n[@]}"*
*    do*
*    model=($(/lib/udev/scsi_id --page=0x80 --whitelisted /dev/$i))*
*    if [ "$model" == "SIBM" ]; then*
*        serial=($(/lib/udev/scsi_id --page=0x83 --whitelisted /dev/$i))*
*        ln -s /dev/$i /dev/tape/by-id/scsi-$serial-sg*
*    fi*
*done*

A udev rule would be nice because it could work for a lot of users using
different hardware but I've run out of patience.  This script can be
adapted for other hardware simply by changing the "SIBM" model to the
output of the" scsi_id --page=0x80" command for a different model drive.

Thanks,
Nate


On Sun, Jan 27, 2019 at 9:14 PM Nate K <nate...@gmail.com> wrote:

> This is the rules file, I will have to spend some time going through it.
> Thanks.
>
> *> cat /lib/udev/rules.d/60-persistent-storage-tape.rules*
> *# do not edit this file, it will be overwritten on update*
>
> *# persistent storage links: /dev/tape/{by-id,by-path}*
>
> *ACTION=="remove", GOTO="persistent_storage_tape_end"*
> *ENV{UDEV_DISABLE_PERSISTENT_STORAGE_RULES_FLAG}=="1",
> GOTO="persistent_storage_tape_end"*
>
> *# type 8 devices are "Medium Changers"*
> *SUBSYSTEM=="scsi_generic", SUBSYSTEMS=="scsi", ATTRS{type}=="8",
> IMPORT{program}="scsi_id --sg-version=3 --export --whitelisted -d
> $devnode", \*
> *  SYMLINK+="tape/by-id/scsi-$env{ID_SERIAL}"*
>
> *SUBSYSTEM!="scsi_tape", GOTO="persistent_storage_tape_end"*
>
> *KERNEL=="st*[0-9]|nst*[0-9]", ATTRS{ieee1394_id}=="?*",
> ENV{ID_SERIAL}="$attr{ieee1394_id}", ENV{ID_BUS}="ieee1394"*
> *KERNEL=="st*[0-9]|nst*[0-9]", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb",
> IMPORT{builtin}="usb_id"*
> *KERNEL=="st*[0-9]|nst*[0-9]", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi",
> KERNELS=="[0-9]*:*[0-9]", ENV{.BSG_DEV}="$root/bsg/$id"*
> *KERNEL=="st*[0-9]|nst*[0-9]", ENV{ID_SERIAL}!="?*",
> IMPORT{program}="scsi_id --whitelisted --export --device=$env{.BSG_DEV}",
> ENV{ID_BUS}="scsi"*
> *KERNEL=="st*[0-9]",  ENV{ID_SERIAL}=="?*",
> SYMLINK+="tape/by-id/$env{ID_BUS}-$env{ID_SERIAL}"*
> *KERNEL=="nst*[0-9]", ENV{ID_SERIAL}=="?*",
> SYMLINK+="tape/by-id/$env{ID_BUS}-$env{ID_SERIAL}-nst"*
>
> *# by-path (parent device path)*
> *KERNEL=="st*[0-9]|nst*[0-9]", IMPORT{builtin}="path_id"*
> *KERNEL=="st*[0-9]", ENV{ID_PATH}=="?*",
> SYMLINK+="tape/by-path/$env{ID_PATH}"*
> *KERNEL=="nst*[0-9]", ENV{ID_PATH}=="?*",
> SYMLINK+="tape/by-path/$env{ID_PATH}-nst"*
>
> *LABEL="persistent_storage_tape_end"*
>
>
> On Sun, Jan 27, 2019 at 3:14 AM Adam Nielsen <a.niel...@shikadi.net>
> wrote:
>
>> > There are symlinks for the archive devices but not the tape drive
>> control
>> > devices which is what the tape alert commands need.
>>
>> Ah I see, you need the /dev/sg* equivalent for the /dev/st* in use.
>>
>> Can you copy the udev rules that produce symlinks for the autochangers
>> (see link in my last post) and tweak them so that they also work for the
>> drives themselves?  It looks like they pick up anything that's a
>> "type 8" device so if you duplicate the rule but change it to whatever
>> type number that tape drives are, presumably you'd end up with the same
>> result.
>>
>> > My only other idea is that maybe you could create a script that rewrites
>> > the bacula-sd.conf every boot by parsing the output of this command as
>> it
>> > shows which sg* devices correspond to the st* ones:
>>
>> If you wanted to do that it might be easier to have the script
>> create/update symlinks in /dev so you don't need to rewrite the Bacula
>> config file.  But this is pretty much what udev does already so better
>> to get that working if you can.
>>
>> Cheers,
>> Adam.
>>
>
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to