[ltp] Copying Files

Joachim Schrod linux-thinkpad@linux-thinkpad.org
Mon, 6 Dec 2004 17:51:37 +0100


>>>>> "S" == SOTL  <sotl155360@earthlink.net> writes:

S> I want to copy all files in a partition to another partition.

S> Can I do the following?

S> dd     if=dev/hda5/*     of=dev/hda6/*

No. This will simply give you a file not found error. (Btw, concerning
other answers: The asterisk in your arguments is not expanded by the
shell, as long as you don't have files with that obscure name in your
current directory.)

If AND ONLY IF your two partitions are of *exactly* the same size, you
can use

    dd if=/dev/hda5 of=/dev/hda6 bs=1M

(The bs makes dd run faster.)

But most probably your two partitions are of different size, then you
need to mount them and copy the files. For the sake of an example,
let's assume that /dev/hda5 is /var.

    mount /dev/hda6 /mnt
    cd /var
    find . -xdev -print0 | cpio -p0dam /mnt

Usage of cpio is recommended for the following reasons:
 -- It handels special files like named pipes and devices that cp
    doesn't do well.
 -- It's faster than a pipe with two tars. (That would be the other
    possibility.)

Read the man pages of find and cpio for explanation of the options.

	Joachim

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Joachim		     The most exciting phrase to hear in science, the
Rödermark, Germany   one that heralds new discoveries, is not "Eureka!"
<jschrod@acm.org>    (I found it!) but "That's funny..." [Isaac Asimov]