10

By default rsync verifies written files to make sure that it matches the original file. I can reproduce this by copying a volatile file from /sys

$ rsync -v /sys/power/state /tmp/
state
rsync: read errors mapping "/sys/power/state": No data available (61)
WARNING: state failed verification -- update discarded (will try again).
state
rsync: read errors mapping "/sys/power/state": No data available (61)
ERROR: state failed verification -- update discarded.

sent 8,328 bytes  received 133 bytes  16,922.00 bytes/sec
total size is 4,096  speedup is 0.48
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1165) [sender=3.1.0]

Is there an option to turn this error into a warning and without discarded the file again?

Context: I want to use rsync instead of cp to workaround a common bug in coreutils (broken since 12 years), see Why does cp --no-preserve=mode preserves the mode? Alternative tools available?

rudimeier
  • 10,315
  • You shouldnt be trying to copy /sys "files" as they are not regular files. For example, they will have a size of 4096 bytes, but only contain 16 bytes. – meuh Oct 11 '16 at 14:57
  • Isn't "copy" just "read"? The example file is surly a regular file made to read it. The stats seem odd that's why I want to ignore them. – rudimeier Oct 11 '16 at 15:01
  • Found a similar question on superuser http://superuser.com/questions/598664/rsync-can-it-transfer-files-ignoring-size-comparing-only-timestamp-and-name – rudimeier Oct 11 '16 at 15:13

1 Answers1

7

rsync performs read + write + verify, not just read + write. You cannot disable this verify-after-read option.

The complication for this file in /sys occurs because rsync gets a short read (it's expecting 4096 bytes but only gets around 12), so treats that as a read failure.

Shortly after writing this answer I found more detail at Why does rsync fail to copy files from /sys in Linux?.

Chris Davies
  • 116,213
  • 16
  • 160
  • 287
  • 1
    Not sure why you're downvoted, this is what's going on. – Satō Katsura Oct 11 '16 at 15:19
  • Assuming "you" is me ;) It's not my down vote. I believe this answer is right that there is no way to get rsync running for /sys. But it sounds like that rsync behavior has to be that way. IMO verify could be implemented without using sizes, specially when using option -c "skip based on checksum, not mod-time & size". IMO that's a bug in rsync, not only a missing feature. BTW about "short read"? If all programs would read data in the same way like rsync then sysfs would be unusable. – rudimeier Oct 11 '16 at 16:52