DOKK / manpages / debian 12 / nbdkit-plugin-guestfs / nbdkit-guestfs-plugin.1.en
nbdkit-guestfs-plugin(1) NBDKIT nbdkit-guestfs-plugin(1)

nbdkit-guestfs-plugin - nbdkit libguestfs plugin

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

Using nbdkit-guestfs-plugin in read-write mode on live virtual machines can be dangerous, potentially causing disk corruption. Use the -r (read-only) option to use this plugin safely if the disk image or virtual machine might be live.

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

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

The parameters control:

  • Which disk(s) are 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 guestfish(1) -i option), else mount individual filesystems.
  • 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 that you want to export.
  • Use the -r option to export read-only. The default is read-write.

This optional parameter specifies the libvirt connection URI. This is only used with the "domain" parameter.
Enable full debugging of libguestfs. Note you'll probably also have to use the nbdkit(1) option -v in order to see the messages.
Add the named disk image. You may specify this option multiple times.
Add the disk(s) from the libvirt guest called "DOMAIN".
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.

Filenames are similarly those located inside the guest or disk image, and always start with a "/" character (even for Windows guests).

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.

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).
Use guest inspection to mount disks. This is like "guestfish -i".
Mount "DEV" from inside the guest on "MOUNTPOINT" (defaults to /). This is like "guestfish -m".
Enable tracing of libguestfs calls. Note you'll probably also have to use the nbdkit(1) option -v in order to see the messages.

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.

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

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

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

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).

$plugindir/nbdkit-guestfs-plugin.so
The plugin.

Use "nbdkit --dump-config" to find the location of $plugindir.

"nbdkit-guestfs-plugin" first appeared in nbdkit 1.2.

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

Richard W.M. Jones

Copyright (C) 2013 Red Hat Inc.

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.

2023-01-04 nbdkit-1.32.5