0

I have one folder in my internal HDD. I need to copy the folder to multiple external HDD. If the copy can happen simultaneously, it will help me gain time.

Folder name is "AllFiles" Folder is located at the root of the internal HDD. /AllFiles

No to copy it to /dev/sdb, /dev/sdc and /dev/sdd

I saw some command lines using cat and tee. I couldn't test it because it was for a specific purpose and the destination was a network folder.

karel
  • 13,488
Arnaud
  • 1

2 Answers2

0

The way to tackle this really depends on what your exact goal is.

Using TEE would not be of much help here - tee allows you to take stdout and split it into two, although it could be forced into doing your bidding by catting each file through tee.

The simplest way to do this would be to simply mount each drive and start 3 copies (you can do it in 3 terminals, or you could issue the same command 3 times, with an & after each to put it in the background). This will nail IO to the wall.

If the drives don't need to be removed, and need identical information, I'd take the 3 drives and create a RAID1 array (ie 3 copies of the same data) using mdadm. I'd then create a filesystem on the RAID, mount the array and do the copy. This will mean less reads (maybe), and least overhead of writing to the disk - but quite a bit of setup. (YES, you can then take an individual disk and mount it without it being part of the array)

davidgo
  • 70,654
  • I feel like the second idea is superb. I thought of it in the past but didn't know how to make RAID0 from 3 disks. Let me try the mdadm command. I will revert. – Arnaud Oct 16 '17 at 12:42
0

Yes, you can copy a file to multiple destinations using cat and tee:

cat source.dat | tee copy1.dat | tee copy2.dat >copy3.dat 

Or to be more symmetrical:

cat source.dat | tee copy1.dat | tee copy2.dat | tee copy3.dat >/dev/null

In practice you would put the line above in a short script that takes the source file as a parameter, and call this script in a find command:

find $directory_to_be_copied -type f -exec copy_multiple {} \;

But, if you save on the disk reads, you'll likely hit I/O bandwidth problems.

xenoid
  • 10,012
  • I'm a beginner in linux and command line. It's tough to understand what you mean. But I will definitely do some tests and revert. Thanks anyway. – Arnaud Oct 16 '17 at 12:44