Chapter 18. Managing tape devices
A tape device is a magnetic tape where data is stored and accessed sequentially. Data is written to this tape device with the help of a tape drive. There is no need to create a file system in order to store data on a tape device. Tape drives can be connected to a host computer with various interfaces like, SCSI, FC, USB, SATA, and other interfaces.
The following are the different types of tape devices:
-
/dev/st
is a rewinding tape device. -
/dev/nst
is a non-rewinding tape device. Use non-rewinding devices for daily backups.
Advantages of tape devices:
- Cost efficient
- Resilient against data corruption
- Data retention
- Stable
18.1. Installing tape drive management tool
Use the mt
command to wind the data back and forth. The mt
utility controls magnetic tape drive operations and the st
utility is used for SCSI tape driver. This procedure describes how to install the mt-st
package for tape drive operations.
Procedure
Install the
mt-st
package:# yum install mt-st
Additional resources
-
The
mt
man page. -
The
st
man page.
18.2. Writing to tape devices
This procedure describes how to back up data using the tar
command. By default, block size
is 10KB (bs=10k
) in tape devices. The -f
device option specifies the tape device file, but this option is not required if you have set the TAPE
environment variable using the export TAPE=/dev/st0
attribute.
Prerequisites
-
The
mt-st
package is installed. For more information, see Section 18.1, “Installing tape drive management tool”. Load the tape drive:
# mt -f /dev/st0 load
Procedure
Check the tape head:
# mt -f /dev/st0 status SCSI 2 tape drive: File number=-1, block number=-1, partition=0. Tape block size 0 bytes. Density code 0x0 (default). Soft error count since last status=0 General status bits on (50000): DR_OPEN IM_REP_EN
Here:
-
the current
file number
is -1. -
the
block number
defines the tape head. By default, it is set to -1. -
the
block size
0 indicates that the tape device does not have a fixed block size. -
the
Soft error count
indicates the number of encountered errors after executing the mt status command. -
the
General status bits
explains the stats of the tape device. -
DR_OPEN
indicates that the door is open and the tape device is empty.IM_REP_EN
is the immediate report mode.
-
the current
If the tape device is not empty, specify the tape head:
# mt -f /dev/st0 rewind # tar -czf /dev/st0 /etc
This command overwrites the data on a tape device with the content of the /etc directory
Optional: To append the data on the tape device:
# mt -f /dev/st0 eod
Back up the /etc directory to the tape device:
# tar -czf /dev/st0 /etc tar: Removing leading `/' from member names /etc/ /etc/man_db.conf /etc/DIR_COLORS /etc/rsyslog.conf [...]
View the status of the tape device:
# mt -f /dev/st0 status
Verification steps
View the list of all files on the tape device:
# tar -tzf /dev/st0 /etc/ /etc/man_db.conf /etc/DIR_COLORS /etc/rsyslog.conf [...]
Additional resources
-
The
mt
man page. -
The
tar
man page. -
The
st
man page. - Tape drive media detected as write protected Red Hat Knowlegebase article.
- How to check if tape drives are detected in the system Red Hat Knowlegebase article.
18.3. Switching tape head in tape devices
Use the following procedure to switch the tape head in the tape device. While appending the data to tape devices, use the eod
option to switch the tape head.
Prerequisites
-
The
mt-st
package is installed. For more information, see Section 18.1, “Installing tape drive management tool”. - Data is written to the tape device. Fore more information, see Section 18.2, “Writing to tape devices”.
Procedure
To go to the end of the data:
# mt -f /dev/st0 eod
To go to the previous record:
# mt -f /dev/st0 bsfm 1
To go to the forward record:
# mt -f /dev/st0 fsf 1
Additional resources
-
The
mt
man page.
18.4. Restoring data from tape devices
To restore data from a tape device, use the tar
command.
Prerequisites
-
The
mt-st
package is installed. For more information, see Section 18.1, “Installing tape drive management tool”. - Data is written to the tape device. Fore more information, see Section 18.2, “Writing to tape devices”.
Procedure
Rewind the tape device:
# mt -f /dev/st0 rewind
Restore the /etc directory:
# tar -xzf /dev/st0 /etc
Additional resources
-
The
mt
man page. -
The
tar
man page.
18.5. Erasing data from tape devices
To erase data from a tape device, use the erase
option.
Prerequisites
-
The
mt-st
package is installed. For more information, see Section 18.1, “Installing tape drive management tool”. - Data is written to the tape device. Fore more information, see Section 18.2, “Writing to tape devices”.
Procedure
Erase data from the tape device:
# mt -f /dev/st0 erase
Unload the tape device:
mt -f /dev/st0 offline
Additional resources
-
The
mt
man page.
18.6. Tape commands
The following are the common mt
commands:
Table 18.1. mt commands
Command | Description |
---|---|
| Displays the status of the tape device. |
| Rewinds the tape device. |
| Erases the entire tape. |
| Switches the tape head to the forward record. Here, n is an optional file count. If a file count is specified, tape head skips n records. |
| Switches the tape head to the previous record. |
| Switches the tape head to the end of the data. |