LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-03-2016, 03:44 PM   #1
TheReddestRock
LQ Newbie
 
Registered: Oct 2016
Location: Arizona
Distribution: Ubuntu
Posts: 5

Rep: Reputation: Disabled
Duplicating a tape drive using dd


Hi guys! I just got started with linux and I've settled on Ubuntu 16. It's spiffy. I like it.

Anyway, what I'm trying to do is copy all the data from one tape drive onto another tape drive. I've been poking around the web a bit and have found info on how to copy from tape to HDD, HDD to tape etc but not tape-to-tape. I'm sure the process probably isn't that different but I'm still not quite sure how to do it correctly.

So obviously the first thing to do is rewind the tapes. Then I tried dd:

sudo dd if=/dev/st1 of=/dev/st0 bs=512

But then I get:

0+0 records in
0+0 records out
0 bytes copied, 0.0028584 s, 0.0 kB/s

Which doesn't seem right. Are there parameters I'm missing? Or do I need to "prime" the tape drives first (I rewound both of them, checked status, etc. but didn't do anything else). The drives/tapes are pretty much as close to brand new as you can get, so I don't think there's anything wrong with the tapes themselves. They're both HP drives, if that's relevant.
 
Old 11-03-2016, 05:38 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,978

Rep: Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624
Hello and welcome to LQ.

dd might be a poor choice. Have you considered using tar command?
Some useful tips. http://www.cyberciti.biz/hardware/un...ment-commands/

Wonder if tcopy is available?


Others may have a better solution.

Last edited by jefro; 11-03-2016 at 05:44 PM.
 
1 members found this post helpful.
Old 11-03-2016, 05:45 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,699

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Yes it is although I do not know how it compares to the AIX version.

https://sourceforge.net/projects/tcopy/
 
2 members found this post helpful.
Old 11-03-2016, 05:47 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,978

Rep: Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624
Also your hardware has documented block size if unsure.
 
Old 11-03-2016, 06:04 PM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
The most important difference when working with tapes is that block size is important. You will need to get familiar with the manpage for the mt command, and you will also have to look in the system error log to see why things aren't working as expected.

For simple duplication, you can just put the driver for both tapes in variable block size mode and tell the dd command to use a block size at least as large as anything on the source tape.
Code:
mt -f /dev/st0 setblk 0
mt -f /dev/st1 setblk 0
dd if=/dev/st0 of=/dev/st1 bs=1M
It is important that the same process does both the reading and the writing so that the block size(s) are preserved.

That dd command is going to read and write just a single file. If the tape contains multiple files, you will need to use the "no-rewind" devices and loop on the dd until it fails.
Code:
while dd if=/dev/nst0 of=/dev/nst1 bs=1M
do :
done
mt -f /dev/st0 rewind
mt -f /dev/st1 rewind
It's been quite a while since I've used tapes, so I've probably left something out, but that should be enough to get you started.
 
2 members found this post helpful.
Old 11-03-2016, 06:09 PM   #6
TheReddestRock
LQ Newbie
 
Registered: Oct 2016
Location: Arizona
Distribution: Ubuntu
Posts: 5

Original Poster
Rep: Reputation: Disabled
I'm pretty confident I know the block size, it's just getting my head around everything else. Tape drives are a bit before my time but I've been doing some reading and I think I have a basic understanding of how block size and filemarks work. The hardest thing to get used to is the lack of a file system. I'm spoiled.

Quote:
Originally Posted by michaelk View Post
Yes it is although I do not know how it compares to the AIX version.

https://sourceforge.net/projects/tcopy/
Downloading this as we speak. Not quite sure how to install things yet but I'm looking that up as we speak too!

I'll report back on how things go.
 
Old 11-03-2016, 06:19 PM   #7
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by TheReddestRock View Post
I'm pretty confident I know the block size,
It's easy enough to find out for sure.
Code:
mt -f /dev/st0 setblk 0
dd if=/dev/st0 of=/dev/null bs=1M count=1
If that works, the dd command will tell you the size of the one block it read. If not, the system error log should give some clue as to why.

Note that it's entirely possible that multiple block sizes were used to write the tape, e.g., a header written with one block size followed by a payload written with a different block size. You would probably know if that were likely.
 
1 members found this post helpful.
Old 11-03-2016, 08:53 PM   #8
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
There is a good bit of things to know about a tape... Mostly about the tape marks.

Between any two files will be a tape mark. At the end of the recorded data there will be two tape marks together.

If the tape is labeled, the roughly one 512 byte block read will be the label, followed by a tape mark.

If you have an "ANSI" tape, then each file is preceded by the file header (usually one 512 byte block)... and a tape mark.

Any data recorded on the tape will have its own record length... But if you are not doing any form of data conversions (using the "conv=..." option), then it likely won't matter what block size you use.
 
2 members found this post helpful.
Old 11-03-2016, 10:56 PM   #9
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by jpollard View Post
But if you are not doing any form of data conversions (using the "conv=..." option), then it likely won't matter what block size you use.
I disagree. If either the driver or dd is using a block size too small to hold one of the blocks on the tape, that is going to cause an error. If you are trying to copy a tape, the block sizes at the destination had better match the source or else whatever application is trying to read that tape won't be happy with the copy. It's not like a direct access device where data is going to be re-blocked on both input and output. With a tape, the blocks you read have to match one-for-one with the blocks on the tape**, and whatever size blocks you write are the sizes that end up on the tape.
** It's OK to read a short block into a larger buffer, but what you get is just that short block, not a full buffer.
 
1 members found this post helpful.
Old 11-04-2016, 05:49 AM   #10
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
You are correct. I forgot the driver can't know ahead of time how large the block is.
 
Old 11-04-2016, 04:28 PM   #11
TheReddestRock
LQ Newbie
 
Registered: Oct 2016
Location: Arizona
Distribution: Ubuntu
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
It's easy enough to find out for sure.
Code:
mt -f /dev/st0 setblk 0
dd if=/dev/st0 of=/dev/null bs=1M count=1
If that works, the dd command will tell you the size of the one block it read. If not, the system error log should give some clue as to why.

Note that it's entirely possible that multiple block sizes were used to write the tape, e.g., a header written with one block size followed by a payload written with a different block size. You would probably know if that were likely.
I've tried this but the console spits out "mt command setblk not recognised". I checked the man file for mt and as it turns out, setblk is not displayed as an argument so I guess it's a legacy issue? The plot thickens!

That said, I was able to confirm block size by other means so I'm good on that front.

Now I've run into a new issue - I can copy the data, but the filemarks aren't preserved. Is it possible to insert them myself? I mean in theory, it's just more data...

Still looking into tcopy. I'm just dragging my feet there because I want to see how far I can get before I have to install something new. I'm working with an offline PC so bringing in outside packages is a pain in the rear.
 
Old 11-04-2016, 05:59 PM   #12
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by TheReddestRock View Post
I've tried this but the console spits out "mt command setblk not recognised". I checked the man file for mt and as it turns out, setblk is not displayed as an argument so I guess it's a legacy issue? The plot thickens!

That said, I was able to confirm block size by other means so I'm good on that front.

Now I've run into a new issue - I can copy the data, but the filemarks aren't preserved. Is it possible to insert them myself? I mean in theory, it's just more data...

Still looking into tcopy. I'm just dragging my feet there because I want to see how far I can get before I have to install something new. I'm working with an offline PC so bringing in outside packages is a pain in the rear.
File marks on a tape drive are written when the file is closed. Actually, two tape marks (end of tape identification), then it backs up over one to allow the next file to be added. But to write to the tape requires the output tape to NOT rewind on close. You don't create the tape marks - that is up to the transport.

You can use (or should be able to) write extra tape marks using the mt command if you want, but it shouldn't be necessary (I think all it does is open the transport for write, then close it again).

If you are appending to a tape just installed in the transport you have to position the tape to the end of the tape first (mt eod) AND use the no rewind device name.
 
1 members found this post helpful.
Old 11-04-2016, 06:35 PM   #13
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by TheReddestRock View Post
I've tried this but the console spits out "mt command setblk not recognised". I checked the man file for mt and as it turns out, setblk is not displayed as an argument so I guess it's a legacy issue?
What version of the mt command ("mt --version")? What type of tape drive, and what interface? The "setblk" operation is specific to drives that use the SCSI command set.

Last edited by rknichols; 11-04-2016 at 06:36 PM.
 
Old 11-16-2016, 02:20 PM   #14
TheReddestRock
LQ Newbie
 
Registered: Oct 2016
Location: Arizona
Distribution: Ubuntu
Posts: 5

Original Poster
Rep: Reputation: Disabled
Hey guys, just a general update! Sorry it took so long, life happened and I had to put my tapes on the backburner for a while.

I ended up going with tcopy and it worked pretty well! The only weird thing it does is add an extra filemark at the end, but who cares it's not harming anything. I suppose I could always erase it if I really had to.

Thanks for your help everyone. I really appreciate it.
 
Old 11-16-2016, 02:42 PM   #15
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
The two tape marks are supposed to be there. It allows a quick skip to "end of tape" as identified by the two consecutive tape marks.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Script to Detect whether tape exist in tape drive or not dctw Linux - General 3 12-17-2010 03:04 AM
Is Tar file to tape drive faster than dir/files to tape drive? Runge_Kutta Linux - General 2 03-11-2009 07:13 AM
Tape Backups and How can i find out the Name (label) of the tape in the drive?? helptonewbie Linux - Newbie 2 10-27-2008 07:20 AM
Using a DDS5 tape drive to restore from a DDS3 backup tape. AndrewCAtWayofthebit Linux - Hardware 1 05-14-2006 09:15 AM
Duplicating a hard drive mediocre Linux - General 1 03-24-2006 01:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration