[comp.sys.sun] Copying SunOS distribution tapes

MIKE@UCDHEP.BITNET (10/12/89)

I manage six Sun computers in the Physics Dept. on this campus.  The
department benefits from an umbrella license obtained by the University
for Sun systems.  I.e., the campus has a license for SunOS for several
hundred systems, and individual licenses are given out on a
first-come-first-served basis.

Unfortunately for me, most Sun systems on this campus have 1/4" tape
drives, so our standard distribution tapes from Sun come in this format.
I say this is unfortunate because this department has only a 1/2",
9-track, reel-to-reel tape drive.  Hence, when a new version of SunOS
becomes available, I have to request the loan of a tape from the local Sun
sales office.

While the Sun sales people are cooperative, it still takes from one to
several days for me to get the tape.  If, for example, I need to boot Unix
from a distribution tape, in order to restore a damaged root filesystem, I
need the tape immediately, not in a day or two.

Hence, I'd like to do what seems to me to be the obvious thing, namely,
just copy the 1/4" tape to a 1/2" tape compatible with my drive.  I've
asked people around here who are more knowledgeable than I about SunOS if
that were possible.  The general sense of the replies is ``it's possible
in principle but not easy to do'', for reasons which are vague, at least
to me.

It seems that this shouldn't be a hard problem: read physical records from
the tape on a system with a 1/4" drive, store uninterpreted on disk, copy
the disk files to the system with the 1/2" drive, and write physical
records to the tape.  (Disk space could, of course, be a problem.)

So what is the opinion of the Sun Spots community?  Can I do this?  Any
opinions, conjectures, advice, RTFM's, etc., will be greatly appreciated.

Mike Hannon                              mike@ucdhep     (Bitnet)
ucdhep::mike          (HEPnet)           42385::mike     (HEPnet)
jmhannon@ucdavis.edu  (Internet)         916-752-4966    (Telephone)

len@rufus.bitnet (Len Evens) (10/14/89)

We also have to copy tapes because of a University wide update arrangement
in which the University gets one set of tapes for everyone.

To copy a Sun OS distribution tape, just copy all the records to disk and
then copy them back to the other  tape.   If you have lots of disk space
you can do it a tape at a time, otherwise you will have to do it one
record at a time.   The only problem I encountered was that dd couldn't
seem to get past an end of record mark on the tape so that the obvious
scheme for copying from the tape to disk did not work.  Hence, for each
record it was  necessary to rewind the tape and skip over the previously
read records to read the next  record.   This led to an  arithmetic
progression for time  so that the  time went like N squared where N is the
number of records.   Here are shell scripts I used for the second of two
tapes for the 4.0.3 update.

For  reading a 1/4 in tape  (tape 2 of the distribution).

#!/bin/sh
for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
do
mt -f /dev/nrst8 fsf $i
dd bs=1024 </dev/nrst8 1>/home/len/tape/tape2/file$i 2>>/home/len/tape/tape2/r
mt -f /dev/rst8 rew
done

For writing to a 1/4 in tape.

#!/bin/sh
for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
do
dd bs=1024 < /home/len/tape/tape2/file$i 1>/dev/nrst8 2>>/home/len/tape/tape2/w
done
mt -f /dev/rst8 rew

One problem in using this scheme is that you have to know the number of
records on each tape you are reading.   Fortunately, this is in the second
record on the Sun distribution tape.  You use the program
/usr/etc/install/xdrtoc to read it.   You can copy that record from the
tape (as above) but pipe the result to xdrtoc.  Also, if you don't get all
the records the first time, you  read the next ones just  by changing the
numbers since you are rewinding the tape each time anyway. 

There is a tape copying routine which may work if you have two tape drives
on one machine.   However, I couldn't get it to work with a local  1/4 in
drive and a remote 1/4 in drive another machine.  I think it may only work
with reel to reel  1/2 in tapes.

Leonard Evens                      len@math.nwu.edu
Department of Mathematics 
Northwestern University
Evanston, IL 60208
312-491-5537

mkatz@sesame.stanford.edu (Morris Katz) (10/16/89)

In article <2099@brazos.Rice.edu>, MIKE@UCDHEP writes:
>Hence, I'd like to do what seems to me to be the obvious thing, namely,
>just copy the 1/4" tape to a 1/2" tape compatible with my drive.  I've
>asked people around here who are more knowledgeable than I about SunOS if
>that were possible.  The general sense of the replies is ``it's possible
>in principle but not easy to do'', for reasons which are vague, at least
>to me.
>
>Mike Hannon                              mike@ucdhep     (Bitnet)
>ucdhep::mike          (HEPnet)           42385::mike     (HEPnet)
>jmhannon@ucdavis.edu  (Internet)         916-752-4966    (Telephone)

The problem is that the distribution tapes come with a directory at the
begining that lists their contents.  This directory is used by the
installation software.  Since the different size tapes are of different
length, one cannot just blindly copy the bits from one tape to another and
have things work since splitting one tape over several tapes will cause
the directory to be incorrect and cause problems.  I have never tried it,
but the last time I looked, the directory was just in ascii, so I imagine
that one can build the correct directory by hand and store it at the
begining of each tape.  In the past, the documentation has specified what
files are located on each real of the distribnution tapes of each type.

P.S.  I suspect that it is easiest just to get a loaned copy of the tapes
from sun and copy them.  Sun has a disk to tape/tape to disk copy program
that makes this easy.  Try and cajole you local sales rep into giving you
a copy.

-- Morry Katz

dav@uunet.uu.net (David L. Markowitz) (10/25/89)

mkatz@sesame.stanford.edu (Morris Katz) writes:
>In article <2099@brazos.Rice.edu>, MIKE@UCDHEP writes:
>>Hence, I'd like to do what seems to me to be the obvious thing, namely,
>>just copy the 1/4" tape to a 1/2" tape compatible with my drive.  I've
>>asked people around here who are more knowledgeable than I about SunOS if
>>that were possible.  The general sense of the replies is ``it's possible
>>in principle but not easy to do'', for reasons which are vague, at least
>>to me.

The main reason it is difficult is because of the limitations of the 1/4"
drives.  Any other direction is easy: 1/2" -> 1/2", 1/2" -> 1/4", and 1/4"
-> 1/4".  The limitation involved is based on the fact that the
information on a 1/2" tape consists of more than just the byte stream you
cann read from it.  Also of great importance is the record size.

[ Note: The following information is deducible by reading between the
lines of mtio(4) at least twice. ]

When read a 1/2" tape, you must read a large enough record to get all the
data: anything left will be discarded.  If you request too much you will
get only as much as is in the current record.  Subsequent reads will get
subsequent data records.

On the other hand, a 1/4" drive stores ONLY 512-byte records, and fakes
bigger records (multiples of 512) by returning as many records as are
needed to satisfy the request.  Reads of non-512 byte multiples are an
error.

What this means is that on a 1/2" tape you can tell that the tape has
three records of size 512, 2048, and 1024 bytes in that order (by reading
64K bytes three times and checking the return value from read()), but on a
1/4" tape there is no way to tell!

Because of that, you can't copy a 1/2" tape to a 1/4" tape without knowing
the structure ahead of time.  This info can't be deduced from the tape.
Sun's distribution tapes consist of many files with many, variable record
sizes (but always a multiple of 512).  In particular, the first file on
tape 1 (the "boot" program) starts with a 512 byte record and is followed
by many 2048 byte records.  Why?  I don't know.  Third base.

It then becomes obvious that a properly written copy program can copy 1/2"
-> 1/2" (record size deducible), 1/2" -> 1/4" (record size deducible and
unnecessary)), and 1/4" -> 1/4" (record size irrelevant).  I have written
such a beast.  It can copy over a network, too.

>The problem is that the distribution tapes come with a directory at the
>begining that lists their contents.  This directory is used by the
>installation software.  Since the different size tapes are of different
>length, one cannot just blindly copy the bits from one tape to another and
>have things work since splitting one tape over several tapes will cause
>the directory to be incorrect and cause problems.

This is also true, but I have never had problems copying a 60 MB tape to a
145 MB tape.  Just waste the excess, or use a 1200' tape.  If a 1600 bpi
tape is needed, that should fit too (Sun uses 450' 1/4" tapes so they
never have >45 MB).

>I have never tried it,
>but the last time I looked, the directory was just in ascii, so I imagine
>that one can build the correct directory by hand and store it at the
>begining of each tape.

Under 4.0 the directory is stored in XDR format.  Still massagable, but a
much tougher job.

>P.S.  I suspect that it is easiest just to get a loaned copy of the tapes
>from sun and copy them.  Sun has a disk to tape/tape to disk copy program
>that makes this easy.  Try and cajole you local sales rep into giving you
>a copy.

This program is a consulting special (tcopy can't handle this either).
Mine copies tape to tape (no disk space required, but you need two tape
drives on one network).  Borrow the 1/2" tapes and copy them.