Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Jun 2011 18:13:48 +0200
From:      Alfred Bartsch <bartsch@dssgmbh.de>
To:        paul+usenet@w6yx.stanford.edu
Cc:        freebsd-scsi@freebsd.org
Subject:   Re: making a predictable passX name
Message-ID:  <4E04B7BC.6010707@dssgmbh.de>
In-Reply-To: <iu28kp$dvg$1@hairball.ziemba.us>
References:  <iu28kp$dvg$1@hairball.ziemba.us>

next in thread | previous in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 24.06.2011 16:57, schrieb G. Paul Ziemba:
> Is there a way to set up a constant name for a /dev/passX
> device? (Or maybe there is a better way to solve the problem)
> 
>     % uname -r
>     8.2-PRERELEASE
> 
>     % pkg_info | grep amanda-server
>     amanda-server-3.2.1,1 The Advanced Maryland Automatic Network Disk Archiver (serv)
> 
> I'm setting up a Dell Powervault 122T with LTO2 drive to operate
> with amanda. I seems to me that chg-robot is the best choice of
> changer.
> 
> chg-robot uses mtx, which seems to require the name of the /dev/passX
> device corresponding to the changer (attached as /dev/ch0).
> Therefore, I'm trying to create a link with a constant name
> that points to the arbitrary /dev/passX name. I plan to use this
> constant name in the amanda config file.
> 
> I can manually run "camcontrol periphlist ch0" and obtain the
> matching pass device name, so in theory I can write a small
> script to create a link such as /dev/ch0.pass -> /dev/passX
> and then specify /dev/ch0.pass in the amanda config file.
> 
> I wrote the following in /etc/devd.conf:
> 
>     attach 100 {
> 	device-name "ch[0-9]+";
> 	action "camcontrol periphlist $device-name|grep pass|sed -e 's/:.*\$//'|xargs -I PASS ln -s /dev/PASS /dev/$device-name.pass; logger added ch pass link";
>     };
> 
>     detach 100 {
> 	device-name "ch[0-9]+";
> 	action "rm /dev/$device-name.pass; logger removed ch pass link";
>     };
> 
> I also tried the above with just the "logger" parts in the actions.
> 
> However, the actions do not seem to be invoked when the ch0 device
> is attached (power-on + camcontrol rescan + messages in /var/log/messages).
> Maybe devd does not get an "attach" event when ch attaches?
> 
> Is there another way to trigger on the attach/detach events for /dev/chX?
> Or a way to hard-wire assignment of the /dev/passX names?
> 

You can achieve this behaviour via editing /boot/device.hints:

...
# SCSI tape peripherals
#
hint.scbus.0.at="mpt0"
hint.scbus.0.bus="0"
#
# Drive
hint.sa.0.at="scbus0"
hint.sa.0.target="4"
hint.sa.0.lun="0"
hint.pass.0.at="scbus0"
hint.pass.0.target="4"
hint.pass.0.lun="0"
# Changer
hint.ch.0.at="scbus0"
hint.ch.0.target="4"
hint.ch.0.lun="1"
hint.pass.1.at="scbus0"
hint.pass.1.target="4"
hint.pass.1.lun="1"
#

all You have to know is:
- - the SCSI driver (in our case mpt) with its associated bus number (0)
- - target and lun of drive and changer
it is then possible to freely choose a pass device number, in this example:

SCSI_ID 0:4:0 gets pass0 (drive), SCSI_ID 0:4:1 gets pass1 (changer)

changes take effect after reboot, HTH.

- -- 
Alfred Bartsch
Data-Service GmbH
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk4Et7wACgkQ5QGe2JdVf3gsrwCguAGB3JaOB2OQA6BQbstwgnaE
K8YAn0F+m+S1UN6SR6WlMuPqxQmtktyi
=WyTG
-----END PGP SIGNATURE-----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4E04B7BC.6010707>