Problem selecting options for cp command
I attempted to copy contents of one partition to another using
cp -R /media/richard/myrepo /media/richard/test
/media/richard/myrepo is a hard disk partition
/media/richard/test is a USB flash drive
I received "illegal operation" error messages as symbolic links
were encountered.
"man cp" was too terse to be illuminating.
https://www.gnu.org/software/coreutils/manual/html_node/cp-invocation.html#cp-invocation
[apparently relevant excerpts below] was not enlightening.
"...
By default, cp does not copy directories. However, the -R, -a,
and -r options cause cp to copy recursively by descending into
source directories and copying files to corresponding destination
directories.
When copying from a symbolic link, cp normally follows the link
only when not copying recursively or when --link (-l) is used.
This default can be overridden with the --archive (-a), -d,
--dereference (-L), --no-dereference (-P), and -H options. If
more than one of these options is specified, the last one
silently overrides the others.
When copying to a symbolic link, cp follows the link only when it
refers to an existing regular file. However, when copying to a
dangling symbolic link, cp refuses by default, and fails with a
diagnostic, since the operation is inherently dangerous. This
behavior is contrary to historical practice and to POSIX. Set
POSIXLY_CORRECT to make cp attempt to create the target of a
dangling destination symlink, in spite of the possible risk.
Also, when an option like --backup or --link acts to rename or
remove the destination before copying, cp renames or removes the
symbolic link rather than the file it points to.
..."
"...
‘-d’ Copy symbolic links as symbolic links rather than copying
the files that they
point to, and preserve hard links between source files
in the copies. Equivalent
to --no-dereference --preserve=links.
..."
"...
‘-H’ If a command line argument specifies a symbolic link,
then copy the file it
points to rather than the symbolic link itself. However,
copy (preserving its
nature) any symbolic link that is encountered via
recursive traversal.
..."
"...
‘-R’
‘-r’
‘--recursive’
Copy directories recursively. By default, do not follow
symbolic links in the source unless used together with the --link
(-l) option; see the --archive (-a), -d, --dereference (-L),
--no-dereference (-P), and -H options. Special files are copied
by creating a destination file of the same type as the source;
see the --copy-contents option. It is not portable to use -r to
copy symbolic links or special files. On some non-GNU systems, -r
implies the equivalent of -L and --copy-contents for historical
reasons. Also, it is not portable to use -R to copy symbolic
links unless you also specify -P, as POSIX allows implementations
that dereference symbolic links by default.
..."
What option(s) should I be using?
Should I be looking at "dd" rather than "cp"?
"man dd" and
https://www.gnu.org/software/coreutils/manual/html_node/dd-invocation.html#dd-invocation
not illuminating.
TIA
Reply to: