Operating System - HP-UX
1820592 Members
1694 Online
109626 Solutions
New Discussion юеВ

Reading header and trailer records from the tape

 
Henry_52
Advisor

Reading header and trailer records from the tape

Hello,

How can I get the header and trailer records (80 characters each) from the tape.
Please let me know.

Thank you.

Henry
6 REPLIES 6
A. Clay Stephenson
Acclaimed Contributor

Re: Reading header and trailer records from the tape

By making use of the norewind device nodes - I suggest that you use the Berkeley style no-rewind devices.

e.g.

dd if=/dev/rmt/1mnb bs=80 of=header1

Next read the file itself with the appropriate blocksize; if you don't know the blocksize it doesn't matter as long as you don't need the data itself. Typically the record size and blocking is part of the header. In any event you need to read until the next file mark and then read the trailer (if it exists).

e.g
dd if=/dev/rmt/1mnb bs=5120 of=data1

dd if=/dev/rmt/1mnb bs=80 of=trailer1
If it ain't broke, I can fix that.
Rodney Hills
Honored Contributor

Re: Reading header and trailer records from the tape

You can also skip to a file mark with the "mt" command-

mt -t /dev/rmt/1mnb fsf 1

will forward space 1 file.

HTH

-- Rod Hills
There be dragons...
Henry_52
Advisor

Re: Reading header and trailer records from the tape

Thank you for your replies.
I tried to read header and trailer blocks using above commands but I saw same results.
Actually, I don't understand exactly about your replies because I don't have enough knowledge about tape. If I want to read header or trailer blocks, Do I have to move to header or trailer blocks and read it ?
Please let me know detail information.

Thank you.

Best Regards,

Henry
Sundar_7
Honored Contributor

Re: Reading header and trailer records from the tape

You need to know the size of the file/data in the tape to be able to extract the trailer.

# dd if=/dev/rmt/0mn of=/tmp/header bs=80b count=1

# dd if=/dev/rmt/0mn of=/tmp/trailer skip=NNNm bs=80b count=1

where NNN is the size of the data/file on the tape.

Say, if you have a 2 GB file on the tape

# mt -t /dev/rmt/0mn rew
# dd if=/dev/rmt/0mn of=/tmp/header bs=80b count=1
# dd if=/dev/rmt/0mn of=/tmp/trailer skip=2096992b bs=80b count=1
Learn What to do ,How to do and more importantly When to do ?
Henry_52
Advisor

Re: Reading header and trailer records from the tape

Hi Sundar,

Thank you for your reply.
If I use bs and skip options, is it block size or byte ?

I restored first tape to disk.
And I checked restored total file size
using du command.

$du -s
12553744 .

So I think total file size is 12553744 blocks.

Please check below command.(If b means byte, I'll have to change to byte.)

# dd if=/dev/rmt/1m of=/trailer skip=12553744b bs=80b count=1


Henry
Victor BERRIDGE
Honored Contributor

Re: Reading header and trailer records from the tape

Hi Henry,

The way I see it, is you have a true tape? not DAT which is formated for mainframe purpose, if this is so you havent said all...
I believe you have a tape generated with a header 80 char then follows DATA of XXXchar and ends with trailer record of 80char
unless the data records are of 80 characters
the Solution:
you will have to use a no rewind device and use dd 3 times:
rewind the tape:
mt -t /dev/rmt/1mn rew

then load in 3 separate files the content of the tape file:

dd of=/tmp/file.header if=/dev/rmt/1mn ibs=80 obs=80
dd of=/tmp/file.data if=/dev/rmt/1mn ibs= obs=
dd of=/tmp/file.trail if=/dev/rmt/1m ibs=80 obs=80

Notice at the end the difference on tape device so it will rewind at the end...

All the best
Victor