Specifications
Chapter 2. Tapes (SCSI and awstape) 17
tape utility functions, such as scsi2tape, tape2scsi, and also by Linux utilities such as tar
and mt. The /dev/stN and /dev/nstN interfaces are not used with the awsscsi device manager.
The /dev/sgN devices are general SCSI devices and the awsscsi device manager uses the
/dev/sgN interfaces.
3
Unfortunately, the N value for a given device is typically not the same in
the stN and the sgN forms. All Linux SCSI devices are assigned sgN numbers, and Linux
treats many of its normal devices as SCSI (even if they are not really hardware SCSI
devices).
4
The first (and only) tape drive on a Linux system would be /dev/st0 but it might be
/dev/sg7, for example.
The easiest way to determine what the sg device number represents is to list
/proc/scsi/scsi. For example:
$ cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00 (this is sg0)
Vendor: IBM Model: root Rev: V1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Id: 00 Lun: 00 (this is sg1)
Vendor: IBM Model: 03592E05 Rev: 1C91
Type: Sequential-Access ANSI SCSI revision: 03
This example shows two SCSI devices (a disk and a tape) which would correspond to
/dev/sg0 and /dev/sg1. In this case, /dev/sg1 is the device you would specify for the awsscsi
device manager, but any Linux utility would use /dev/st0 or /dev/nst0 for the same tape drive.
The devices listed in /proc/scsi/scsi are in sgN order; sg0 is first, sg1 is second, sg2 is third,
and so forth.
There is another issue with both /dev/stN and /dev/sgN devices: the permission bits must
allow usage by zPDT. Some Linux systems allow general user access to /dev/stN devices by
default; no Linux systems allow general access to /dev/sgN devices by default. You must
change the permissions to allow general access to your device. For example:
$ ls -al /dev/sg*
crw-r----- 1 root disk 21, 0 2008-09-03 14:44 /dev/sg0
crw-rw---- 1 root tape 23, 0,2008-99-03 14:44 /dev/sg1
$ su
(enter root password)
# chmod 666 /dev/sg1
# exit
$ ls -al /dev/sg*
crw-r----- 1 root disk 21, 0 2008-09-03 14:44 /dev/sg0
crw-rw-rw-+1 root tape 23, 0,2008-99-03 14:44 /dev/sg1
In this example, we changed the permissions for /dev/sg1 so that everyone (including zPDT)
can read and write to it. This change (by manually entering chmod) is lost when Linux is
rebooted, but is suitable for many situations. Always verify the correct sgN number first, by
listing /proc/scsi/scsi.
A more permanent change can be made by modifying Linux boot functions. Unfortunately,
there are two problems with this:
3
The reason is that the /dev/stN interface does not accept the full SCSI command set that is needed for some tape
operations. The /dev/sgN interface allows all SCSI tape commands to be passed to the tape drive.
4
The sg numbers are assigned in ascending order by bus and by device on the bus. However, since Linux treats a
number of non-SCSI devices as though they were SCSI, these bus and device numbers are difficult to predict in
advance.










