Tape drive error issues on write/erase

I have an SAS LTO-3 tape drive I’m trying to use but I keep getting errors when trying to perform operations with the drive. Before any of this, I did insert a cleaning cartridge and the drive performed self-cleaning with it.

# ls -alh /dev/tape/by-id/
total 0
drwxr-xr-x. 2 root root 120 Mar  8 08:29 .
drwxr-xr-x. 4 root root  80 Mar  8 08:29 ..
lrwxrwxrwx. 1 root root   9 Mar  8 08:29 scsi-3500110a00125746a -> ../../st0
lrwxrwxrwx. 1 root root  10 Mar  8 08:29 scsi-3500110a00125746a-nst -> ../../nst0
lrwxrwxrwx. 1 root root   9 Mar  8 08:29 scsi-HU1084836A -> ../../st0
lrwxrwxrwx. 1 root root  10 Mar  8 08:29 scsi-HU1084836A-nst -> ../../nst0

Drive Status after inserting a tape cartridge:

# mt -f /dev/st0 status
SCSI 2 tape drive:
File number=0, block number=0, partition=0.
Tape block size 0 bytes. Density code 0x44 (LTO-3).
Soft error count since last status=0
General status bits on (41010000):
 BOT ONLINE IM_REP_EN

I see I’m at the beginning of tape (BOT and the tape is loaded (ONLINE). The tape is clean and has never had anything written to it. So I attempt to write to it:

# tar -cvpf /dev/nst0 --label="Backup `date '+%Y%M%d'`" /etc
Backup 20251208
tar: Removing leading `/' from member names
/etc/
/etc/favicon.png
/etc/grub2-efi.cfg
/etc/grub2.cfg
/etc/issue
.......
.......
/etc/passwd
/etc/kdump.conf
/etc/ld.so.cache
tar: /dev/nst0: Cannot close: Input/output error
tar: Exiting with failure status due to previous errors

That doesn’t look good. Well I rewind it and try to erase it just in case. I heard the drive moving on the rewind…seems good. But on erase:

# mt -f /dev/nst0 rewind
# mt -f /dev/nst0 erase
/dev/nst0: Input/output error

Maybe erase using the /dev/st0 handle?

# mt -f /dev/st0 erase
/dev/st0: Input/output error

Same error! Checking the drive status for both device handles:

# mt -f /dev/nst0 status
SCSI 2 tape drive:
File number=0, block number=0, partition=0.
Tape block size 0 bytes. Density code 0x44 (LTO-3).
Soft error count since last status=0
General status bits on (41010000):
 BOT ONLINE IM_REP_EN

# mt -f /dev/st0 status
SCSI 2 tape drive:
File number=0, block number=0, partition=0.
Tape block size 0 bytes. Density code 0x44 (LTO-3).
Soft error count since last status=0
General status bits on (41010000):
 BOT ONLINE IM_REP_EN

The drive status looks OK and as I would expect after a rewind. But something is going on with erases and writes with tar. After some googling, I saw recommendations to set the block size with mt. Some more searching revealed that I should try 256KB for LTO-3 technology.

# mt -f /dev/st0 setblk 262144
root@tundra:~# mt -f /dev/st0 status
SCSI 2 tape drive:
File number=0, block number=0, partition=0.
Tape block size 262144 bytes. Density code 0x44 (LTO-3).
Soft error count since last status=0
General status bits on (41010000):
 BOT ONLINE IM_REP_EN

OK, block size is now set, file number is 0, block number is 0, try again?

# tar -cvpf /dev/st0 --label="Backup `date '+%Y%M%d'`" /etc
Backup 20253808
tar: Removing leading `/' from member names
/etc/
/etc/favicon.png
/etc/grub2-efi.cfg
/etc/grub2.cfg
/etc/issue
/etc/issue.net
/etc/opensc-x86_64.conf
/etc/resolv.conf
/etc/.java/
/etc/.java/.systemPrefs/
/etc/ImageMagick-7/
/etc/ImageMagick-7/colors.xml
/etc/ImageMagick-7/log.xml
tar: /dev/st0: Cannot write: Invalid argument
tar: Error is not recoverable: exiting now

Now it doesn’t even process all of the tiles but bails after just a few. Welcome any ideas or suggestions for troubleshooting!

Here are some errors from the last write attempt with tar from the kernel buffer:

[80602.396884] st 6:0:5:0: Attached scsi tape st0
[80602.396896] st 6:0:5:0: st0: try direct i/o: yes (alignment 4 B)
[80602.397082] st 6:0:5:0: Attached scsi generic sg3 type 1
[80602.399429]  end_device-6:5: add: handle(0x0009), sas_addr(0x500110a001257468)
[81418.147826] st 6:0:5:0: [st0] Block limits 1 - 16777215 bytes.
[81493.407191] st 6:0:5:0: device_block, handle(0x0009)
[81493.407322] st 6:0:5:0: [st0] Error e0000 (driver bt 0, host bt 0xe).
[81493.407335] st 6:0:5:0: [st0] Error on write filemark.
[81494.906911] st 6:0:5:0: device_unblock and setting to running, handle(0x0009)
[81494.907042] st 6:0:5:0: [st0] Error 10000 (driver bt 0, host bt 0x1).
[81494.910738] mpt2sas_cm0: mpt3sas_transport_port_remove: removed: sas_addr(0x500110a001257468)
[81494.910750] mpt2sas_cm0: removing handle(0x0009), sas_addr(0x500110a001257468)
[81494.910756] mpt2sas_cm0: enclosure logical id(0x500605b0079b23a0), slot(3)
[81497.908381] mpt2sas_cm0: handle(0x9) sas_address(0x500110a001257468) port_type(0x1)
[81497.910877] scsi 6:0:6:0: Sequential-Access HP       Ultrium 3-SCSI   Q24D PQ: 0 ANSI: 5
[81497.910897] scsi 6:0:6:0: SSP: handle(0x0009), sas_addr(0x500110a001257468), phy(3), device_name(0x0000000000000000)
[81497.910905] scsi 6:0:6:0: enclosure logical id (0x500605b0079b23a0), slot(3) 
[81497.910913] scsi 6:0:6:0: qdepth(254), tagged(1), scsi_level(6), cmd_que(1)
[81497.911296] scsi 6:0:6:0: Power-on or device reset occurred
[81497.912617] scsi 6:0:6:0: TLR Disabled

The [81493.407335] st 6:0:5:0: [st0] Error on write filemark. part perhaps is interesting. Will do more searching…

I’ve never messed with it, but did you find the stinit man page? It appears to suggest that you should run something like the following first.

$ sed -n '\!# HP StorageWorks Ultrium 960/920 SAS LTO-3!,\!}$! { p; }' /usr/share/doc/mt-st/stinit.def.examples | sudo tee /etc/stinit.def
$ sudo stinit

BTW, there is also the following note about the erase command in the mt man page.

       erase  Erase the tape. Note that this is a long erase, which on modern (high-capacity) tapes can take many  hours,  and
              which usually can't be aborted.

See also: The SCSI Tape Driver — The Linux Kernel documentation


Edit: Also, not sure if it is necessary, but it looks like you can “reset” the device with the following

# echo "- - -" > /sys/class/scsi_host/host6/scan

You’ll need to run the above as root (possibly every time you change the tape) and host6 was derived from your earlier dmesg output.

source: /usr/share/doc/mt-st/README.md

1 Like

Thanks for this tip, I was not aware of stinit but I did get running, and it looks like my drive already had a config that I was able to use. I’m still not able to get the drive to read/write, but I hear movement. I suspect it must be some configuration or initialization perhaps that needs to be done first? Appreciate your post, I think I’m going in the right direction now. I’m going to see if Bacula works with my setup and hopefully find something in the logs that tips me on how to init and use my device.

There is an interesting note here:

Try to find an mt that supports all of the Linux SCSI tape ioctls and opens the device for writing if the tape contents will be modified (look for a package mt-st* from the Linux ftp sites; the GNU mt does not open for writing for, e.g., erase).

I’m not sure what to make of what that is saying.


The source for the mt program is here: GitHub - iustin/mt-st: Magnetic tape control tools for Linux SCSI tapes

Since you haven’t received any responses from anyone “knowledgeable” here, you might try filling an issue report in that issue tracker.


There are a few commands documented here that might be helpful (mt -f /dev/st0 stsetoption debug, etc.).