Linux Tape Backup: Difference between revisions

From Dave-Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(30 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[File:Powervault114x.jpg|800px]]
=Linux Drivers=
=Linux Drivers=


==LSI SAS2008==
==LSI SAS2008==


My first obstacle was getting the drive to show up in Linux. Apparently RHEL/CentOS decided to stop putting LSI SAS2008 (SAS9200-8e) drivers in the distro, starting with RHEL/CentOS8. Here's some more info: [https://access.redhat.com/discussions/3722151 https://access.redhat.com/discussions/3722151] Also a helpful vid: [https://www.youtube.com/watch?v=4fOAuXiynYM https://www.youtube.com/watch?v=4fOAuXiynYM]
'''LSI SAS 9200-8e 6Gbs PCI Express SAS Host Bus Adapter'''


I was able to get the correct drivers for my LSI SAS9200-8e 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/ 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).
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 https://access.redhat.com/discussions/3722151] Also a helpful vid: [https://www.youtube.com/watch?v=4fOAuXiynYM https://www.youtube.com/watch?v=4fOAuXiynYM]


Also, FWIW, I'm using a Quantum Ultrium LTO 4 (Model B) SAS Tape Drive attached to a LSI SAS9200-8e. I'm using a fresh install of CentOS Stream 8 on a Dell PowerEdge R730xd.
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/ 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).


==LSI SAS3008 / Dell 12Gbps HBA==
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.


I have since switched to a LSI SAS3008 PCI-Express Fusion-MPT SAS-3 (branded as a Dell 0T93GD 12G SAS HBA Low Profile Dual Port Host Bus Adapter) and the card just worked out of the box with RHEL 9.3. I'm still using the Quantum Ultrium LTO 4 (Model B) SAS Tape Drive, mounted in a 2U Dell PowerVault 114X enclosure.
==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 also now using an IBM Half-High LTO 5 SAS Tape Drive, mounted in a 2U Dell PowerVault 114X enclosure (left drive in picture at top of page; the Quantum is not connected yet in this setup), which is connected to my Dell PowerEdge R730xd storage server.


=Using The Tape Drive In Linux=
=Using The Tape Drive In Linux=


The main program you will use is call "mt". You can install it by running <code>sudo yum install mt-st</code>.
<pre>
      <-------------------TAPE-------------------------->
 
+----------+------------------+----------+--------------------+
|          |                  |          |                    |
|  tar #0  |      tar #1      |  tar #2  |      Empty        |
|          |                  |          |                    |
+----------+------------------+----------+--------------------+
 
Data is stored sequentially on a tape using tar. The first tape archive will start at the physical beginning of the tape: tar #0, tar #1, etc.
</pre>
 
The main program we will use is called '''mt'''. You can install it with <code>sudo yum install mt-st</code> (or equivalent command for your distro).


<code>/dev/st0</code> rewinds tape after being written to
==Device Names==


<code>/dev/nst0</code> don't rewind tape after being written to
The device name you utilize affects behavior after command executions:


*Citation: https://forums.fedoraforum.org/showthread.php?59746-SCSI-Tape-Drive*
;<code>/dev/st0</code>: rewinds tape after being written to
 
;<code>/dev/nst0</code>: don't rewind tape after being written to
 
''More info: [https://forums.fedoraforum.org/showthread.php?59746-SCSI-Tape-Drive https://forums.fedoraforum.org/showthread.php?59746-SCSI-Tape-Drive]''
 
==Main Operations==
 
===Check usage and capacity of a tape===
 
<code>sg_logs -a /dev/nst0 | grep -E "native\ capacity"</code>
 
===Write directory to blank tape===
 
Make sure you are at the beginning of the tape:
 
<code>mt -f /dev/nst0 rewind</code>
 
Write directory to tape:
 
<code>tar -C /directory/to/backup/ -cvf /dev/nst0 . | tee /home/file-listing-0.txt</code>
 
''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===
 
Make sure you have enough space left on the tape!
 
Fast-forward to beginning of next new file:
 
<code>mt -f /dev/nst0 asf <newfile#></code>
 
Write directory to tape, excluding files already written previously:
 
<code>tar -C /mnt/hdd/os/ -cvf /dev/nst0 --exclude-from=/home/file-listing-0.txt . | tee /home/file-listing-1.txt</code>
 
===Restore an individual file===
 
Fast-forward to the tar file that contains the file you want:
 
<code>mt -f /dev/nst0 asf <file#></code>
 
Extract the file to the PWD:
 
<code>tar xvf /dev/nst0 "filename.ext"</code>
 
OR Extract the file to a specified directory:
 
<code>tar xvf /dev/nst0 "filename.ext" -C \some\dir</code>
 
==Other Useful Operations==


===Check if tape is online===
===Check if tape is online===
Line 27: Line 95:
<code>mt -f /dev/st0 status</code>
<code>mt -f /dev/st0 status</code>


A cartdrige is inserted and ready to write. Because we used /dev/st0, the tape is now positioned at the beginning.
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.


===List The First file===
===List The First file===
Line 44: Line 112:


File numbers start at zero (0).
File numbers start at zero (0).
===Write Directory To Tape, At Current Position===
<code>tar cvf /dev/nst0 {directory}</code>
or, you can also write the file list to a file so you have a record of files:
<code>tar cvf /dev/nst0 {directory} | tee {listing.txt}</code>


===Rewind The Tape===
===Rewind The Tape===
Line 61: Line 121:
Make sure you move to the tar file you want, first
Make sure you move to the tar file you want, first


<code>tar tf /dev/nst0</code>
<code>tar tvf /dev/nst0</code>


or, you can also write the file list to a file so you have a record of files:
or, you can also write the file list to a file so you have a record of files:


<code>tar tf /dev/nst0 | tee {listing.txt}</code>
<code>tar tvf /dev/nst0 | tee {listing.txt}</code>

Latest revision as of 00:37, 6 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 also now using an IBM Half-High LTO 5 SAS Tape Drive, mounted in a 2U Dell PowerVault 114X enclosure (left drive in picture at top of page; the Quantum is not connected yet in this setup), which is connected to my Dell PowerEdge R730xd storage server.

Using The Tape Drive In Linux

      <-------------------TAPE-------------------------->

+----------+------------------+----------+--------------------+
|          |                  |          |                    |
|  tar #0  |      tar #1      |  tar #2  |       Empty        |
|          |                  |          |                    |
+----------+------------------+----------+--------------------+

Data is stored sequentially on a tape using tar. The first tape archive will start at the physical beginning of the tape: tar #0, tar #1, etc.

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

Check usage and capacity of a tape

sg_logs -a /dev/nst0 | grep -E "native\ capacity"

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

Make sure you have enough space left on the tape!

Fast-forward to beginning of next new file:

mt -f /dev/nst0 asf <newfile#>

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.

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}