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

Re: Setting up NBD server / client - block nbd4: Other side returned error (22) issue



On Thu, Aug 26, 2021 at 08:48:35PM +0100, Richard W.M. Jones wrote:
> > [movie]
> > exportname = /home/pi/media/500G_FAITH/movies/
> > transactionlog = /home/pi/media/500G_FAITH/logs/log_movie
> 
> One problem here is that NBD is a block device export protocol, not a
> file serving protocol (like eg NFS or SMB).
> 
> You can however turn a directory into an NBD export using
> nbdkit-floppy-plugin, eg:
> 
>   $ nbdkit floppy /home/pi/media/500G_FAITH/recipes/
> 
> (https://libguestfs.org/nbdkit-floppy-plugin.1.html)
> 
> That exports a VFAT filesystem as a block device which has to be
> mounted:
> 
>   # nbd-client 192.168.1.14 10809 /dev/nbd0
>   # mkdir /mnt/recipes
>   # mount /dev/nbd0 /mnt/recipes

It is also possible to point nbdkit to a directory which will serve
every (regular) file in that directory as its own block device (in
this scenario, each block device is the content of the file, rather
than a file system to be mounted):

  # nbdkit file dir=/home/pi/media/500G_FAITH/logs/

At which point listing from that server will show one export for each
file (compared to Rich's suggestion which has just a single export
pointing to a file system that must be mounted before seeing files
within), something like:

  # nbdinfo --list nbd://192.168.1.14:10809
  protocol: newstyle-fixed without TLS
  export="log_recipes":
	export-size: 700
	uri: nbd://localhost:10809/log_recipes
	contexts:
		base:allocation
  ...
  export="log_movie":
	export-size:56
	uri: nbd://localhost:10809/log_recipes
	contexts:
		base:allocation
  ...

> > 
> > pi@rpi-C3:~ $ ls -la /home/pi/media/500G_FAITH/logs
> > -rw------- 1 pi pi     56 Aug 26 17:00 log_images
> > -rw------- 1 pi pi     56 Aug 26 17:00 log_movie
> > -rw------- 1 pi pi    700 Aug 26 17:35 log_recipes
> >

I'm actually a bit surprised that nbd-server doesn't actually report
an error when configured to try to serve a directory, as it is
generally not possible to serve the raw bytes of a directory inode
(for example, nbdkit's file plugin detects directories as different
from regular files and rejects them up front) - while you can open(2)
a directory in O_RDONLY mode, you can't read() or write() to it.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


Reply to: