copyonwrite = false gives read-only system
% cat /etc/nbd-server/config
[generic]
# The [generic] section is required, even if nothing is specified
# there.
# When either of these options are specified, nbd-server drops
# privileges to the given user and group after opening ports, but
# _before_ opening files.
user = nbd
group = nbd
allowlist = true
[arch]
exportname = /srv/nbd/arch.img
copyonwrite = false
Then on another machine:
% sudo nbd-client -name arch staropramen /dev/nbd2
Negotiation: ..size = 6144MB
Connected /dev/nbd2
% sudo mount /dev/nbd2 /mnt
mount: /mnt: WARNING: source write-protected, mounted read-only.
However if I change copyonwrite = true and try again:
% sudo nbd-client -name arch staropramen /dev/nbd3
Negotiation: ..size = 6144MB
Connected /dev/nbd3
% sudo mount /dev/nbd3 /mnt
% sudo touch /mnt/foo
journal gives not much detail
% journalctl -u nbd.service -b
log with copyonwrite = true
Sep 19 02:55:43 staropramen nbd_server[113549]: Spawned a child process
Sep 19 02:55:43 staropramen nbd_server[114370]: virtstyle ipliteral
Sep 19 02:55:43 staropramen nbd_server[114370]: connect from 192.168.1.66, assigned file is /srv/nbd/arch.img
Sep 19 02:55:43 staropramen nbd_server[114370]: No authorization file, granting access.
Sep 19 02:55:43 staropramen nbd_server[114370]: Size of exported file/device is 6442450944
Sep 19 02:55:43 staropramen nbd_server[114370]: About to create map and diff file /srv/nbd/nbd-192.168.1.66-114370.diff
copyonwrite = false
Sep 19 02:58:13 staropramen nbd_server[119825]: Spawned a child process
Sep 19 02:58:13 staropramen nbd_server[120884]: virtstyle ipliteral
Sep 19 02:58:13 staropramen nbd_server[120884]: connect from 192.168.1.66, assigned file is /srv/nbd/arch.img
Sep 19 02:58:13 staropramen nbd_server[120884]: No authorization file, granting access.
Sep 19 02:58:13 staropramen nbd_server[120884]: Size of exported file/device is 6442450944
Sep 19 02:58:13 staropramen nbd_server[120884]: Starting to serve
I tried installing nbdkit and this command was able to make my img mounted writable:
sudo nbdkit file arch.img --no-fork
Which version of nbd-server was this with? I believe we fixed a bug very similar to this one not that long ago.
I used the standard version of arch Linux so it should be this version https://archlinux.org/packages/extra/x86_64/nbd/
There's an AUR package but it tracks the git repo on sourceforge. Is it still syncing over there? https://aur.archlinux.org/packages/nbd-git
I can try again with that version or change the package to point to GitHub and see how that works out.
There's an AUR package but it tracks the git repo on sourceforge. Is it still syncing over there? https://aur.archlinux.org/packages/nbd-git
I can try again with that version or change the package to point to GitHub and see how that works out.
Answering my own question. The sourceforge repo seems to not be mirrored with GitHub-commits so I have flagged the AUR package nbd-git as out of date.
There's an AUR package but it tracks the git repo on sourceforge. Is it still syncing over there? https://aur.archlinux.org/packages/nbd-git
No, we stopped syncing to sourceforge a while back.
I can try again with that version or change the package to point to GitHub and see how that works out.
Probably should try that, yes.
One more thing here:
If a file is not writable by the nbd-server process, it will mark the expor tas read-only (since any write will fail).
What are the permissions on the file /srv/nbd/arch.img? If they're writable by the "nbd" user (which you ask nbd-server to drop privileges to), then that explains why your export is read-only.
-rw-r--r-- 1 nbd nbd 6442450944 Dec 16 00:14 arch.img