[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dd - behavior on read error

From: Pádraig Brady
Subject: Re: dd - behavior on read error
Date: Mon, 10 Apr 2017 08:05:54 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 10/04/17 06:37, David Balažic wrote:
> Hi!
> Using dd on Ubuntu 16.04.2 LTS (64 bit) I discovered this behavior
> that was (for me) unexpected.
> There is a bad sector on /dev/sda which on read attempt returns an i/o error.
> Suppose it is sector number 50.
> So: dd if=/dev/sda bs=512 count=1 skip=50
> result: I/O error printed on stderr, exit status code is 1 (non zero,
> don't remember the exact value)
> But this: dd if=/dev/sda bs=2048 count=1 skip=12
> returns exit code 0 and no error. It reads 1024 bytes (up to the
> erroring sector)
> Is this by design? I would expect an I/O error to be reported (in exit code).

Your probably hitting the default short read behavior of dd
which is defined by POSIX.  I.E. the read() system call will
return what's available before returning the read() error,
however with a count=1 dd will only consider the first read operation.

You can change this operation with the iflag=fullblock flag.
Note also the conv=sync,noerror settings which would be useful
for reading as much as possible from the disk.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]