virt-inspector is a very convenient tool to examine a disk image and find out if it contains an operating system, what applications are installed and so on.
nbdkit xz file=win7.img.xz -U - --run 'virt-inspector --format=raw -a nbd://?socket=$unixsocket'
What’s happening here is we run nbdkit with the xz plugin, and tell it to serve NBD over a randomly named Unix domain socket (
We then run virt-inspector as a sub-process. This is called “captive nbdkit”. (Nbdkit is “captive” here, because it will exit as soon as virt-inspector exits, so there’s no need to clean anything up.)
$unixsocket variable expands to the name of the randomly generated Unix domain socket, forming a libguestfs NBD URL which allows virt-inspector to examine the raw uncompressed data exported by nbdkit.
The nbdkit xz plugin only uncompresses those blocks of the data which are actually accessed, so this is quite efficient.
Source From: fedoraplanet.org.
Original article title: Richard W.M. Jones: Tip: Run virt-inspector on a compressed disk (with nbdkit).
This full article can be read at: Richard W.M. Jones: Tip: Run virt-inspector on a compressed disk (with nbdkit).