nbdkit(1) | NBDKIT | nbdkit(1) |
nbdkit - toolkit for creating NBD servers
nbdkit [-4|--ipv4-only] [-6|--ipv6-only] [-D|--debug PLUGIN|FILTER|nbdkit.FLAG=N] [--exit-with-parent] [-e|--exportname EXPORTNAME] [--filter=FILTER ...] [-f|--foreground] [-g|--group GROUP] [-i|--ipaddr IPADDR] [--log=stderr|syslog|null] [--mask-handshake=MASK] [-n|--newstyle] [--no-sr] [-o|--oldstyle] [-P|--pidfile PIDFILE] [-p|--port PORT] [-r|--readonly] [--run 'COMMAND ARGS ...'] [--selinux-label=LABEL] [-s|--single] [--swap] [-t|--threads THREADS] [--tls=off|on|require] [--tls-certificates=/path/to/certificates] [--tls-psk=/path/to/pskfile] [--tls-verify-peer] [-U|--unix SOCKET|-] [-u|--user USER] [-v|--verbose] [--vsock] PLUGIN [[KEY=]VALUE [KEY=VALUE [...]]] nbdkit --dump-config nbdkit PLUGIN --dump-plugin nbdkit --help nbdkit [-V|--version]
Network Block Device (NBD) is a network protocol for accessing block devices over the network. Block devices are hard disks and things that behave like hard disks such as disk images and virtual machines.
nbdkit is both a toolkit for creating NBD servers from “unconventional” sources, and the name of an NBD server. nbdkit ships with many plugins for performing common tasks like serving local files.
nbdkit is different from other NBD servers because you can easily create new Network Block Device sources by writing a few glue functions, possibly in C, or perhaps in a high level language like Perl or Python. The liberal licensing of nbdkit is meant to allow you to link nbdkit with proprietary libraries or to include nbdkit in proprietary code.
If you want to write your own nbdkit plugin you should read nbdkit-plugin(3).
nbdkit also has a concept of filters which can be layered on top of plugins. Several filters are provided with nbdkit and if you want to write your own you should read nbdkit-filter(3).
nbdkit file disk.img guestfish --rw --format=raw -a nbd://localhost
nbdkit --tls=require file disk.img
nbdkit data ' ( 0x55 0xAA )*2048 '
nbdkit -r curl https://example.com/disk.img
nbdkit ssh host=example.com /var/tmp/disk.img
nbdkit memory 1T nbd-client localhost /dev/nbd0
nbdkit floppy dir/
nbdkit --filter=partition --filter=xz file disk.img.xz partition=1
To understand this command line:
plugin name and plugin parameter │ ┌───────┴──────┐ │ │ nbdkit --filter=partition --filter=xz file disk.img.xz partition=1 │ │ │ └──────────────┴────┬─────────────────────┘ │ filters and filter parameter
nbdkit --filter=error --filter=delay memory 100M \ error-rate=10% rdelay=1 wdelay=1
nbdkit sh - <<'EOF' case "$1" in get_size) echo 1M ;; pread) dd if=/dev/zero count=$3 iflag=count_bytes ;; *) exit 2 ;; esac EOF
nbdkit eval get_size='echo 1M' \ pread='dd if=/dev/zero count=$3 iflag=count_bytes'
Display information about nbdkit or a specific plugin:
nbdkit --help nbdkit --version nbdkit --dump-config nbdkit example1 --help nbdkit example1 --dump-plugin
When the -i option is omitted, listen on only the IPv4 or IPv6 address of all interfaces (0.0.0.0 or "::", respectively).
When both -4 and -6 options are present on the command line, the last one takes effect.
Set the nbdkit server Debug Flag called "FLAG" to the integer value "N". See "SERVER DEBUG FLAGS" below.
An alternative to this is "CAPTIVE NBDKIT" in nbdkit-captive(1).
This option implies --foreground.
If not set, the --run environment is set to access the default exportname "" (empty string).
The server needs sufficient permissions to be able to do this. Normally this would mean starting the server up as root.
See also -u.
The default is to send error messages to stderr, unless nbdkit forks into the background in which case they are sent to syslog.
For more details see "LOGGING" in nbdkit-service(1).
If the file already exists, it is overwritten. nbdkit does not delete the file when it exits.
Note that some plugins inherently don't support writes. With those plugins the -r option is added implicitly.
nbdkit-cow-filter(1) can be placed over read-only plugins to provide copy-on-write (or "snapshot") functionality. If you are using qemu as a client then it also supports snapshots.
Note that the command is executed by /bin/sh. On some platforms like Debian this might not be a full-featured shell.
This option implies --foreground.
The common — perhaps only — use of this option is to allow libvirt guests which are using SELinux and sVirt confinement to access nbdkit Unix domain sockets. The example below shows how to do this. Note that the socket and filesystem labels are different.
nbdkit -U /tmp/sock --selinux-label=system_u:object_r:svirt_socket_t:s0 ... chcon system_u:object_r:svirt_image_t:s0 /tmp/sock
You can use this option to run nbdkit from inetd or similar superservers; or just for testing; or if you want to run nbdkit in a non-conventional way. Note that if you want to run nbdkit from systemd, then it may be better to use "SOCKET ACTIVATION" in nbdkit-service(1) instead of this option.
This option implies --foreground.
Specifies that the NBD device will be used as swap space loop mounted on the same machine which is running nbdkit. To avoid deadlocks this locks the whole nbdkit process into memory using mlockall(2). This may require additional permissions, such as starting the server as root or raising the "RLIMIT_MEMLOCK" (ulimit(1) -l) limit on the process.
nbdkit creates this socket, but it will probably have incorrect permissions (too permissive). If it is a problem that some unauthorized user could connect to this socket between the time that nbdkit starts up and the authorized user connects, then put the socket into a directory that has restrictive permissions.
nbdkit does not delete the socket file when it exits. The caller should delete the socket file after use (else if you try to start nbdkit up again you will get an "Address already in use" error).
If the socket name is - then nbdkit generates a randomly named private socket. This is useful with "CAPTIVE NBDKIT" in nbdkit-captive(1).
The server needs sufficient permissions to be able to do this. Normally this would mean starting the server up as root.
See also -g.
It's a good idea to use -f as well so the process does not fork into the background (but not required).
The --dump-config option provides separate major and minor numbers and may be easier to parse from shell scripts.
Use the AF_VSOCK protocol (instead of TCP/IP). You must use this in conjunction with -p/--port. See "AF_VSOCK" in nbdkit-service(1).
You can give the full path to the plugin, like this:
nbdkit $libdir/nbdkit/plugins/nbdkit-file-plugin.so [...]
but it is usually more convenient to use this equivalent syntax:
nbdkit file [...]
$libdir is set at compile time. To print it out, do:
nbdkit --dump-config
After specifying the plugin name you can (optionally, it depends on the plugin) give plugin configuration on the command line in the form of "key=value". For example:
nbdkit file file=disk.img
To list all the options supported by a plugin, do:
nbdkit --help file
To dump information about a plugin, do:
nbdkit file --dump-plugin
Some plugins declare a special "magic config key". This is a key which is assumed if no "key=" part is present. For example:
nbdkit file disk.img
is assumed to be "file=disk.img" because the file plugin declares "file" as its magic config key. There can be ambiguity in the parsing of magic config keys if the value might look like a "key=value". If there could be ambiguity then modify the value, eg. by prefixing it with "./"
There is also a special exception for plugins which do not declare a magic config key, but where the first plugin argument does not contain an '=' character: it is assumed to be "script=value". This is used by scripting language plugins:
nbdkit perl foo.pl [args...]
has the same meaning as:
nbdkit perl script=foo.pl [args...]
You can use "#!" to run nbdkit plugins written in most scripting languages. The file should be executable. For example:
#!/usr/sbin/nbdkit perl sub open { # etc }
(see nbdkit-perl-plugin(3) for a full example).
As well as enabling or disabling debugging in the server using --verbose you can control extra debugging in the server using the -D nbdkit.* flags listed in this section. Note these flags are an internal implementation detail of the server and may be changed or removed at any time in the future.
-D nbdkit.backend.datapath=0 is the more useful setting which lets you suppress messages about pread, pwrite, zero, trim, etc. commands. When transferring large amounts of data these messages are numerous and not usually very interesting.
-D nbdkit.backend.controlpath=0 suppresses the non-datapath commands (config, open, close, can_write, etc.)
nbdkit responds to the following signals:
nbdkit-captive(1) — Run nbdkit under another process and have it reliably cleaned up.
nbdkit-client(1) — How to mount NBD filesystems on a client machine.
nbdkit-loop(1) — Use nbdkit with the Linux kernel client to create loop devices and loop mounts.
nbdkit-probing(1) — How to probe for nbdkit configuration and plugins.
nbdkit-protocol(1) — Which parts of the NBD protocol nbdkit supports.
nbdkit-security(1) — Lists past security issues in nbdkit.
nbdkit-service(1) — Running nbdkit as a service, and systemd socket activation.
nbdkit-tls(1) — Authentication and encryption of NBD connections (sometimes incorrectly called "SSL").
nbdkit-cdi-plugin(1), nbdkit-curl-plugin(1), nbdkit-data-plugin(1), nbdkit-eval-plugin(1), nbdkit-example1-plugin(1), nbdkit-example2-plugin(1), nbdkit-example3-plugin(1), nbdkit-example4-plugin(1), nbdkit-file-plugin(1), nbdkit-floppy-plugin(1), nbdkit-full-plugin(1), nbdkit-guestfs-plugin(1), nbdkit-info-plugin(1), nbdkit-iso-plugin(1), nbdkit-libvirt-plugin(1), nbdkit-linuxdisk-plugin(1), nbdkit-memory-plugin(1), nbdkit-nbd-plugin(1), nbdkit-null-plugin(1), nbdkit-ondemand-plugin(1), nbdkit-partitioning-plugin(1), nbdkit-pattern-plugin(1), nbdkit-random-plugin(1), nbdkit-S3-plugin(1), nbdkit-sparse-random-plugin(1), nbdkit-split-plugin(1), nbdkit-ssh-plugin(1), nbdkit-tmpdisk-plugin(1), nbdkit-torrent-plugin(1), nbdkit-vddk-plugin(1), nbdkit-zero-plugin(1) ; nbdkit-cc-plugin(3), nbdkit-golang-plugin(3), nbdkit-lua-plugin(3), nbdkit-ocaml-plugin(3), nbdkit-perl-plugin(3), nbdkit-python-plugin(3), nbdkit-ruby-plugin(3), nbdkit-rust-plugin(3), nbdkit-sh-plugin(3), nbdkit-tcl-plugin(3) .
nbdkit-blocksize-filter(1), nbdkit-blocksize-policy-filter(1), nbdkit-cache-filter(1), nbdkit-cacheextents-filter(1), nbdkit-checkwrite-filter(1), nbdkit-cow-filter(1), nbdkit-ddrescue-filter(1), nbdkit-delay-filter(1), nbdkit-error-filter(1), nbdkit-exitlast-filter(1), nbdkit-exitwhen-filter(1), nbdkit-exportname-filter(1), nbdkit-ext2-filter(1), nbdkit-extentlist-filter(1), nbdkit-fua-filter(1), nbdkit-gzip-filter(1), nbdkit-ip-filter(1), nbdkit-limit-filter(1), nbdkit-log-filter(1), nbdkit-luks-filter(1), nbdkit-multi-conn-filter(1), nbdkit-nocache-filter(1), nbdkit-noextents-filter(1), nbdkit-nofilter-filter(1), nbdkit-noparallel-filter(1), nbdkit-nozero-filter(1), nbdkit-offset-filter(1), nbdkit-partition-filter(1), nbdkit-pause-filter(1), nbdkit-protect-filter(1), nbdkit-rate-filter(1), nbdkit-readahead-filter(1), nbdkit-retry-filter(1), nbdkit-retry-request-filter(1), nbdkit-scan-filter(1), nbdkit-stats-filter(1), nbdkit-swab-filter(1), nbdkit-tar-filter(1), nbdkit-tls-fallback-filter(1), nbdkit-truncate-filter(1), nbdkit-xz-filter(1) .
nbdkit-cc-plugin(3), nbdkit-golang-plugin(3), nbdkit-lua-plugin(3), nbdkit-ocaml-plugin(3), nbdkit-perl-plugin(3), nbdkit-python-plugin(3), nbdkit-ruby-plugin(3), nbdkit-rust-plugin(3), nbdkit-sh-plugin(3), nbdkit-tcl-plugin(3) .
nbdkit-release-notes-1.32(1), nbdkit-release-notes-1.30(1), nbdkit-release-notes-1.28(1), nbdkit-release-notes-1.26(1), nbdkit-release-notes-1.24(1), nbdkit-release-notes-1.22(1), nbdkit-release-notes-1.20(1), nbdkit-release-notes-1.18(1), nbdkit-release-notes-1.16(1), nbdkit-release-notes-1.14(1), nbdkit-release-notes-1.12(1), nbdkit-release-notes-1.10(1), nbdkit-release-notes-1.8(1), nbdkit-release-notes-1.6(1), nbdkit-release-notes-1.4(1).
guestfish(1), libnbd(3), nbd-client(1), nbdcopy(1), nbdfuse(1), nbdinfo(1), nbdsh(1), qemu(1).
http://gitlab.com/nbdkit/nbdkit — Source code.
qemu-nbd(1), nbd-server(1), https://bitbucket.org/hirofuchi/xnbd.
https://github.com/NetworkBlockDevice/nbd/blob/master/doc/proto.md, https://nbd.sourceforge.io/.
https://en.wikipedia.org/wiki/iSCSI, https://en.wikipedia.org/wiki/ATA_over_Ethernet, https://en.wikipedia.org/wiki/Fibre_Channel_over_Ethernet.
gnutls_priority_init(3), qemu-img(1), psktool(1), systemd.socket(5).
Eric Blake
Laszlo Ersek
Richard W.M. Jones
Yann E. MORIN
Nikolaus Rath
François Revol
Nir Soffer
Alan Somers
Pino Toscano
Copyright (C) 2013-2020 Red Hat Inc.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2023-01-04 | nbdkit-1.32.5 |