Linux Tape Backup: Difference between revisions
Line 17: | Line 17: | ||
'''Dell 12Gbps HBA / LSI SAS 9300-8e 12Gbs PCI Express SAS Host Bus Adapter''' | '''Dell 12Gbps HBA / LSI SAS 9300-8e 12Gbs PCI Express SAS Host Bus Adapter''' | ||
I have since switched to a LSI SAS3008 PCI-Express Fusion-MPT SAS-3 (branded as a Dell 0T93GD 12G SAS Low Profile Dual Port HBA) and the card just worked out of the box with RHEL 9.3 (it is using the built-in mpt3sas kernel driver). I'm still using the Quantum Ultrium LTO 4 (Model B) SAS Tape Drive, mounted in a 2U Dell PowerVault 114X enclosure. | I have since switched to a LSI SAS3008 PCI-Express Fusion-MPT SAS-3 (branded as a Dell 0T93GD 12G SAS Low Profile Dual Port HBA) and the card just worked out of the box with RHEL 9.3 (it is using the built-in mpt3sas kernel driver). I'm still using the Quantum Ultrium LTO 4 (Model B) SAS Tape Drive, mounted in a 2U Dell PowerVault 114X enclosure (left drive in picture at top of page). | ||
=Using The Tape Drive In Linux= | =Using The Tape Drive In Linux= |
Revision as of 22:41, 1 June 2024
Linux Drivers
LSI SAS2008
LSI SAS 9200-8e 6Gbs PCI Express SAS Host Bus Adapter
My first obstacle was getting the drive to show up in Linux. Apparently RHEL/CentOS decided to stop putting LSI SAS2008 drivers in the distro, starting with RHEL/CentOS8. Here's some more info: https://access.redhat.com/discussions/3722151 Also a helpful vid: https://www.youtube.com/watch?v=4fOAuXiynYM
I was able to get the correct drivers for my LSI SAS2008 using the driver that matched my kernel (CentOS Stream 8/4.18.0-448.el8.x86_6) here: http://mirror.centos.org/centos/8-stream/kmods/x86_64/packages-rebuild/Packages/k/ (I used kmod-mlx4-4.18.0~448-1.el8s.x86_64.rpm).
Also, FWIW, I'm using a Quantum Ultrium LTO 4 (Model B) SAS Tape Drive attached to the LSI SAS9200-8e. I'm using a fresh install of CentOS Stream 8 on a Dell PowerEdge R730xd.
LSI SAS3008
Dell 12Gbps HBA / LSI SAS 9300-8e 12Gbs PCI Express SAS Host Bus Adapter
I have since switched to a LSI SAS3008 PCI-Express Fusion-MPT SAS-3 (branded as a Dell 0T93GD 12G SAS Low Profile Dual Port HBA) and the card just worked out of the box with RHEL 9.3 (it is using the built-in mpt3sas kernel driver). I'm still using the Quantum Ultrium LTO 4 (Model B) SAS Tape Drive, mounted in a 2U Dell PowerVault 114X enclosure (left drive in picture at top of page).
Using The Tape Drive In Linux
The main program we will use is called mt. You can install it with sudo yum install mt-st
(or equivalent command for your distro).
Device Names
The device name you utilize affects behavior after command executions:
/dev/st0
- rewinds tape after being written to
/dev/nst0
- don't rewind tape after being written to
More info: https://forums.fedoraforum.org/showthread.php?59746-SCSI-Tape-Drive
Main Operations
Write directory to blank tape
Make sure you are at the beginning of the tape:
mt -f /dev/nst0 rewind
Write directory to tape:
tar -C /directory/to/backup/ -cvf /dev/nst0 . | tee /home/file-listing-0.txt
You can omit the piped tee command if you don't want to save a listing of files. Not sure why you'd do that though...
Append directory to existing tape
Fast-forward to beginning of next new file:
mt -f /dev/nst0 asf <file#>
Write directory to tape, excluding files already written previously:
tar -C /mnt/hdd/os/ -cvf /dev/nst0 --exclude-from=/home/file-listing-0.txt . | tee /home/file-listing-1.txt
Restore an individual file
Fast-forward to the tar file that contains the file you want:
mt -f /dev/nst0 asf <file#>
Extract the file to the PWD:
tar xvf /dev/nst0 "filename.ext"
OR Extract the file to a specified directory:
tar xvf /dev/nst0 "filename.ext" -C \some\dir
Other Useful Operations
Check if tape is online
mt -f /dev/st0 status
A cartridge is inserted and ready to write. Because we used /dev/st0, the tape rewound itself after executing the command, and is now positioned at the beginning.
Check usage and capacity of a tape
sg_logs -a /dev/nst0 | grep -E "native\ capacity"
List The First file
file - < /dev/nst0
Example Output: blah
Forward Tape To Next File
mt -f /dev/nst0 fsf 1
Seek To A File On The Tape
mt -f /dev/nst0 asf {file_number}
File numbers start at zero (0).
Rewind The Tape
mt -f /dev/nst0 rewind
List The Files In The Current Tar File
Make sure you move to the tar file you want, first
tar tvf /dev/nst0
or, you can also write the file list to a file so you have a record of files:
tar tvf /dev/nst0 | tee {listing.txt}