nbdkit-guestfs-plugin(1)

πŸ¦‹ nbdkit-guestfs-plugin β€” the nbdkit libguestfs plugin, bestie edition

okay so this is the manual page for nbdkit-guestfs-plugin(1) from the nbdkit fam, and honestly? it's giving backstage pass to the inside of a disk image πŸ’…

✨ SYNOPSIS ✨

nbdkit [-r] guestfs
  [disk=DISK] [domain=DOMAIN] [format=FORMAT] [connect=URI]
  [mount=inspect|MOUNT] [trace=on] [debug=on] export=DEVICE|FILE

🚨 WARNING 🚨

Using nbdkit-guestfs-plugin in read-write mode on live virtual machines can be dangerous β€” like, potentially causing disk corruption dangerous. no cap. 😭 If the disk image or the VM might be live, use the -r (read-only) option and stay safe. this plugin is a menace in the best way and you gotta respect the boundaries.

🌸 EXAMPLES 🌸

Export the first partition inside a disk image called disk.img, and allow writes:

nbdkit guestfs disk=disk.img export=/dev/sda1

Export a disk image which is located inside a libvirt guest called Guest, read-only (-r option):

nbdkit -r guestfs domain=Guest mount=inspect export=/images/disk.img

πŸ’– DESCRIPTION πŸ’–

nbdkit-guestfs-plugin is an nbdkit(1) plugin that lets you access the contents of disk images over NBD. there are so many weird and wonderful uses for this, and this man page only covers the simpler ones. (the chaotic ones? iykyk.)

the parameters control these four things:

  • Which disk(s) get added to libguestfs. specifically disk=DISK and domain=DOMAIN add a single disk, or all the disks from a particular libvirt guest.
  • What, if any, filesystems inside the disk image / guest have to be mounted. use mount=inspect to do this automatically (like the guestfish(1) -i option), or else mount individual filesystems yourself.
  • What device or file from inside the disk image or guest you want to export over NBD. use export=DEVICE|FILE to specify the thing you want to export.
  • Read-only or not: use the -r option to export read-only. the default is read-write. πŸ‘‘

πŸŽ€ PARAMETERS πŸŽ€

  • connect=URI β€” this optional parameter specifies the libvirt connection URI. it's only used with the domain parameter, bestie. don't come at it with anything else.
  • debug=on β€” enable full debugging of libguestfs. heads up: you'll probably also have to use the nbdkit(1) option -v in order to actually see the messages. πŸ™ˆ
  • disk=DISK β€” add the named disk image. you may specify this option multiple times, stack 'em up.
  • domain=DOMAIN β€” add the disk(s) from the libvirt guest called DOMAIN.
  • export=DEVICE, export=FILE β€” export DEVICE or FILE (from inside the disk image or guest) over NBD.
    • Device names are the usual libguestfs names like /dev/sda1 (meaning the first partition of the first disk), or /dev/VG/LV (a logical volume), or RAID arrays etc. the device name should not be confused with host devices, okay? that's a whole different thing.
    • Filenames are similarly those located inside the guest or disk image, and always start with a / character (even for Windows guests β€” yes, even then πŸ’€).
    • Exports are writable by default. use the -r option to make them read-only. exporting read-write a live disk image or virtual machine will probably cause disk corruption. like. probably. don't do it.
  • format=FORMAT β€” this can be used to specify the format of the disk. use it before the disk=DISK argument. it works like the --format option of guestfish(1). order matters, queen.
  • mount=inspect β€” use guest inspection to mount disks. this is like guestfish -i.
  • mount=DEV, mount=DEV:MOUNTPOINT β€” mount DEV from inside the guest on MOUNTPOINT (defaults to /). this is like guestfish -m.
  • trace=on β€” enable tracing of libguestfs calls. again, you'll probably also have to use the nbdkit(1) option -v in order to see the messages. ✨

πŸ¦‹ WORKED EXAMPLES πŸ¦‹

πŸ“ Exporting a partition or logical volume inside a disk image

disk.img is a host file that contains partitions or LVM logical volumes. use the disk=disk.img option to add the disk. because you don't want to access filesystem contents, mount=... is not needed.

nbdkit guestfs disk=disk.img export=/dev/sda1

nbdkit guestfs disk=disk.img export=/dev/VG/LV

Use virt-filesystems(1) to find out what devices, partitions, LVs, filesystems etc a disk image contains. it's the detective of the group πŸ”

🌈 Exporting a partition or logical volume inside guest

Guest is the name (in libvirt) of a guest. since the guest might be live, we use the -r option to open the guest read-only. because you don't want to access filesystem contents, mount=... is not needed.

nbdkit -r guestfs domain=Guest export=/dev/sda1

nbdkit -r guestfs domain=Guest export=/dev/VG/LV

πŸ’œ Exporting a file inside a disk image

disk.img is a partitioned disk image with one filesystem that contains a file that we want to export. use the disk=disk.img option to add the disk, and mount=/dev/sda1 to specify the filesystem in the disk image. use export=/image to specify the name of the file in that filesystem that we want to export.

nbdkit guestfs disk=disk.img mount=/dev/sda1 export=/image

🧚 Exporting a file inside a virtual machine disk image

windows.img is the disk from a Windows virtual machine. use the disk=windows.img option to add the disk, and mount=inspect to auto-mount the filesystem(s) in the disk image. use export=/Users/rich/AppData/image to specify the name of the file from the guest that we want to export.

nbdkit guestfs disk=windows.img mount=inspect \
  export=/Users/rich/AppData/image

πŸ”₯ DEBUGGING πŸ”₯

to debug this plugin, use the following options:

nbdkit -f -v guestfs debug=on trace=on [...]

this enables libguestfs debugging and tracing (see guestfs-faq(1)). it also ensures that the messages are displayed by nbdkit (because of -f and -v). main character debugging energy, honestly. πŸ’…

⭐ FILES ⭐

  • $plugindir/nbdkit-guestfs-plugin.so β€” the plugin.
    • use nbdkit --dump-config to find the location of $plugindir.

πŸ‘‘ VERSION πŸ‘‘

nbdkit-guestfs-plugin first appeared in nbdkit 1.2. an icon, a legend, a pioneer. πŸŽ€

🌸 SEE ALSO 🌸

nbdkit(1), nbdkit-plugin(3), guestfish(1), guestfs(3), virt-filesystems(1), http://libguestfs.org.

πŸ’– AUTHORS πŸ’–

Richard W.M. Jones

Copyright Red Hat

πŸ“œ LICENSE πŸ“œ

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of Red Hat nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

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.


and that's the whole page, bestie! πŸ¦‹ this cutie dropped as part of nbdkit-1.48.0, dated 2026-08-22 β€” go forth and mount responsibly, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from