To initialize the drive, you want to:
stinit
To rewind the tape, do
mt -f /dev/nst0 rewind
To write data to it, do
tar cvf /dev/nst0 archive2/
To read data, do
tar xvf /dev/nst0
[root@kazi restore]# mt -f /dev/nst0 rewind
[root@kazi restore]# mt -f /dev/nst0 tell
At block 0.
[root@kazi restore]# tar -tf /dev/nst0
archive1/
archive1/1.MTS
[root@kazi restore]# mt -f /dev/nst0 tell
At block 22168.
[root@kazi restore]# tar -tf /dev/nst0
archive2/
archive2/2.MTS
[root@kazi restore]# mt -f /dev/nst0 tell
At block 44336.
Now rewinding
[root@kazi restore]# mt -f /dev/nst0 bsf 1
[root@kazi restore]# mt -f /dev/nst0 tell
At block 44335.
[root@kazi restore]# mt -f /dev/nst0 bsf 1
[root@kazi restore]# mt -f /dev/nst0 tell
At block 22167.
[root@kazi restore]# mt -f /dev/nst0 fsf 1
[root@kazi restore]# mt -f /dev/nst0 tell
At block 22168.
[root@kazi restore]# tar -tf /dev/nst0
archive2/
archive2/2.MTS
So if you are at the end of the drive:
[root@kazi restore]# mt -f /dev/nst0 bsf 2
[root@kazi restore]# mt -f /dev/nst0 fsf 1
[root@kazi restore]# mt -f /dev/nst0 tell
At block 22168.
System V semantics
[root@kazi ~]# tar cvf /dev/nst0 archive1
archive1/
archive1/1.MTS
[root@kazi ~]# tar cvf /dev/nst0 archive2
archive2/
archive2/2.MTS
[root@kazi ~]# tar cvf /dev/nst0 archive3
archive3/
archive3/3.MTS
[root@kazi ~]# mt -f /dev/nst0 tell
At block 66504.
[root@kazi ~]# mt -f /dev/nst0 rewind
[root@kazi restore]# tar xvf /dev/nst0
archive1/
archive1/1.MTS
[root@kazi restore]# mt -f /dev/nst0 tell
At block 22168.
[root@kazi restore]# tar xvf /dev/nst0
archive2/
archive2/2.MTS
[root@kazi restore]# mt -f /dev/nst0 tell
At block 44336.
[root@kazi restore]# tar xvf /dev/nst0
archive3/
archive3/3.MTS
[root@kazi restore]# mt -f /dev/nst0 tell
At block 66504.
Timing:
time tar cvf /dev/nst0 /data/tape1/
...
real 57m7.877s
user 1m16.384s
sys 9m57.844s
[root@kazi restore]# #time tar cvf /dev/nst0 /data/tape1/
[root@kazi restore]# du -shc /data/tape1/
265G /data/tape1/
265G total
Doing it again:
real 54m32.163s
user 1m13.405s
sys 9m55.750s
[root@kazi ~]# time tar cvf /dev/nst0 /data/tape1/
Restore
real 62m12.270s
user 1m22.551s
sys 19m14.131s
[root@kazi restore]# time tar -xvf /dev/nst0
Get some stats:
[ormester@kazi ITDT]$ sudo sg_logs -a /dev/nst0 | less
Another useful link:
https://darkimmortal.com/adventures-with-lto-tape-for-home-casual-use/
Let's try to rewind
The maintained source code for mt-st is here: https://github.com/iustin/mt-st
To initialise it we'll need an stinit.def file
https://wiki.debian.org/StinitDef
My tape drive looks like this:
[ormester@kazi ~]$ sudo lsscsi
[0:0:0:0] tape IBM ULTRIUM-HH5 F991 /dev/st0
[1:2:0:0] disk DELL PERC H710 3.13 /dev/sda
[1:2:1:0] disk DELL PERC H710 3.13 /dev/sdb
The used config is /etc/stinit.def
- which was taken from here: https://wiki.debian.org/StinitDef#LTO5
manufacturer="IBM" model = "ULTRIUM-HH5" {
scsi2logical=1
can-bsr=1
auto-lock=1
two-fms=0
drive-buffering=1
buffer-writes
read-ahead=1
async-writes=1
can-partitions=1
fast-mteom=0
sysv=1
#
# If your stinit supports the timeouts:
timeout=180 # 3 minutes
long-timeout=14400 # 4 hours
#
mode1 blocksize=0 compression=0 # 1500 GB, LTO5 _NO_ compression
mode2 blocksize=0 compression=1 # 3000 GB, LTO5 compresses
mode3 disabled=1
mode4 disabled=1
}
Having said that, I found some entries who were suggesting slightly different config, which has a slight difference
sysv=0
sili=1
instead of
sysv=1
What that means is
sili=value
If value is non-zero, the SILI bit is set when reading in variable block mode. This may speed up reading blocks shorter than the read byte count. Set this only if you know that the drive supports SILI and the HBA reliably returns transfer residual byte counts. Requires kernel version >= 2.6.26.
And the other setting
sysv=value
The System V tape semantics are used if value is non-zero. Otherwise the BSD semantics are used.
More about it here: https://www.kernel.org/doc/html/latest/scsi/st.html#bsd-and-sys-v-semantics9
The user can choose between these two behaviours of the tape driver by defining the value of the symbol ST_SYSV. The semantics differ when a file being read is closed. The BSD semantics leaves the tape where it currently is whereas the SYS V semantics moves the tape past the next filemark unless the filemark has just been crossed.
Initialization of the drive was performed by:
Bacula was helpful: https://www.bacula.org/5.2.x-manuals/en/problems/problems/Testing_Your_Tape_Drive.html
Also this one: https://wiki.zmanda.com/index.php/Tape_Driver_Semantics
https://www.techtarget.com/searchdatabackup/definition/shoeshining-or-backhitching
The command:
tar -b 4096 -cvf - agica-hdd/ | mbuffer -m 4G -L -P 95 -f | dd of=/dev/nst0 bs=2M iflag=fullblock
[root@kazi tape1]# find -mindepth 1 -type d -exec sh -c "cd {}; md5sum * > md5sums.txt" \;
sg_logs -a /dev/nst0 > tepe1.sglogs
When extracting, Use this:
tar -b 4096 -xvf /dev/nst0
You need to set the buffer size, otherwise you are getting weird and scary error messages: