Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #171756 > unrolled thread
| Started by | Richard Owlett <rowlett@cloud85.net> |
|---|---|
| First post | 2016-09-05 14:40 +0200 |
| Last post | 2016-09-05 15:10 +0200 |
| Articles | 13 — 9 participants |
Back to article view | Back to linux.debian.user
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
| From | Richard Owlett <rowlett@cloud85.net> |
|---|---|
| Date | 2016-09-05 14:40 +0200 |
| Subject | Problem selecting options for cp command |
| Message-ID | <se1lT-3KI-7@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Patrick Wiseman <pwiseman@gmail.com> |
|---|---|
| Date | 2016-09-05 14:50 +0200 |
| Message-ID | <se1vA-3Ov-19@gated-at.bofh.it> |
| In reply to | #171756 |
[Multipart message — attachments visible in raw view] — view raw
On Mon, Sep 5, 2016 at 8:29 AM, Richard Owlett <rowlett@cloud85.net> wrote: > 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 think what you want is the magic tar command: $tar cf - [files] | (cd /[dir]; tar xf - ) It's wise, just to make sure it's going to do what you expect, to do $tar cf - [files] | (cd /[dir]; tar tvf - ) first! Substitute 'u' for 'x' to update files; otherwise, old files will overwrite newer files with the same name. (I know; I did it!) To copy a whole directory; create the parent dir if it doesn't already exist, then: $tar cf - [dir] | (cd /[parent_dir]; tar xf - ) I haven't had occasion to use it in a while, but I'm pretty sure it makes a "perfect" copy. HTH Patrick
[toc] | [prev] | [next] | [standalone]
| From | <tomas@tuxteam.de> |
|---|---|
| Date | 2016-09-05 15:00 +0200 |
| Message-ID | <se1Ff-3S7-7@gated-at.bofh.it> |
| In reply to | #171759 |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Mon, Sep 05, 2016 at 08:43:44AM -0400, Patrick Wiseman wrote: > On Mon, Sep 5, 2016 at 8:29 AM, Richard Owlett <rowlett@cloud85.net> wrote: > > > 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 think what you want is the magic tar command: > > $tar cf - [files] | (cd /[dir]; tar xf - ) > > It's wise, just to make sure it's going to do what you expect, to do > > $tar cf - [files] | (cd /[dir]; tar tvf - ) > > first! While basically correct, this is antiquated. It stems from the good ol'days "cp" had no -a option. With the ubiquity of the Gnu tools (thanks, Gnu!), you have cp -a, which is what you really want. Or rsync (especially if you expect having to stop the copy operation mid-way and restart it, or if you have an old version of the copy to start of, as in backups). When copying across machine boundaries, use rsync. Much nicer. As in "by orders of magnitude much nicer". Regards - -- t -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlfNa8QACgkQBcgs9XrR2kYI+QCfVEyF9/35j6+WLYEjDXqfUiWZ AdsAn1w35Wxia/I1B6yaos+JF+zl+kaf =dHpj -----END PGP SIGNATURE-----
[toc] | [prev] | [next] | [standalone]
| From | Mark Fletcher <mark27q1@gmail.com> |
|---|---|
| Date | 2016-09-05 14:50 +0200 |
| Message-ID | <se1vB-3Ov-49@gated-at.bofh.it> |
| In reply to | #171756 |
[Multipart message — attachments visible in raw view] — view raw
On Mon, Sep 5, 2016 at 9:30 PM Richard Owlett <rowlett@cloud85.net> wrote: > 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. > > I think cp -a is your best bet. It will copy everything, shouldn't choke on links, and will also set permissions etc correctly on the target device, assuming you have permissions to do so (you should be doing the copy as root, always assuming you want to keep permissions and access modes intact). I recently used it to copy hard disk partitions to a replacement SSD (some discussions about that are in the archives of this list) and it worked just dandy. Mark
[toc] | [prev] | [next] | [standalone]
| From | Richard Owlett <rowlett@cloud85.net> |
|---|---|
| Date | 2016-09-05 16:30 +0200 |
| Message-ID | <se34l-4Wz-9@gated-at.bofh.it> |
| In reply to | #171761 |
On 9/5/2016 7:46 AM, Mark Fletcher wrote: > > > On Mon, Sep 5, 2016 at 9:30 PM Richard Owlett > <rowlett@cloud85.net <mailto:rowlett@cloud85.net>> wrote: > > 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. > > > I think cp -a is your best bet. It will copy everything, > shouldn't choke on links, and will also set permissions etc > correctly on the target device, assuming you have permissions to > do so (you should be doing the copy as root, always assuming you > want to keep permissions and access modes intact). > > I recently used it to copy hard disk partitions to a replacement > SSD (some discussions about that are in the archives of this > list) and it worked just dandy. > > Mark "archive" had brought up mental image of dusty back rooms where things were being preserved for posterity. Not making a copy to actually be used. Someone had suggested rsync but that has too many options for me to bungle. "cp" may be slower but appears more comfortable. Thanks to all.
[toc] | [prev] | [next] | [standalone]
| From | Lars Noodén <lars.nooden@gmail.com> |
|---|---|
| Date | 2016-09-05 16:30 +0200 |
| Message-ID | <se34m-4Wz-23@gated-at.bofh.it> |
| In reply to | #171774 |
On 09/05/2016 05:21 PM, Richard Owlett wrote: > "archive" had brought up mental image of dusty back rooms where things > were being preserved for posterity. Not making a copy to actually be used. > > Someone had suggested rsync but that has too many options for me to > bungle. "cp" may be slower but appears more comfortable. > > Thanks to all. For rsync, the only options that you need to worry about are -a and -v. Even then the -v is optional. rsync -av /media/richard/myrepo/ /media/richard/test/ Just remember the trailing slash on the directories and it will go fine. Regards, Lars
[toc] | [prev] | [next] | [standalone]
| From | <tomas@tuxteam.de> |
|---|---|
| Date | 2016-09-05 15:00 +0200 |
| Message-ID | <se1Fg-3S7-27@gated-at.bofh.it> |
| In reply to | #171756 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Mon, Sep 05, 2016 at 07:29:52AM -0500, Richard Owlett wrote:
> 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.
First: what do you *want*?
(a) if cp finds a link it should copy it as a (now possibly
dangling) link)
(b) it should copy (recursively) the contents of the dir
the link points to.
Once you are clear, it's easier to decide
Hint: when doing backup, you almost always want cp -a (*not* -R).
It will copy the links as links. If they point to some place
outside the tree under copy, they are dangling links in the copy.
On backups you almost always want that.
Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iEYEARECAAYFAlfNamQACgkQBcgs9XrR2kbzmACffqDzwcIiLQ0mUhNFgfHNj3pF
jQEAniafWEURYJx7Q1kDt8E+h+U0U2yJ
=O7Ig
-----END PGP SIGNATURE-----
[toc] | [prev] | [next] | [standalone]
| From | Dan Purgert <dan@djph.net> |
|---|---|
| Date | 2016-09-05 15:00 +0200 |
| Message-ID | <se1Ff-3S7-19@gated-at.bofh.it> |
| In reply to | #171756 |
Richard Owlett wrote: > 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. > [snip] > > What option(s) should I be using? > Should I be looking at "dd" rather than "cp"? > [snip] Using 'dd' may work, though it seems you need to simply add the -l option to the 'cp' command you were using. -- |_|O|_| Registered Linux user #585947 |_|_|O| Github: https://github.com/dpurgert |O|O|O|
[toc] | [prev] | [next] | [standalone]
| From | Henrique de Moraes Holschuh <hmh@debian.org> |
|---|---|
| Date | 2016-09-05 15:00 +0200 |
| Message-ID | <se1Fg-3S7-29@gated-at.bofh.it> |
| In reply to | #171756 |
On Mon, 05 Sep 2016, Richard Owlett wrote: > I received "illegal operation" error messages as symbolic links were > encountered. That means the target filesystem does not support symlinks. -- Henrique Holschuh
[toc] | [prev] | [next] | [standalone]
| From | <tomas@tuxteam.de> |
|---|---|
| Date | 2016-09-05 15:10 +0200 |
| Message-ID | <se1OW-4aR-29@gated-at.bofh.it> |
| In reply to | #171765 |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Mon, Sep 05, 2016 at 09:55:46AM -0300, Henrique de Moraes Holschuh wrote: > On Mon, 05 Sep 2016, Richard Owlett wrote: > > I received "illegal operation" error messages as symbolic links were > > encountered. > > That means the target filesystem does not support symlinks. Oh, right. Good point -- forgot the most important part. Luckily someone is reading carefully :-) regards - -- t -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlfNbNUACgkQBcgs9XrR2kZigACdHrkKUeZ2v0BEadC/GlOnOWys lNgAnjil3HPOzEeuoqfG3n8JeG2UNNEe =DUDz -----END PGP SIGNATURE-----
[toc] | [prev] | [next] | [standalone]
| From | Richard Owlett <rowlett@cloud85.net> |
|---|---|
| Date | 2016-09-05 15:30 +0200 |
| Message-ID | <se28k-4is-77@gated-at.bofh.it> |
| In reply to | #171765 |
On 9/5/2016 7:55 AM, Henrique de Moraes Holschuh wrote: > On Mon, 05 Sep 2016, Richard Owlett wrote: >> I received "illegal operation" error messages as symbolic links were >> encountered. > > That means the target filesystem does not support symlinks. > That may have been the problem. It's possible the flash drive HAD BEEN formatted FAT-32. No way to tell now as I brute forced wiped drive by having gparted format it as ext2.
[toc] | [prev] | [next] | [standalone]
| From | Jonathan Dowland <jmtd@debian.org> |
|---|---|
| Date | 2016-09-05 15:40 +0200 |
| Message-ID | <se2i3-4lH-19@gated-at.bofh.it> |
| In reply to | #171769 |
[Multipart message — attachments visible in raw view] — view raw
On Mon, Sep 05, 2016 at 08:25:37AM -0500, Richard Owlett wrote: > That may have been the problem. It's possible the flash drive HAD BEEN > formatted FAT-32. No way to tell now as I brute forced wiped drive by having > gparted format it as ext2. If you are going to put an extX family filesystem on it, I'd recommend at least ext3, and ideally ext4, which have journals and therefore are more robust in the face of things like power cuts. -- Jonathan Dowland Please do not CC me, I am subscribed to the list.
[toc] | [prev] | [next] | [standalone]
| From | "Thomas Schmitt" <scdbackup@gmx.net> |
|---|---|
| Date | 2016-09-05 15:10 +0200 |
| Message-ID | <se1OW-4aR-21@gated-at.bofh.it> |
| In reply to | #171756 |
Hi, Richard Owlett wrote: > /media/richard/test is a USB flash drive > I received "illegal operation" error messages as symbolic links were > encountered. Maybe the filesystem is of a type which does not support symbolic links ? $ cp -R ./test/softlinks /mnt/fat cp: cannot create symbolic link ‘/mnt/fat/softlinks/irrelang’: Operation not permitted Have a nice day :) Thomas
[toc] | [prev] | [standalone]
Back to top | Article view | linux.debian.user
csiph-web