Link to home
Start Free TrialLog in
Avatar of PongBuddy
PongBuddyFlag for Canada

asked on

Extract just the volume name from an LTO tar archive

I create tar archives with the "-V <volume name>" flag.  When I do a 'tar -t', the volume name is the first record, which is then followed by the listing of the rest of the files on the tape.

I want to list that first record (without necessarily knowing the record's name) and stop the listing there.  I've tried the '--occurrence 1' argument, but tar doesn't stop after retrieving the 1st record... it scans through the rest of the tape.

There's got to be a way to tell tar to extract the first record from an archive and stop, no?

Maybe something with:
--checkpoint=1 --checkpoint-action=??

CentOS 5.4

TIA
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

tctl -f /dev/rmt0 -b 80 -B read


tctl -f /dev/rmt0 rewind
dd if=/dev/rmt0 bs=80 count=2
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PongBuddy

ASKER

Found it.

If your tar volume header is created using a consistent pattern (I use LTO-####-###), you can find it with this command:

tar -t -n --occurrence=1 -f ./archive_name.tar 'LTO*' (Multiple wildcards are supported, eg. 'LTO-*-*' also works)

This causes tar to list the first matching record (the header) and exit.

Tested in Tar 2:1.15.1-23.0.1.el5
woolmilkporc's solution works if the correct version of tar (1.24) is installed.  I'd like to award the points to him.
I had to install the newest tar (1.24) for --test-label to work.