Hi Peter,

> $ src=/dev/sdb
> $ img=${src//\//_}
> $ img=${img#_}.img
> $  devbs=$(stat -fc %s $src)
> $
> $ sudo dd if=$src bs=$((devbs * 32)) of=$img
> [sudo] password for peterm:
> dd: error reading '/dev/sdb': Input/output error
> 126+1 records in
> 126+1 records out
> 16580608 bytes (17 MB, 16 MiB) copied, 0.0128577 s, 1.3 GB/s
> $
>
> Is it  because sdb is mounted?

No, that wouldn't cause `Input/output error'.  read(2) says of EIO:

    It may also occur when there is a low-level I/O error while reading
    from a disk or tape.

It's either an error on the media, or in the chain of devices to get to
that media, e.g. USB hubs, etc.  It's not corrupted bytes on the media
as they'd be read just fine.  dmesg(1) may have recorded something at
the time.  `dmesg -HPx' will show the time of day for searching.

dd says 16580608 bytes copied, that being 126 whole blocks plus one
truncated block.  The echo command I gave isn't pasted above, but
guessing $devbs is 4096 gives

    4096 * 32 = 131,072
    16,580,608 / 131,072 = 126.5

that matches the 126.  Half a 128 KiB input block was read after that.

Re-trying this would be interesting to see if the EIO occurs at the same
point.  If it doesn't then you've an intermittent problem, but still a
problem.

It's a bad idea to have any of the partitions on /dev/sdb mounted whilst
taking an image as the filesystems can be in an inconsistent state that
would need an fsck(8) to attempt to repair them in the copy that's made.
But it wouldn't cause the EIO above.

Cheers, Ralph.

--
  Next meeting at *new* venue:  Bournemouth, Tuesday, 2018-12-04 20:00
  Check if you're replying to the list or the author
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk/
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk

Reply via email to