7

I just installed an Exabyte tape drive:

$ lsscsi -g
[11:0:0:0]   process Marvell  91xx Config      1.01  -          /dev/sg0 
[12:0:1:0]   cd/dvd  TOSHIBA  CD-ROM XM-3401TA 0283  /dev/sr0   /dev/sg1 
[12:0:5:0]   tape    EXABYTE  EXB-8500-85Qanx0 046G  /dev/st0   /dev/sg2 
[N:1:4:1]    disk    Samsung SSD 970 EVO 250GB__1               /dev/nvme1n1
[N:0:4:1]    disk    Samsung SSD 970 EVO 250GB__1               /dev/nvme0n1
$   /usr/sbin/tapeinfo -f /dev/sg2  
Product Type: Tape Drive
Vendor ID: 'EXABYTE '
Product ID: 'EXB-8500-85Qanx0'
Revision: '046G'
Attached Changer API: No
SerialNumber: '02541381  '
MinBlock: 1
MaxBlock: 245760
SCSI ID: 5
SCSI LUN: 0
Ready: yes
WriteProtect: yes
BufferedMode: yes
Medium Type: 0x85
Density Code: 0x0
BlockSize: 1024
DataCompEnabled: no
DataCompCapable: no
DataDeCompEnabled: no
CompType: 0x0
DeCompType: 0x0
Block Position: 15750
ActivePartition: 0
EarlyWarningSize: 0

I can read from a tape like this:

$ mt -f /dev/nst0 rewind
$ /usr/sbin/scsitape -f /dev/sg2 read 0  > outfile.bin
$ tar tf outfile.bin
[ a list of files in the tar archive ]

However, I cannot read from the tape with tar in the normal way:

$ mt -f /dev/nst0 rewind
$ tar tf /dev/nst0 
tar: /dev/nst0: Cannot read: Input/output error
tar: At beginning of tape, quitting now
tar: Error is not recoverable: exiting now

In /var/log/messages we see:

Jun 29 13:11:00 horizon kernel: [ 9362.244683] Errata on LSI53C1030 occurredsc->req_bufflen=0x2800, xfer_cnt=0x400,difftransfer=0x0a
Jun 29 13:11:00 horizon kernel: [ 9362.244773] st 12:0:5:0: [st0] Sense Key : Medium Error [current] 
Jun 29 13:11:00 horizon kernel: [ 9362.244790] st 12:0:5:0: [st0] <<vendor>>ASC=0xff <<vendor>>ASCQ=0xff 

Reducing the read size (for example with tar -f /dev/nst0 -b 1 --record-size=512 -t) doesn't seem to make a difference.

The mechanisms are quite different; scsitape read uses ioctl against /dev/sg2 to read from the tape device, while tar uses read syscalls against /dev/nst0 or /dev/st0 to read.

But I don't know why access via /dev/sg2 works while access via /dev/nst0 does not. Can anybody explain this?

In case it matters, the mt-st package is not installed and so there is no /etc/stinit.def file. I'm using the mt binary that comes with the cpio package.

1 Answer 1

13

It turns out that the tape was written with a fixed block size, and using the mt command from the mt-st package allows us to accommodate this:

$ mt -f /dev/nst0 rewind
$ mt -f /dev/nst0 setblk 10240
$ tar  -f /dev/nst0  -t
[ files list normally ]

10240 here corresponds to 20 blocks of 512 bytes (20 is the traditional and default blocking factor for tar).

This isn't possible with the mt binary in the cpio package because it lacks the setblk command.

1
  • 4
    Presumably dd bs=10240 would also work. Jun 29, 2021 at 21:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .