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

Re: Linux kernel NBD sector size (1K) has peculiar effects



On Tue, Sep 04, 2018 at 02:02:36PM +0100, Richard W.M. Jones wrote:
> Let's say you have an NBD exported disk which contains an MBR
> partition:
> 
>   # nbd-client localhost /dev/nbd0
>   Warning: the oldstyle protocol is no longer supported.
>   This method now uses the newstyle protocol with a default export
>   Negotiation: ..size = 10240MB
>   Connected /dev/nbd0
> 
> On creating /dev/nbd0 the kernel complains:
> 
>   [ 3083.308232] nbd0: p1 size 41938944 extends beyond EOD, truncated
> 
> and fdisk shows:
> 
>   # fdisk -l /dev/nbd0
>   Disk /dev/nbd0: 10 GiB, 10737418240 bytes, 10485760 sectors
>   Units: sectors of 1 * 1024 = 1024 bytes
>   Sector size (logical/physical): 1024 bytes / 1024 bytes
>   I/O size (minimum/optimal): 1024 bytes / 1024 bytes
>   Disklabel type: dos
>   Disk identifier: 0x000127ae
>   
>   Device      Boot Start      End  Sectors Size Id Type
>   /dev/nbd0p1       2048 20971519 20969472  20G 83 Linux
> 
> I think what's happening here is that because the Linux kernel NBD
> driver uses the odd 1K sector size, and because MBR partitions use
> sector numbers throughout, everything is getting doubled.
> 
> Suggested (and completely *untested*) fix would be:
> 
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c

Sorry, ignore this patch.

I've just noticed the -block-size parameter of nbd-client.  Using
‘nbd-client -b 512’ does indeed fix the problem.

Is 1K a good default choice?

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org


Reply to: