How do I configure the sg (Solaris SCSI pass-thru driver) so that sgscan shows tape drives that have a SCSI ID (target) that is greater than 15?

Version 1

    Cause: With the invention of "native fibre" tape drives like the STK 9840 it is now possible to have SCSI IDs (or SCSI targets) that are greater than 15. With fibre channel devices, it is possible to have SCSI target values up to 127.
    The NetBackup procedure in the NetBackup 3.4 Media Manager Device Configuration Guide pp.58-62 tells how to create SCSI targets up to 15 with the /usr/openv/volmgr/bin/sg.build command. However, this command does not allow the creation of scsi targets that are greater than 15.

    Solution:
    This example is for a Qlogic Controller:
    http://www.qlogic.com/support/

    Target devices with SCSI IDs greater than 15 do not show up.
    The original configuration files of Sun Solaris v2.6 and 7 / 8 only support up to 7 and 15 target devices respectively. You will need to modify a configuration file to make the OS support beyond 7 and 15 target devices respectively. To cover all the possible Fibre Channel devices the file needs to be expanded to include devices up to ID 255.
    To allow Solaris to detect up to 255 devices that are connected to the QLogic adapter, the file, /kernel/drv/sd.conf, must be modified.
    Attached at the end of this readme file is a sample sd.conf file for scanning up to SCSI target ID 255, with entries for SCSI LUNs 0 and 1 specified for the first 8 SCSI target IDs. You may use this readme file directly as the sd.conf file on your system by copying this file to the /kernel/drv directory and rename it as sd.conf. However, it is recommended to either delete or comment out the entries for the SCSI IDs which do not exist in your system/device configuration for a faster scanning process during system boot time.

    CAUTION: Entries to scan beyond SCSI target ID 255 must not be added to the sd.conf file, otherwise there may be severe problems with the system (such as system panic) after the system is rebooted.
    3. Target devices with LUN numbers other than 0 do not show up.
    For support of multiple LUNs, sd.conf located in /kernel/drv must be altered to reflect the existence of the device. Examples:
    # sd.conf:
    # The following line is added for detection of a disk with target ID 16 LUN 2.
    name="sd" class="scsi" target=16 lun=2;
    4. I made the above changes to sd.conf file but I still don't see my tape devices.
    For tape devices the st.conf file must be altered if the target ID for the tape device exceeds SCSI target ID 6 and/or the device is not at LUN 0. The entries to add to the st.conf file is in a similar fashion as those in the sd.conf file. Example:
    # st.conf:
    # The following line is added for detection of a tape device with target ID 16 LUN 2.
    # name="st" class="scsi" target=? lun=2;

    MORE INFO FROM VERITAS:
    http://seer.support.veritas.com/docs/236104.htm
    TechNote ID: 236104
    Last Updated: June 08 2001 05:35 PM GMT
    The workaround for this is to manually edit the sg driver's configuration files.

    1. The first step is to ensure the operating system (OS) can see the tape drives.
    Check the /dev/rmt/ directory with this command ls -al /dev/rmt/*cbn.
    The output should look something like this:
    lrwxrwxrwx 1 root other 45 Apr 10 12:25 0cbn -> ../../devices/pci@1f,4000/scsi@4,1/st@2,0:cbn
    lrwxrwxrwx 1 root other 45 Apr 10 12:25 1cbn -> ../../devices/pci@1f,4000/scsi@4,1/st@3,0:cbn
    lrwxrwxrwx 1 root other 45 Apr 10 12:25 2cbn -> ../../devices/pci@1f,4000/scsi@4,1/st@13,1:cbn
    lrwxrwxrwx 1 root other 45 Apr 10 12:25 3cbn -> ../../devices/pci@1f,4000/scsi@4,1/st@20,0:cbn
    Note: The strings st@2,0 st@3,0 st@13,1 and st@20,0 at the end of the device paths. These are the scsi target and lun values.
    Also Note: The target and lun values for "st@?,?" are in hexadecimal format, NOT decimal.
    /dev/rmt/0cbn has target 2 and lun 0 (st@2,0).
    /dev/rmt/1cbn has target 3 and lun 0 (st@3,0).
    /dev/rmt/2cbn has target 19 and lun 1 (st@13,0).
    /dev/rmt/3cbn has target 32 and lun 0 (st@20,0).

    Go through the list of tape drives that the server sees and write down the target and lun values for each /dev/rmt/*cbn device.

    2. If there are tape drives missing from the /dev/rmt/ device files then the /kernel/drv/st.conf file needs to be edited.
    The first step is to determine what scsi target and luns the tape drives are set for.
    The next step is to edit the st.conf file so that it has a listing for each target and lun combination that the tape drives have.
    For example: if there is a tape drive with target 19 and lun 0 then this line needs to be in the st.conf file
    name="st" class="scsi" target=19 lun=0;
    Another example: if there is a tape drive with target 58 and lun 1 then this line needs to be in the st.conf file
    name="st" class="scsi" target=58 lun=1;
    After all the updates are made to the /kernel/drv/st.conf file the device trees need to be rebuilt. Do this with the command
    reboot -- -r.

    3. Once the scsi target and lun values are know for each tape drive then it's time to edit the sg driver configuration files.
    First edit the /usr/openv/volmgr/bin/driver/sg.conf file to add the needed target and lun entries.
    For example: if there is a tape drive with target 19 and lun 0 then this line needs to be in the st.conf file
    name="sg" class="scsi" target=19 lun=0;
    For example: if there is a tape drive with target 58 and lun 1 then this line needs to be in the st.conf file
    name="sg" class="scsi" target=58 lun=1;

    Next edit the /usr/openv/volmgr/bin/driver/sg.links file to add the needed target and lun entries.
    For example: if there is a tape drive with target 19 and lun 0 then this line needs to be in the st.conf file
    type=ddi_pseudo;name=sg;addr=13,0; sg/c\N0t19l0
    For example: if there is a tape drive with target 58 and lun 1 then this line needs to be in the st.conf file
    type=ddi_pseudo;name=sg;addr=3A,1; sg/c\N0t58l1
    Note: The values for the addr= string are in hexadecimal, but the values for sg/c\N0t19l0 are in decimal.
    Note2: The format of this line if very important. The two parts of this line need to be separated by a tab, not spaces (i.e. type=ddi_pseudo;name=sg;addr=3A,1;
    sg/c\N0t58l1).

    4. After the sg.conf and sg.links files are edited, they need to be moved into place with the /usr/openv/volmgr/bin/sg.install script.
    The sg.install script will reload the sg driver. It was also copy /usr/openv/volmgr/bin/driver/sg.conf to /kernel/drv/sg.conf.
    If there is an existing /kernel/drv/sg.conf file, sg.install will not copy the new file out there.
    Thus it is important to remove or rename the existing /kernel/drv/sg.conf file before running sg.install.

    The script sg.install also concatenates the entries in /usr/openv/volmgr/bin/driver/sg.links to the end of the Solaris device links file /etc/devlink.tab.
    It is recommended to remove any previous sg device link entries in the /etc/devlink.tab file before running sg.install.


    5. If setting up persistent binding for tape drives in /kernel/drv/st.conf then it is also necessary to setup entries for the persistent binding of the tape drives to the world wide names (wwn) in the /kernel/drv/sg.conf file too.
    For example: If you have some native-fibre tape drives with targets 60-62 do this:
    A. Make sure the /kernel/drv/st.conf file has persistent binding setup for the tape drives.
    name="st" class="scsi" hba="fcaw0" wwn="500104F000426D0A" target=60 lun=0;
    name="st" class="scsi" hba="fcaw0" wwn="500104F00043E20C" target=61 lun=0;
    name="st" class="scsi" hba="fcaw0" wwn="500104F00043A45C" target=62 lun=0;

    B. Edit the /kernel/drv/sg.conf file to setup persistent device binding for these tape drives.
    name="sg" class="scsi" hba="fcaw0" wwn="500104F000426D0A" target=60 lun=0;
    name="sg" class="scsi" hba="fcaw0" wwn="500104F00043E20C" target=61 lun=0;
    name="sg" class="scsi" hba="fcaw0" wwn="500104F00043A45C" target=62 lun=0;

    C. Make sure the /etc/devlink.tab file is setup correctly.
    type=ddi_pseudo;name=sg;addr=3C,0; sg/c\N0t60l0
    type=ddi_pseudo;name=sg;addr=3D,0; sg/c\N0t61l0
    type=ddi_pseudo;name=sg;addr=3E,0; sg/c\N0t62l0

    D. If any changes are made to these three files then it is necessary to rebuild the device tree with a reboot -- -r or rm /dev/rmt/*; rm /dev/sg/*; drvconfig; tapes; devlinks.
    When sg.install is run, it reloads the sg driver and puts the new sg configuration files in place.
    The key to make any configuration changes to sg.conf or devlink.tab permanent is to edit the files /usr/openv/volmgr/bin/driver/sg.conf and /usr/openv/volmgr/bin/driver/sg.links so that they will be copied into place whenever sg.install is run.


    Conclusion:
    Currently there are only a few native-fibre tape drives (including the STK 9840FC and the LTO tape drives like the IBM 3580-LTO and the HP SureStore Ultrium 230-LTO).
    These native-fibre device can support scsi target values that are greater than the scsi target limit of 15.
    To take advantage of this extended scsi target limit it is necessary to configure the st (scsi tape) driver, the sg (SCSI pass-thru) driver, and the device links files so that the sg driver will see these devices with the higher scsi targets.