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/nbdXblock 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. π
--objecttype,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 is10809. 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. default0.0.0.0. π«Ά-k,--socket=PATHβ use a unix socket with pathPATH. 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-fflag β instead set theformat=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 theqemu:allocation-depthmetadata context, reachable viaNBD_OPT_SET_META_CONTEXT. π-B,--bitmap=NAMEβ if filename has a qcow2 persistent bitmap namedNAME, expose that bitmap via theqemu:dirty-bitmap:NAMEmetadata context, accessible throughNBD_OPT_SET_META_CONTEXT. πΊοΈ-s,--snapshotβ use filename as an external snapshot: create a temporary file withbacking_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_PARAMformat issnapshot.id=[ID],snapshot.name=[NAME]or[ID_OR_NAME]. π--cache=CACHEβ the cache mode for the file. valid values:none,writeback(the default),writethrough,directsyncandunsafe. 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), andio_uring(Linux 5.1+). β‘--discard=DISCARDβ control whether discard requests (aka trim, aka unmap) are ignored or passed to the filesystem.DISCARDis one ofignore(oroff),unmap(oron). the default isignore. ποΈ--detect-zeroes=DETECT_ZEROESβ control the automatic conversion of plain zero writes by the OS into driver-specific optimized zero write commands.DETECT_ZEROESis one ofoff,on, orunmap. β οΈunmapconverts a zero write into an unmap operation and can only be used ifDISCARDis set tounmap. the default isoff. π³οΈ-c,--connect=DEVβ connect filename to NBD deviceDEV(Linux only). π-d,--disconnectβ disconnect the deviceDEV(Linux only). bye bestie π-e,--shared=NUMβ allow up toNUMclients to share the device (default1), or0for 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 toNseconds (default10), or0for 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 theIDof 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-hostnameto 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--listoption. π--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 theIDof 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 originalSTDERRstream open if the qemu-nbd process gets daemonized because of other options like--forkor-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 matchingPATTERN(either an event name or a globbing pattern). πͺ this option is only available if QEMU was compiled with thesimple,logorftracetracing backend. to specify multiple events or patterns, just pass the-traceoption multiple times. also: use-trace helpto print a list of names of trace points.events=FILEβ immediately enable the events listed inFILE. π the file must contain one event name per line (as listed in thetrace-events-allfile); globbing patterns are accepted too. this option is only available if QEMU was compiled with thesimple,logorftracetracing backend.file=FILEβ log output traces toFILE. π this option is only available if QEMU was compiled with thesimpletracing 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/nbddevice generally requires root privileges, and may also require runningmodprobe nbdto 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. π«‘
π Copyright π
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