[Last Call] Learn how to a build a cloud-first strategyRegister Now


Tar and Tapes - -Problems Extracting and Getting a Listing of Files

Posted on 2006-05-30
Medium Priority
Last Modified: 2009-07-29
I'm working on what I thought was something pretty basic:

- Tar a file to a mounted tape drive
- Get a listing of the files on the tape drive
- Extract the file just tarred from the tape drive

I can get the file, I think tarred to the tape drive since when I do a

mt -f /dev/nst0 status

I the file count increments.

Beyond that, I'm lost. None of the following works:

tar -tvf /dev/nst0
tar -tv /dev/nst0
tar -xvf /dev/nst0
tar -xv  /dev/nst0
tar -xvf /dev/nst0 *

Here's an example of the command and the errors I'm getting:
tar -tvf /dev/nst0
tar: /dev/nst0: Cannot read: Input/output error
tar: At beginning of tape, quitting now
tar: Error is not recoverable: exiting now

sudo tar -xvf /dev/nst0 test1
tar: /dev/nst0: Cannot read: Input/output error
tar: At beginning of tape, quitting now
tar: Error is not recoverable: exiting now

tar -xvf /dev/nst0
[yields nothing]

This works fine:

tar -cvf /dev/nst0 test1                                            

Question by:kls1
  • 3
  • 3
LVL 48

Expert Comment

ID: 16794216
nst0 is the no rewind device.  This allows you to add multiple backups to a single tape.  Is that what you are doing?

What does

tar tvf /dev/st0


Do you rewind the tape before tarring up the files?

Sounds like what you really want is:

tar cvf /dev/st0 test1
tar tvf /dev/st0
tar xvf /dev/st0

Author Comment

ID: 16798995
I have it to the point to where I can actually get it to add/archive a directory, show a listing, and extract *one* set of files. But, the file counter always shows 0.  

mt -f /dev/st0 status
SCSI 2 tape drive:
File number=0, block number=0, partition=0.
Tape block size 0 bytes. Density code 0x42 (no translation).
Soft error count since last status=0
General status bits on (41010000):

What might I be doing to prevent me from adding more than one archive? (It copies over the previous one when I add a new one) I tried

mt -f /dev/st0 fsf 1

It doesn't seem to change anything.

For a tvf:

tar tvf /dev/st0
drwxr-xr-x jjj/users      0 2006-05-31 08:23:00 test5/
-rw-r--r-- jjj/usersf    15 2006-05-31 08:23:00 test5/temp2
-rw-r--r-- jjj/users     15 2006-05-31 08:23:00 test5/temp1
-rw-r--r-- jjj/users     15 2006-05-31 08:23:00 test5/temp3
-rw-r--r-- jjj/users     15 2006-05-31 08:23:00 test5/temp4


LVL 48

Accepted Solution

Tintin earned 2000 total points
ID: 16804634
To skip to a another section of the tape, you *must* use the no rewind device.

Generally, you'd do the following steps

mt -f /dev/st0 rewind
mt -f /dev/nst0 fsf 1
tar tvf /dev/nst0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!


Author Comment

ID: 16806818
Ok, so it sounds like what is confusing me is when to use the no-rewind device and when not to.

So do I understand correctly that using st0 as the device name will automatically rewind the tape after any operation. Whereas using nst0 will not?

I notice that you use st0 in the first command you list, but nst0 for the remaining. Why do you use st0 in the first command? Would it matter which device name you used in the first command?
LVL 48

Expert Comment

ID: 16812166
You are correct in your summation of st0 and nst0

Strictly speaking, doing

mt -f /dev/st0 rewind

is a bit redundant as you rightly point out st0 is the rewind device, so any operations on it will rewind the tape.  However, it makes it very clear as to what you are doing, so it doesn't hurt.

Author Comment

ID: 16819546
Ok, sounds great -- thanks!

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses
Course of the Month17 days, 16 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question