On Mon, 5 Apr 2004, Dieter Stueken wrote:
> Bruce Allen wrote:
> > I didn't know about "raw". I just read the man page -- very interesting.
> > But I don't understand why this is needed -- there's nothing that prevents
> > you from simply addressing /dev/hdc directly, using dd. Right? In other
> > words, you *could* just do:
> > dd if=/dev/hdc of=/dev/null bs=512 count=1 skip=244335596
> > (to verify the io error), then
> > dd if=/dev/zero of=/dev/hdc bs=512 count=1 seek=244335596
> > to overwrite the bad block.
> in principle yes, but using hdc, the kernels block buffering is involved.
> Thus when you try to replace 512 bytes within some 4k block, the kernel
> will read all 8 sectors first, modify the content of the block and will
> write it back again. Unfortunately this must fail, as you end up with a
> read error from the broken sector. You may be successful if, and only if
> the data you write perfectly matches a 4k block and the kernel is smart
> enough to recognize, that no reading is needed, as the whole block gets replaced.
Interesting. I thought that when you reference /dev/hdc, there is no
'file system' involved, which is where I thought that the 4kB block size
came from. Where is a 4kB block size 'wired in' to the IDE driver for
> > Dieter, if I've missed the point of 'raw', please be patient and explain
> > it. (Oh, perhaps the point is that the device driver for /dev/hda has a
> > native block size of 1kB=2 sectors. Is that it?)
> is it true? I always assumed to be 4k. Anyway, reducing any damage
> to 512 byte instead of 1k or 4k seems always worth to to, i think.
I thought that the native size of the ide driver was 512 bytes, and that
the native block size of ext2/3 was 4kB.
> In my case, I found a source-code file affected. Thus I was able to
> "dd" 512 "#" and exactly saw which lines are affected in the editor.
> Or what, if it hits a direntry or an indirect-block ....
> Also the testing seems much clearer to me. If I peek around on hdc or
> hdc1, blocks in the neighborhood of the broken sector seem to be affected,
> due to some 1k or 4k windows. This also depends on the alignment, too.
> So, your approach is not wrong, and will work fine. But I just feel even
> better, to locate end eliminate the sector exactly.
In fact I advocate locating and eliminating the sector exactly, just as
you do. HOWEVER if you want to know what FILE is affected, then you might
as well work in the block size of the relevant file system.