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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
11-03-2016, 03:44 PM
|
#1
|
LQ Newbie
Registered: Oct 2016
Location: Arizona
Distribution: Ubuntu
Posts: 5
Rep: 
|
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.
|
|
|
11-03-2016, 05:38 PM
|
#2
|
Moderator
Registered: Mar 2008
Posts: 22,344
|
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.
|
11-03-2016, 05:45 PM
|
#3
|
Moderator
Registered: Aug 2002
Posts: 26,626
|
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.
|
11-03-2016, 05:47 PM
|
#4
|
Moderator
Registered: Mar 2008
Posts: 22,344
|
Also your hardware has documented block size if unsure.
|
|
|
11-03-2016, 06:04 PM
|
#5
|
Senior Member
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,810
|
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.
|
11-03-2016, 06:09 PM
|
#6
|
LQ Newbie
Registered: Oct 2016
Location: Arizona
Distribution: Ubuntu
Posts: 5
Original Poster
Rep: 
|
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
|
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.
|
|
|
11-03-2016, 06:19 PM
|
#7
|
Senior Member
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,810
|
Quote:
Originally Posted by TheReddestRock
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.
|
11-03-2016, 08:53 PM
|
#8
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908
|
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.
|
11-03-2016, 10:56 PM
|
#9
|
Senior Member
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,810
|
Quote:
Originally Posted by jpollard
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.
|
11-04-2016, 05:49 AM
|
#10
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908
|
You are correct. I forgot the driver can't know ahead of time how large the block is.
|
|
|
11-04-2016, 04:28 PM
|
#11
|
LQ Newbie
Registered: Oct 2016
Location: Arizona
Distribution: Ubuntu
Posts: 5
Original Poster
Rep: 
|
Quote:
Originally Posted by rknichols
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.
|
|
|
11-04-2016, 05:59 PM
|
#12
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908
|
Quote:
Originally Posted by TheReddestRock
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.
|
11-04-2016, 06:35 PM
|
#13
|
Senior Member
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,810
|
Quote:
Originally Posted by TheReddestRock
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.
|
|
|
11-16-2016, 02:20 PM
|
#14
|
LQ Newbie
Registered: Oct 2016
Location: Arizona
Distribution: Ubuntu
Posts: 5
Original Poster
Rep: 
|
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.
|
|
|
11-16-2016, 02:42 PM
|
#15
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908
|
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.
|
All times are GMT -5. The time now is 03:33 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|