NetworkBlockDevice / nbd

Network Block Device
GNU General Public License v2.0
450 stars 116 forks source link

copyonwrite = false gives read-only system #169

Open hartmark opened 3 days ago

hartmark commented 3 days ago
% 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 commented 2 days ago

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