Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #171756

Problem selecting options for cp command

From Richard Owlett <rowlett@cloud85.net>
Newsgroups linux.debian.user
Subject Problem selecting options for cp command
Date 2016-09-05 14:40 +0200
Message-ID <se1lT-3KI-7@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.debian.user | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Problem selecting options for cp command Richard Owlett <rowlett@cloud85.net> - 2016-09-05 14:40 +0200
  Re: Problem selecting options for cp command Patrick Wiseman <pwiseman@gmail.com> - 2016-09-05 14:50 +0200
    Re: Problem selecting options for cp command <tomas@tuxteam.de> - 2016-09-05 15:00 +0200
  Re: Problem selecting options for cp command Mark Fletcher <mark27q1@gmail.com> - 2016-09-05 14:50 +0200
    Re: Problem selecting options for cp command Richard Owlett <rowlett@cloud85.net> - 2016-09-05 16:30 +0200
      Re: Problem selecting options for cp command Lars Noodén <lars.nooden@gmail.com> - 2016-09-05 16:30 +0200
  Re: Problem selecting options for cp command <tomas@tuxteam.de> - 2016-09-05 15:00 +0200
  Re: Problem selecting options for cp command Dan Purgert <dan@djph.net> - 2016-09-05 15:00 +0200
  Re: Problem selecting options for cp command Henrique de Moraes Holschuh <hmh@debian.org> - 2016-09-05 15:00 +0200
    Re: Problem selecting options for cp command <tomas@tuxteam.de> - 2016-09-05 15:10 +0200
    Re: Problem selecting options for cp command Richard Owlett <rowlett@cloud85.net> - 2016-09-05 15:30 +0200
      Re: Problem selecting options for cp command Jonathan Dowland <jmtd@debian.org> - 2016-09-05 15:40 +0200
  Re: Problem selecting options for cp command "Thomas Schmitt" <scdbackup@gmx.net> - 2016-09-05 15:10 +0200

csiph-web