I'd like to come back and put the solution, but go on with questions (I use to put solutions to my questions when I find them).
I've never used nbd-sever or nbd-client so I've installed both packages on the same computer and tried with something simple. Ex: A file containing a disk image. Serve it with nbd-server, access it with nbd-client. I mount it on "/root/dirdisco/mnt" for nbd-server and "/root/dirdisco/mnt2" for nbd-client.
What I've done:
-Created a file for the disk:
mkfs -t ext3 /roo/dirdisco/disco.img
- Configured nbd-server to server it. This is the configuration file:
# If you want to run everything as root rather than the nbd user, you
# may either say "root" in the two following lines, or remove them
# altogether. Do not remove the [generic] section, however.
# user = nbd
# group = nbd
allowlist = true
oldstyle = true
user = root
group = root
includedir = /etc/nbd-server/conf.d
# What follows are export definitions. You may create as much of them as
# you want, but the section header has to be unique.
exportname = /dev/bus/usb/001/006
port = 1234
exportname = /root/dirdisco/disco.img
port = 1235
- Started nbd-server
- In the same computer (to be sure there is no problem with nbd-server and nbd-client releases), I've configured nbd-client:
- Started nbd-client
- I can see devices
nbd-client -l raspberrypi
- Now, I mount the disco.img on directory /root/dirdisco/mnt and /dev/nbd0 on mnt2 as you can see:
root/dirdisco/disco.img on /root/dirdisco/mnt type ext2 (rw,relatime,sync,dirsync,user_xattr,barrier=1)
/dev/nbd0 on /root/dirdisco/mnt2 type ext2 (rw,relatime,user_xattr,barrier=1)
- If I write something on mnt, I doesn't appear on mnt2. I've to umount /root/dirdisco/mnt2 and mount it again and files created/deleted are reflected in mnt2. But I've to umount/mount mnt2 to update directory (mount -o remount doesn't update files).
So something is wrong or I don't understand nbd. I've also tried with "sync" command, but files modified on mnt are not reflected on mnt2.