Copying to two locations at the same time

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

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.


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