[comp.unix.questions] tape copy and disk format questions

braun@drivax.UUCP (Karl T. Braun (kral)) (04/27/89)

I submitted a couple of questions this month to ca.unix.  I don't know if my
questions are particularly dumb, particularly difficult, or if noone is reading
that group anymore, so I'll try here first before I bother the wizards.

1)	How does one make a copy of the BSD distribution tape?  It's not a 
	tar tape, and not a dump tape; I need to make an 'image' copy.
	Someone suggested using tcopy, but I don't seem to have that (unless
	it's new to 4.3)

2)	We had our RP07 reformated recently by CDC.  But I got several errors
	while recreating the file system indicating that maybe it was formatted
	wrong (errors on newfs indicating wrong number of cylinders, while
	giving the rp07 disk type).  Could some interleave parameters to the
	std DEC formatter have caused this?

Thanx for any replies,

-- 
kral 	408/647-6112			...amdahl!drivax!braun
"To surrender is to remain in the hands of barbarians for the rest of my life;
 To fight is to leave my bones exposed in the desert waste" 
		- ancient chinese poem

karish@forel.stanford.edu (Chuck Karish) (04/28/89)

In article <4601@drivax.UUCP> braun@drivax.UUCP (Karl T. Braun (kral)) wrote:
>1)	How does one make a copy of the BSD distribution tape?  It's not a 
>	tar tape, and not a dump tape; I need to make an 'image' copy.
>	Someone suggested using tcopy, but I don't seem to have that (unless
>	it's new to 4.3)

	If you have 4.3 on line, look at /usr/sys/dist/maketape.

	The first file on the tape is written by `dd' with a block size
	of one block (512 bytes), and the others use 10K.  Files after
	the first one are tar files; some vendors (DEC, for one)
	compress them, but Berkeley doesn't.

	It's easy to write a shell script to use 'dd' to take the files
	off the tape and put them on another one.  If your disks are
	cramped, you'll have to use 'mt' to skip files, and do a lot of
	tape swapping.

	Chuck Karish		hplabs!hpda!mindcrf!karish
	(415) 493-7277		karish@forel.stanford.edu

gwyn@smoke.BRL.MIL (Doug Gwyn) (04/29/89)

/*
	tcopy -- copy magnetic tape

	original version due to Ron Natalie
	last edit:	86/06/08	D A Gwyn

	Usage:	tcopy /dev/rmt12 /dev/rmt13	# for example

	Arguments must be names of non-rewinding magtape devices	
*/
#ifndef	lint
static char	SCCS_id[] = "@(#)tcopy.c	1.1";
#endif

#include	<stdio.h>

extern void	exit(), perror();
extern int	close(), open(), read(), write();

#define	MAXSIZE	20*1024
static char	buffer[MAXSIZE];

static void
error( msg )
	char	*msg;
	{
 	perror( msg );
	exit( 1 );
	}

main( argc, argv )
	int	argc;
	char	*argv[];
	{
	register int	from, to;	/* I/O file descriptors */
	register int	nc, wc;		/* # chars read/written */
	int	bs;			/* file blocksize */
	long	count;			/* file block counter */

	if ( argc != 3 )
		{
		(void)fprintf( stderr, "Usage: tcopy from-dev to-dev\n" );
		exit( 2 );
		}

	do	{
		if ( (from = open( argv[1], 0 )) < 0 )
			error( argv[1] );

		if ( (to = open( argv[2], 1 )) < 0 )
			error( argv[2] );

		count = 0L;
		do	{
			if ( (nc = read( from, buffer, MAXSIZE )) < 0 )
				error( argv[1] );

			if ( count == 0L )
				bs = nc;	/* use first blocksize */

			if ( nc > 0 )
				{
				++count;

				if ( (wc = write( to, buffer, nc )) != nc )
					error( argv[2] );
				}
			}
		while ( nc > 0 );

		if ( close( from ) != 0 )
			error( argv[1] );

		if ( close( to ) != 0 )
			error( argv[2] );

		if ( count == 0L )
			(void)fprintf( stderr, "EOF\n" );
		else
			(void)fprintf( stderr, "%ld records, blocksize %d\n",
				       count, bs
				     );
		}
	while ( count > 0L );

	return 0;
	}