On 09/11/2018 13:44, Ralph Corderoy wrote:
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.

peterm@peterm-MBB-34204H:~/Raspberry-Pi/Robot-7-Flask$ src=/dev/sdb
peterm@peterm-MBB-34204H:~/Raspberry-Pi/Robot-7-Flask$ img=${src//\//_}
peterm@peterm-MBB-34204H:~/Raspberry-Pi/Robot-7-Flask$ img=${img#_}.img
peterm@peterm-MBB-34204H:~/Raspberry-Pi/Robot-7-Flask$ devbs=$(stat -fc %s $src)
peterm@peterm-MBB-34204H:~/Raspberry-Pi/Robot-7-Flask$  echo copy $src to $img 
using multiple of $devbs bytes
copy /dev/sdb to dev_sdb.img using multiple of 4096 bytes
peterm@peterm-MBB-34204H:~/Raspberry-Pi/Robot-7-Flask$ sudo dd if=$src 
bs=$((devbs * 32)) of=$img
[sudo] password for peterm:
dd: error reading '/dev/sdb': Input/output error
1769+0 records in
1769+0 records out
231866368 bytes (232 MB, 221 MiB) copied, 19.0554 s, 12.2 MB/s

peterm@peterm-MBB-34204H:~/Raspberry-Pi/Robot-7-Flask$ ls -al dev*

-rw-r--r-- 1 root root 231866368 Nov 10 13:53 dev_sdb.im

Not the same size as previous try.



--
 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