QEMU-NBD(8)

πŸ’… qemu-nbd β€” QEMU Disk Network Block Device Server ✨

okay so bestie, welcome to the qemu-nbd(8) page, aka the QEMU manual. this one's a whole vibe: it's how you flex a QEMU disk image out over the network with the NBD protocol. no cap, it does a lot. πŸ¦‹


🌸 SYNOPSIS 🌸

qemu-nbd [OPTION]... filename

qemu-nbd -L [OPTION]...

qemu-nbd -d dev

like, three whole modes. pick your fighter. πŸ‘‘


✨ DESCRIPTION ✨

the main character job: export a QEMU disk image using the NBD protocol. that's the whole thing. πŸ”₯

but it's also giving... other uses, and honestly they're iconic:

  • Bind a /dev/nbdX block device to a QEMU server (on Linux).
  • Act as a client to query exports of a remote NBD server.

so it serves and it snoops. versatility queen. πŸ’…


πŸŽ€ OPTIONS πŸŽ€

quick grammar check before we start: filename is a disk image filename, or β€” if you're using --image-opts β€” a set of block driver options. and dev is an NBD device. ok now the flags, bestie. get comfy. πŸ“

  • --object type,id=ID,... β€” define a new instance of the type object class, identified by ID. the qemu(1) manual page has the full deets on which properties are supported. the ones that actually make sense to define here are the secret object (for passwords and/or encryption keys) and the tls-creds object (for TLS credentials for the qemu-nbd server or client). πŸ”‘
  • -p, --port=PORT β€” the TCP port to listen on as a server, or connect to as a client. default is 10809. yes, that exact number. 🎯
  • -o, --offset=OFFSET β€” the offset into the image. like starting a book on chapter 3. πŸ“–
  • -b, --bind=IFACE β€” the interface to bind to as a server, or connect to as a client. default 0.0.0.0. 🫢
  • -k, --socket=PATH β€” use a unix socket with path PATH. very cozy, very local. 🧚
  • --image-opts β€” treat filename as a set of image options instead of a plain filename. ⚠️ if you use this flag, do not use the -f flag β€” instead set the format= option. got it? slay.
  • -f, --format=FMT β€” force the use of the block driver for format FMT instead of auto-detecting. no guessing, we're decisive. πŸ’…
  • -r, --read-only β€” export the disk as read-only. look, don't touch. πŸ™ˆ
  • -A, --allocation-depth β€” expose allocation depth info through the qemu:allocation-depth metadata context, reachable via NBD_OPT_SET_META_CONTEXT. πŸ”
  • -B, --bitmap=NAME β€” if filename has a qcow2 persistent bitmap named NAME, expose that bitmap via the qemu:dirty-bitmap:NAME metadata context, accessible through NBD_OPT_SET_META_CONTEXT. πŸ—ΊοΈ
  • -s, --snapshot β€” use filename as an external snapshot: create a temporary file with backing_file=filename, and redirect the writes into the temporary one. ✨
  • -l, --load-snapshot=SNAPSHOT_PARAM β€” load an internal snapshot inside filename and export it as a read-only device. SNAPSHOT_PARAM format is snapshot.id=[ID],snapshot.name=[NAME] or [ID_OR_NAME]. πŸŽ€
  • --cache=CACHE β€” the cache mode for the file. valid values: none, writeback (the default), writethrough, directsync and unsafe. the emulator's -drive cache=... option docs have more info. πŸ—‚οΈ
  • -n, --nocache β€” literally just --cache=none. same energy. πŸ’€
  • --aio=AIO β€” set the asynchronous I/O mode: threads (the default), native (Linux only), and io_uring (Linux 5.1+). ⚑
  • --discard=DISCARD β€” control whether discard requests (aka trim, aka unmap) are ignored or passed to the filesystem. DISCARD is one of ignore (or off), unmap (or on). the default is ignore. πŸ—‘οΈ
  • --detect-zeroes=DETECT_ZEROES β€” control the automatic conversion of plain zero writes by the OS into driver-specific optimized zero write commands. DETECT_ZEROES is one of off, on, or unmap. ⚠️ unmap converts a zero write into an unmap operation and can only be used if DISCARD is set to unmap. the default is off. πŸ•³οΈ
  • -c, --connect=DEV β€” connect filename to NBD device DEV (Linux only). πŸ”Œ
  • -d, --disconnect β€” disconnect the device DEV (Linux only). bye bestie πŸ‘‹
  • -e, --shared=NUM β€” allow up to NUM clients to share the device (default 1), or 0 for unlimited. come one, come all. πŸŽ‰
  • -t, --persistent β€” don't exit on the last connection. she stays. πŸ‘‘
  • -x, --export-name=NAME β€” set the NBD volume export name. default is a zero-length string. 🏷️
  • -D, --description=DESCRIPTION β€” set the NBD volume export description as a human-readable string. πŸ—’οΈ
  • --handshake-limit=N β€” set the timeout for a client to successfully complete its handshake to N seconds (default 10), or 0 for no limit. ⏳
  • -L, --list β€” connect as a client and list all the details about the exports a remote NBD server is exposing. this enables list mode, and it's incompatible with options that change behavior related to a specific export (things like --export-name, --offset, ...). lowkey just window shopping. πŸ›οΈ
  • --tls-creds=ID β€” enable mandatory TLS encryption for the server by setting the ID of the TLS credentials object you previously created with --object; or provide the credentials needed for connecting as a client in list mode. πŸ”
  • --tls-hostname=hostname β€” when validating an x509 certificate received over a TLS connection, the hostname the NBD client used to connect gets checked against info in the server-provided certificate. sometimes you gotta override the hostname used for that check. for example, if the NBD client is using a tunnel from localhost to reach the remote server, use --tls-hostname to set the officially expected hostname of the remote NBD server. also works when accessing NBD over a UNIX socket where there's no inherent hostname available. ⚠️ this is only permitted when acting as an NBD client with the --list option. 🌐
  • --fork β€” fork off the server process and exit the parent once the server is running. βœ‚οΈ
  • --pid-file=PATH β€” store the server's process ID in the given file. πŸ“Œ
  • --tls-authz=ID β€” specify the ID of a qauthz object previously created with --object. this gets used to authorize connecting users against their x509 distinguished name. πŸͺͺ
  • -v, --verbose β€” display extra debugging info. this option also keeps the original STDERR stream open if the qemu-nbd process gets daemonized because of other options like --fork or -c. πŸ—£οΈ
  • -h, --help β€” display this help and exit. πŸ†˜
  • -V, --version β€” display version information and exit. ℹ️
  • -T, --trace [[enable=]PATTERN][,events=FILE][,file=FILE] β€” specify tracing options. details below πŸ‘‡
    • [enable=]PATTERN β€” immediately enable events matching PATTERN (either an event name or a globbing pattern). πŸͺ„ this option is only available if QEMU was compiled with the simple, log or ftrace tracing backend. to specify multiple events or patterns, just pass the -trace option multiple times. also: use -trace help to print a list of names of trace points.
    • events=FILE β€” immediately enable the events listed in FILE. πŸ“„ the file must contain one event name per line (as listed in the trace-events-all file); globbing patterns are accepted too. this option is only available if QEMU was compiled with the simple, log or ftrace tracing backend.
    • file=FILE β€” log output traces to FILE. πŸ“ this option is only available if QEMU was compiled with the simple tracing backend.

🌈 EXAMPLES 🌈

okay now the fun part, actual receipts. 🧾

1. start a server listening on port 10809 that exposes only the guest-visible contents of a qcow2 file, with no TLS encryption, and with the default export name (an empty string). the command is one-shot, and will block until the first successful client disconnects:

qemu-nbd -f qcow2 file.qcow2

2. start a long-running server listening with encryption on port 10810, and allow clients with a specific X.509 certificate to connect to a 1 megabyte subset of a raw file, using the export name 'subset':

qemu-nbd \
  --object tls-creds-x509,id=tls0,endpoint=server,dir=/path/to/qemutls \
  --object 'authz-simple,id=auth0,identity=CN=laptop.example.com,,\
            O=Example Org,,L=London,,ST=London,,C=GB' \
  --tls-creds tls0 --tls-authz auth0 \
  -t -x subset -p 10810 \
  --image-opts driver=raw,offset=1M,size=1M,file.driver=file,file.filename=file.raw

3. serve a read-only copy of a guest image over a Unix socket with as many as 5 simultaneous readers, with a persistent process forked as a daemon:

qemu-nbd --fork --persistent --shared=5 --socket=/path/to/sock \
  --read-only --format=qcow2 file.qcow2

4. expose the guest-visible contents of a qcow2 file via a block device /dev/nbd0 (and possibly creating /dev/nbd0p1 and friends for partitions found within), then disconnect the device when done. πŸ”Œ

⚠️ access to bind qemu-nbd to a /dev/nbd device generally requires root privileges, and may also require running modprobe nbd to enable the kernel NBD client module. CAUTION: do not use this method to mount filesystems from an untrusted guest image β€” a malicious guest may have prepared the image to attempt to trigger kernel bugs in partition probing or file system mounting. fr fr, don't do it. πŸ’€
qemu-nbd -c /dev/nbd0 -f qcow2 file.qcow2
qemu-nbd -d /dev/nbd0

5. query a remote server to see details about what export(s) it's serving on port 10809, and authenticate via PSK:

qemu-nbd \
  --object tls-creds-psk,id=tls0,dir=/tmp/keys,username=eblake,endpoint=client \
  --tls-creds tls0 -L -b remote.example.com

🫢 SEE ALSO 🫢

qemu(1), qemu-img(1) β€” go read those too, bestie, they're literally related. πŸ“š


πŸ‘‘ Author πŸ‘‘

Anthony Liguori <anthony@codemonkey.ws> β€” the icon who made this. 🫑

2026, The QEMU Project Developers


and that's the whole page!! πŸŽ‰ this was QEMU-NBD(8), version 11.1.3, dated Oct 29, 2026, from the QEMU manual. mwah, go export something legendary. πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from
  • arch rolling: qemu-img 11.1.3-1 Β· BSD-2-Clause AND BSD-2-Clause-Patent AND BSD-3-Clause AND CC0-1.0 AND FSFAP AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-only WITH Linux-syscall-note AND GPL-2.0-only WITH Linux-syscall-note OR BSD-2-Clause AND GPL-2.0-only WITH Linux-syscall-note OR BSD-3-Clause AND GPL-2.0-or-later AND GPL-2.0-or-later OR BSD-3-Clause AND GPL-2.0-or-later WITH Linux-syscall-note AND ISC AND LGPL-2.1-only OR BSD-3-Clause AND LGPL-2.0-or-later AND LGPL-2.1-or-later AND LicenseRef-Public-Domain AND MIT
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms