Procedures for creating TAR files and writing them to tape

por | 23 marzo, 2009

# Change directories (cd) to the desired directory from which tarring will be done.
cd /home/… (whatever)

# To tar all the files in the current directory (.) and sub-directories
# to the tape using medium density (m) and no rewind (n)
tar -cvf /dev/rmt/0mn .

# To tar all the files in the current directory (.) and sub-directories
# to the tape using medium density (m) and, yes, rewind
tar -cvf /dev/rmt/0m .

# To do the same and write the list of the tarred files out to a file
# called TAR_LIST
tar -cvf /dev/rmt/0m . > TAR_LIST

# To view the table of contents from the first tar on the tape
# and then rewind the tape
tar -tvf /dev/rmt/0

# To view the table of contents from the tar at the current location
# on the tape and then NOT rewind the tape (subsequent calls to
# tar -tvf will access the subsequent tars on the tape)
tar -tvf /dev/rmt/0n
tar -tvf /dev/rmt/0n

# To extract a file (e.g., «my_file») from the tar into the current
# directory (All existing files of the same name are over-written)
tar -xvf /dev/rmt/0 ./my_file

# To extract all the files under a directory (e.g., «sumatra») from the tar
# into the current directory (All existing files of the same name are
# over-written). Give the full path to the directory on the tape
tar -xvf /dev/rmt/0 ./jones/proj/sumatra

# To rewind the tape
mt -f /dev/rmt/0 rew

# To advance past the current tar (0=first, 1=second, etc)
mt -f /dev/rmt/0n fsf 1

# Don’t use the following (i.e., without the ‘n’) or else the
# tape will advance forward then rewind
mt -f /dev/rmt/0 fsf 1

# Absolute space to «count» file number. This is equivalent
# to a rewind followed by a fsf «count». Using 2 will position
# the pointer to the start of the third tar on the tape.
mt -f /dev/rmt/0 asf 2

# To backspace to the beginning of the tar in front of, uh, where
# the tape is currently sitting (using ‘…/0n bsf 1’ leaves the
# tape at its current location)
mt -f /dev/rmt/0n bsf 2

# To go to the end of the last tar on the tape and stay there
mt -f /dev/rmt/0n eom

# To see the tape status (and current file number)
# (Careful: if you use /0 and not /0n the tape will rewind
# following the status report)
mt -f /dev/rmt/0n status

# Using the above command the following is the report given at the
# start of the tape, i.e., file no = 0
# Exabyte EXB-8500 8mm Helical Scan tape drive:
# sense key(0x0)= No Additional Sense residual= 0 retries= 0
# file no= 0 block no= 0

# To determine the number of tars on the tape (number of tars
# is the value at ‘file no = ‘)
mt -f /dev/rmt/0 eom
mt -f /dev/rmt/0 status

# To erase all the tars on the tape
mt -f /dev/rmt/0 erase

# To retension the tape
mt -f /dev/rmt/0 retension

# For more goodies
man tar
man mt