descriptionThe Network Block Device is a Linux-originated lightweight block access protocol that allows one to export a block device to a client.
homepage URLhttps://nbd.sourceforge.io/
repository URLhttps://github.com/NetworkBlockDevice/nbd.git
ownereblake@redhat.com
last changeSat, 28 Sep 2024 11:28:49 +0000 (28 13:28 +0200)
last refreshThu, 21 Nov 2024 08:43:11 +0000 (21 09:43 +0100)
content tags
add:
README.md

NBD README

Welcome to the NBD userland support files!

This package contains nbd-server and nbd-client.

To install the package, download the source and do the normal configure/make/make install dance. You'll need to install it on both the client and the server.

For compiling from git, do a checkout, install the SGML tools (docbook2man), and then run './autogen.sh' while inside your checkout. Then, see above.

Contributing

If you want to send a patch, please do not open a pull request; instead, send it to the mailinglist

Security issues

If you think you found a security problem in NBD, please contact the mailinglist. Do not just file an issue for this (although you may do so too if you prefer).

For embargoed issues, please contact Wouter Verhelst <wouter@debian.org>

Using NBD

NBD is quite easy to use. First, on the client, you need to load the module and, if you're not using udev, to create the device nodes:

# modprobe nbd
# cd /dev
# ./MAKEDEV nbd0

(if you need more than one NBD device, repeat the above command for nbd1, nbd2, ...)

Next, write a configuration file for the server. An example looks like this:

# This is a comment
[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
[export1]
    exportname = /export/nbd/export1-file
    authfile = /export/nbd/export1-authfile
    timeout = 30
    filesize = 10000000
    readonly = false
    multifile = false
    copyonwrite = false
    prerun = dd if=/dev/zero of=%s bs=1k count=500
    postrun = rm -f %s
[otherexport]
    exportname = /export/nbd/experiment
    # The other options are all optional

The configuration file is parsed with GLib's GKeyFile, which parses key files as they are specified in the Freedesktop.org Desktop Entry Specification, as can be found at <http://freedesktop.org/Standards/desktop-entry-spec>. While this format was not intended to be used for configuration files, the glib API is flexible enough for it to be used as such.

Now start the server:

nbd-server -C /path/to/configfile

Note that the filename must be an absolute path; i.e., something like /path/to/file, not ../file. See the nbd-server manpage for details on any available options.

Finally, you'll be able to start the client:

nbd-client <hostname> -N <export name> <nbd device>

e.g.,

nbd-client 10.0.0.1 -N otherexport /dev/nbd0

will use the second export in the above example (the one that exports /export/nbd/experiment)

nbd-client must be ran as root; the same is not true for nbd-server (but do make sure that /var/run is writeable by the server that nbd-server runs as; otherwise, you won't get a PID file, though the server will keep running).

There are packages (or similar) available for most current operating systems; see the "Packaging status" badge below for details.

For questions, please use the nbd@other.debian.org mailinglist.

Alternate implementations

Besides this project, the NBD protocol has been implemented by various other people. A (probably incomplete) list follows:

Additionally, these implementations once existed but are now no longer maintained:

Badges

Download Network Block Device Coverity Scan Build Status CII badge Travis

Packaging status

shortlog
2024-09-28 Wouter VerhelstRefactor the negotiate() and connected functionsmaster
2024-09-28 Josef Baciknbd: add nbd-get-status
2024-08-18 Wouter VerhelstDrop note about sourceforge.
2024-08-13 Eric Blakedocs: Tweak location of qemu nbd extensions
2024-08-06 Wouter VerhelstStop using gcc linker magic
2024-08-06 Wouter VerhelstDrop gznbd
2024-08-06 Wouter VerhelstReimplement daemonize() without using daemon()
2024-08-06 Wouter VerhelstClarify error message when not root
2024-07-25 Khem Rajnbd-client: Fix build on musl + gcc14
2024-05-15 Wouter VerhelstDepend on the nbd module being loaded
2024-05-15 Lars H. Rohwedderbuffer is 'const void*' in output functions, as in...
2024-04-24 rokerumask(77) -> umask(077): "allow rwx permission for...
2024-04-24 rokerclean-up headers necessary for treefiles.o, minor sourc...
2024-04-07 Wouter VerhelstActually, do this differently
2024-04-07 Wouter VerhelstEnable TLS1.3 by default
2024-04-03 Wouter VerhelstDrop now-superfluous g_key_file_free()
...
tags
8 months ago nbd-3.26.1 Tagging NBD 3.26.1
8 months ago nbd-3.26 Tagging NBD 3.26
18 months ago nbd-3.25 Tagging NBD 3.25
19 months ago exthdr-v3
2 years ago nbd-debian-3.19-3 Tagging NBD for Debian 1:3.19-3
2 years ago nbd-debian-3.21-1 Tagging NBD 1:3.21-1 for Debian
2 years ago nbd-debian-3.24-1 Tagging NBD Debian 1:3.24-1
2 years ago nbd-3.24 Tagging NBD 3.24
2 years ago exthdr-v1
3 years ago nbd-3.23 Tagging NBD 3.23
3 years ago nbd-debian-3.22-1 NBD for Debian 3.22-1
3 years ago nbd-3.22 Tagging NBD 3.22
3 years ago nbd-3.21 Tagging NBD 3.21
5 years ago nbd-debian-3.20-1 Tagging NBD for Debian 1:3.20-1
5 years ago nbd-3.20 Tagging NBD 3.20
5 years ago nbd-debian-3.19-2 Tagging NBD 1:3.19-2
...
heads
7 weeks ago master
2 months ago debian
19 months ago extension-ext-header
19 months ago structured
6 years ago extension-structured-request
6 years ago extension-blockstatus
6 years ago extension-structured-reply
7 years ago extension-resize
7 years ago 3.15
7 years ago 3.7-fix-flags
7 years ago extension-write-zeroes
8 years ago debian-jessie
9 years ago debian-wheezy
14 years ago plugin
forks
Cached version (5075s old)
nbd/ericb.git Eric Blake's pending patches for NBD eblake@redhat.com 19 months ago