- Well, i just pulled the trigger the other day and purchased an HP Ultrium LTO-6 tape drive for my Linux box. I have a lot of media and video content I want to make permanent backups for and thought to myself "Why not a tape drive". Any ways, I have had about a week or so now of working with this thing and thought I would share a bit of my experiences so far. I am by means no expert so I am sure there are better ways of doing things, but I thought I would share a bit of gathered information here because it was just so hard to find, so here goes my story...
Well, I purchased an internal LTO-6 Ultrium tape drive with the intent on putting it into a PC instead of a server. I do have a Poweredge server but chose to put it into the PC instead. Here are some of the challenges, problem, and solutions I have seen so far with it...
I ordered the tape drive and wanted to mount it internally or perhaps in an enclosure later on, so it was recommended I get an HP H241 PCIe controller card (external SAS) for it. I found out right away that the H241 card has the wrong connectors on it. The H241 controller has SFF-8644 HD (known as SAS HD) connection ports on it and the drive came with an SFF-8087 adapter cable. After a day of searching, no one I could find carries an adapter cable to convert SFF-8087 to SFF-8644 directly. Problem number one.. I ordered the wrong adapter card. I decided to keep it though, as I since have found a solution to making this card work with this drive, but in the mean time, I ordered and installed into my PC, an HP H240 card that has the correct SFF-8087 ports on it. The HP H240 card has SF-8087 ports.
The First problem I encountered is that the adapter card wanted to overheat and was really hot to the touch. It clearly was meant for a server that had a high rate of forced air flow (like my old poweredge). I made a shroud around the card heat sink + mounted a cpu fan on it. After that, the adapter card ran cool and just fine.
Next, I installed the drive and wanted to use the terminal to do my backups and restores instead of relying on some software. Learning to get this thing to work via only terminal commands was several more days of frustrations. Because of this, I though I would share this information for others ...
The first time I booted the PC with everything installed (Ubuntu 16.04 LTS), the SAS card did its auto-setup routine, and then the PC booted just fine. The kernel had no trouble with the card or the drive but I did have to install some basic packages for operating it. Here is what I ended up installing to get it fully functional. All commands were as root user ...
Code:
apt-get install lsscsi fuse procinfo
apt-get install mtx mt-st pv mbuffer
I also had to eventually edit the '/etc/modules' file and add this to the bottom of the file on a separate line and re-boot ...
-----
I then used this command to ensure it was visible and operating ...
the reply
...
[0:0:1:0] tape HP Ultrium 6-SCSI 35GD /dev/st0
...
The device name was '/dev/st0' --- and for 2 days, I used this device name only to find out that this is actually wrong!. It drove me nuts because if you only use the 'st0' then it constantly rewinds after every command and will refuse to make more than one back on a single tape as well. I had to use the device name 'dev/nst0' adding in the 'n' to prevent it from rewinding constantly.
-------
I found out that the drive will not respond to some commands correctly unless you set an option on the drive to allow it to become a logical device. Here is that command, It has to be used every time the PC is booted up before the drive is used. Adding it to a startup file somewhere is likely a good idea...
Code:
mt -f /dev/nst0 stsetoptions scsi2logical
-------
It took me the better part of another half day to figure out how to get/show the device settings and status info from the terminal. Here are those 2 commands combined ...
Code:
tapeinfo -f /dev/nst0 ; mt -f /dev/nst0 status
here is what mine reveals...
...
Code:
Product Type: Tape Drive
Vendor ID: 'HP '
Product ID: 'Ultrium 6-SCSI '
Revision: '35GD'
Attached Changer API: No
SerialNumber: 'HUJ7308Y1E'
MinBlock: 1
MaxBlock: 16777215
SCSI ID: 1
SCSI LUN: 0
Ready: yes
BufferedMode: yes
Medium Type: Not Loaded
Density Code: 0x5a
BlockSize: 0
DataCompEnabled: yes
DataCompCapable: yes
DataDeCompEnabled: yes
CompType: 0x1
DeCompType: 0x1
Block Position: 155409288
ActivePartition: 0
EarlyWarningSize: 0
NumPartitions: 0
MaxPartitions: 3
SCSI 2 tape drive:
File number=1, block number=0, partition=0.
Tape block size 0 bytes. Density code 0x5a (no translation).
Soft error count since last status=0
General status bits on (81010000):
EOF ONLINE IM_REP
...
I could tell that compression was on by default along with other options. This information can also be used in a bash script if someone wants to monitor status, check settings, etc. - The very last line where it says 'ONLINE' is very useful for determining if the drive has a loaded tape and it and is ready for its next command.
-----
Before I get too much further along, I would like to also share more woes with installing this thing into a PC. An internal HP LTO-6 tape drive does NOT have any kind of cooling fan in it. THE DRIVE WILL OVERHEAT WHEN USING IT if forced air is not pushed through the drive (I was told a minimum of 5 cfm). I did not learn this for a day or so and the drive did strange things. It also had a hint of "burnt motor coil" smell to it on occasion. What would happen as it got hot is that during long backups, it would suddenly stop, eject the tape only partially, sit there for about 5 seconds, then load the tape back on, then continue. When it is cooled properly with forced air through the drive, it does not do this. ([tags] LTO tape partially ejects during operation, LTO drive overheating, LTO tape drive ejects during backup, LTO Ultrium ejecting randomly[/tags])
-------
Continuing on ...
Here is what I found out with this thing playing with it over the last few days. The basic premise of using a tape drive with terminal commands is to always position the tape to the beginning of the desired record number before backing up or restoring data. This means you will always need 2 commands to stay consistent at all times. A positioning command, followed by what you want to do.
- To make a backup/append a folder+files to the tape The commands are...
Code:
mt -f /dev/nst0 eod; #move tape past end of last record
tar -cvf /dev/nst0 /etc; #back up the '/etc' folder. change what folder you want as necessary.
- This will make a record and store all the files onto the tape inside that record. You can make multiple backups on one tape and refer to them by record number. The first record will always be 0 on the tape. The next will be record 1, then record 2, and so forth. I found I needed to use BOTH of these commands each time when making a backup even if backups are consecutive for things to always be in sync.
-------
- To show the folder and get a basic overview of what is stored on the tape at record number 0, you would use this command...
Code:
mt -f /dev/nst0 asf 0; #positon the tape to record number 0.
tar tvf /dev/nst0 2> /dev/null | head -n 1; #show only the first entry of the record.
...
as another example, to show record #2, it would look like this...
Code:
mt -f /dev/nst0 asf 2; #positon the tape to record number 2.
tar tvf /dev/nst0 2> /dev/null | head -n 1; #show only the first entry of the record.
-------
- To show a basic overview of all the records on the tape, I made this simple script and saved it to a file ...
Code:
mt -f /dev/nst0 stsetoptions scsi2logical
mt -f /dev/nst0 asf 0;
i=0;
while true;
r=$(tar tvf /dev/nst0 2> /dev/null | head -n 1);
! [[ -z "$r" ]] || break;
printf "\nrecord $i (block-$r) -- ";
printf "$r\n"
mt -f /dev/nst0 fsf 1;
do
((i++));
done
------
Restoring Files...
- To restore the first record (record 0) to the '/tmp' folder, you would use these commands. (the #comments are not necessary)...
Code:
cd /tmp; #change to the destination folder.
mt -f /dev/nst0 asf 0; #position the tape to record number 0.
tar xvf /dev/nst0; #extract all files to the current folder.
-------
- To generate a list of all the files within a single record (0 in this example) and save it to a file '/tmp/tape-record0.filelist.txt' , you would do something like this ...
Code:
mt -f /dev/nst0 asf 0; #positon the tape to record number 0.
tar tvf /dev/nst0 2> /dev/null > /tmp/tape-record0.filelist.txt
You can then keep file lists and records somewhere so that you can use it for searching what you want on your tapes without having to wait for them to be read.
------
- To overwrite an existing record (record #2 in this example) and back up the '/etc' folder over it ...
Code:
mt -f /dev/nst0 asf 2; #positon the tape to record number 2.
tar -cvf /dev/nst0 /etc; #back up the '/etc' folder.
NOTE: THIS WILL ERASE ALL RECORDS PAST THIS RECORD NUMBER!.
------
- Erasing the tape...
NOTE: To prevent wasting many many hours of time, DO NOT USE THE ERASE COMMAND mentioned in the 'mt' man page for linux. Once an erase command is issued to the tape drive there is no stopping it without powering down or hard resetting the unit. Not a good idea as it will constantly be moving very fast and can make the tape un-spool a bit if you do shut it off/reset it. Here is an alternative that I have found...
To do a quick-erase, simply overwrite record 0 with 'dev/null'.
Code:
mt -f /dev/nst0 asf 0; #positon the tape to record number 0.
tar -cvf /dev/nst0 /dev/null; #write a null to record 0.
------
- Finally, to rewind and eject the tape...
Code:
mt -f /dev/nst0 rewind; #rewind the tape to the beginning.
mt -f /dev/nst0 eject; #eject the tape.
----
- Hopefully this will help others out there like myself trying to get started with using one of these things. I am certainly just trying to learn it myself, and thought I would share what I have so far to save others all the wasted time I spent and hours of combing through manuals.