I'm not very fluent with bash... what I'd like to do is copy the content of a DVD-R to two different hard drives in the fastest possible way.
(UI-based solutions are welcome too)
Thanks!
The bottleneck is likely to be reading from the DVD drive, so we must ensure to either read it only once, or read it twice but at sufficiently close intervals that the data will still be in the cache. The latter sounds difficult, so let's go for the first.
We need to get a duplicator in there somewhere. If we restrict to basic shell commands, the only choice is tee
. So we need to convert the input (a tree of files) into a stream, feed the stream to tee
, and convert each output stream back to a tree of files. The tool to do that is an archiver. Compression on something that'll remain in memory is a waste, so let's just use tar
.
Pipes (command0 | command1
) allow us to feed the output of a command into one other commands. We need to feed the output of tee
into two other commands, so another bash construct comes in handy: command1 >(command2)
creates a pipe that is passed to command1
as its first command rather than becoming the standard output of command2
. (Look up process substitution in the bash manual.)
Here's the command (untested):
mkdir /media/disk0/copy_of_dvd /media/disk1/copy_of_dvd
cd /media/cdrom
tar cf - . | tee >(tar xf - -C /media/disk0/copy_of_dvd) | tar xf - -C /media/disk1/copy_of_dvd
*
to the first tar
.
Commented
Aug 16, 2010 at 23:45
tar: one_of_the_files_being_copied: File shrank by 131757636 bytes; padding with zeros
. Ideas?
Commented
Aug 16, 2010 at 23:49
.
which is slightly better. I've never seen that error message before; after googling a little, I wonder if it could be due to a “copy protection” scheme that I've seen on some DVDs: the filesystem structure is invalid, with some files extending beyond the claimed extent of the DVD. If you run both du
and df
on the DVD, do they report approximately equal sizes (last line of du
, leftmost numeric column of df
)?
Commented
Aug 16, 2010 at 23:58
One shell based solution is to open a terminal and type:
cp -r /location/of/DVD /hard/drive/a &
cp -r /location/of/DVD /hard/drive/b
The command cp
is for copy files and the -r
switch copies all files recursively. You have to enter the directory where your DVD is located (usually /media/dvd
or similar) and second the place in the harddrive where you want the files (i.e. /home/diego/mydvd
). The &
sends the first process to the background and you can immediately enter and execute a second command.
tee
command was invented over 40 years ago :-)
Commented
Aug 16, 2010 at 22:56
As mentioned in Li Lo's comment to qbi's answer, optical drives (CD, DVD, etc.) are the slowest kind of drive, so you want to minimize the amount of reading that you do from the DVD drive. The obvious solution would be to copy the data from the DVD to one location on the hard drive and then copy it from that location to the other hard drive.
cp -r /media/cdrom /location1
cp -r /location1 /location2