Re: 2.4: "access beyond end of device" after ext2 mount

From: Sytse Wielinga
Date: Tue Jan 18 2005 - 11:02:09 EST


On Tue, Jan 18, 2005 at 04:20:06PM +0100, Mario Holbe wrote:
> On Tue, Jan 18, 2005 at 03:17:07PM +0100, Sytse Wielinga wrote:
> > Why not just use dd if=/dev/xxx `blockdev --getbsz /dev/xxx` ...?
>
> because it doesn't work, as I've demonstrated in
> Message-ID: <20050118082022.GA2839@xxxxxxxxxxxxxxxxxxx>
>
> > root@darkside:~# dd if=/dev/hdg7 of=/dev/null bs=512
> > attempt to access beyond end of device
> > 22:07: rw=0, want=4996184, limit=4996183
> > dd: reading `/dev/hdg7': Input/output error
> > 9992360+0 records in
> > 9992360+0 records out
> > 5116088320 bytes transferred in 92,603241 seconds (55247400 bytes/sec)
> > root@darkside:~#
> >
> > Fixing dd's blocksize to 512 doesn't help either.

That's not what I said; the block size of /dev/hdg7 there is 4096, not 512.
Besides, the blocksize of dd is 512 by default and independent of the blocksize
of the device.

Anyhow, the block size set for dd doesn't matter as even if the block size is
huge dd copies over the last partial block. The problem was that with the 2.4
kernel only whole blocks are usable, but it rounds off the device size to
multiples of the sector size (i.e., not; the device size is given in multiples
of the sector size, which, by default, is 512) instead of rounding off to
multiples of the block size. The 2.6 kernel does not have this problem; it
appears to accept partial blocks, and doesn't even appear to calculate the
device size (blockdev --getsz and --getsize return 0 on my machine.)

I think the fix could be as simple as rounding off the device size in one
location, but, as I haven't had a look at the source, I'm not sure, maybe every
driver needs a fix.

Sytse
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/