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)


3 Answers 3


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
  • This is exactly what I was after. Thanks! I only had to add * to the first tar. Aug 16, 2010 at 23:45
  • Hmmm... this doesn't look well: tar: one_of_the_files_being_copied: File shrank by 131757636 bytes; padding with zeros. Ideas? Aug 16, 2010 at 23:49
  • @Diego: sorry about the missing argument, I've put . 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)? Aug 16, 2010 at 23:58
  • It turns out the DVD is a little damaged (it's not copy protection - I created the [data] DVD from Ubuntu) Aug 17, 2010 at 0:40

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.

  • 1
    This is likely the slowest method to do the copy because the DVD drives have very slow seek times, so this method would thrash the drive's head back and forth. I think copying once to one hard drive and then copying (rsync?) to the other is faster.
    – Li Lo
    Aug 16, 2010 at 22:38
  • For speed considerations, looks like it's time for somebody to invent a 1-in, multiple-out copy tool, if something like that doesn't already exist. Or a unique way of using a streams from one of the builtin programs to "multiplex" the output.
    – John K
    Aug 16, 2010 at 22:45
  • 2
    @jdk: the tee command was invented over 40 years ago :-) Aug 16, 2010 at 22:56
  • @Gilles: Not if you're new to the *nix world - in that case it's good as new!. And I see OP is equally impressed by your answer. Good stuff.
    – John K
    Aug 17, 2010 at 14:34

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.