nbd icon indicating copy to clipboard operation
nbd copied to clipboard

copyonwrite = false gives read-only system

Open hartmark opened this issue 1 year ago • 8 comments

% 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

hartmark avatar Sep 19 '24 01:09 hartmark

I tried installing nbdkit and this command was able to make my img mounted writable: sudo nbdkit file arch.img --no-fork

hartmark avatar Sep 20 '24 23:09 hartmark

Which version of nbd-server was this with? I believe we fixed a bug very similar to this one not that long ago.

yoe avatar Sep 28 '24 09:09 yoe

I used the standard version of arch Linux so it should be this version https://archlinux.org/packages/extra/x86_64/nbd/

hartmark avatar Sep 28 '24 10:09 hartmark

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.

hartmark avatar Sep 28 '24 10:09 hartmark

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.

hartmark avatar Sep 29 '24 21:09 hartmark

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.

yoe avatar Sep 30 '24 17:09 yoe

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.

yoe avatar Dec 20 '24 10:12 yoe

-rw-r--r-- 1 nbd nbd 6442450944 Dec 16 00:14 arch.img

hartmark avatar Dec 20 '24 11:12 hartmark