I'm trying to copy a directory to external HDD. I mounted the device and then typed : cd root tar -cf - * | (cd /mnt ; tar -xpf -)

I got this error message: "cowardly refusing to create an empty archive"

When I do ls to the same root directory- it is not empty at all- all my needed files are there.

Why does this happen?


Why don't you simply use cp -pr source destination?


cd ~/tmp/source/;tar -cpf - * | (cd ~/tmp/destination;tar -xpf -)

works just fine.

  • Err, I'm guessing 'distance' should be 'destination'. Or possibly 'distant directory'.
    – dr-jan
    Mar 13 '11 at 11:55
  • LOL, I have no idea how that got there. Mar 13 '11 at 12:04

if you want to copy the root filesystem and worry about special files and devices, the best way is:

  • first to mount the / in a subdir using the bind option for mount, this way you won't have to worry about /proc, /dev, /sys and other mounted filesystems
  • then use a command that knows how to handle special files, like cp -a or rsync -a

lets say you have mounted the external drive under /mnt/external

mkdir /mnt/root
mount / /mnt/root -o bind
cp -a /mnt/root/* /mnt/external/


rsync -aP /mnt/root/ /mnt/external/

or (if you like tar so much, btw the worst option)

tar -C /mnt/root -cf - ./ | tar -C /mnt/external -xpf -

add -v to any of the above for verbose output, but it will slow down a bit the process

  • thank you very much!!!- btw i didn't use tar..........
    – Shira
    Mar 13 '11 at 15:13

I find the best thing for copying whole directory structures is rsync

# rsync -avP /path/to/source/* /path/to/destination/

This also has the advantage that you can to it to or from a remote directory through ssh.


Please use the POSIX PAX utility.

Unlike cp, pax works the same on every system. With pax you can always safely copy file systems with special files such as device nodes.

To copy one file system /mnt/foo into /mnt/bar, preserving permissions, timestamps and special files do:

# cd /mnt/foo
pax -rw -pe -X . /mnt/bar/

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.