nbdkit file FILENAME.tar --filter=tar tar-entry=PATH_INSIDE_TAR
Serve a single file inside a tarball
nbdkit file file.tar --filter=tar tar-entry=some/disk.img guestfish --format=raw -a nbd://localhost
Opening a disk image inside an OVA file
The popular “Open Virtual Appliance” (OVA) format is really an uncompressed tar file containing (usually) VMDK-format files, so you could access one file in an OVA like this:
$ tar tf rhel.ova rhel.ovf rhel-disk1.vmdk rhel.mf $ nbdkit -r file rhel.ova --filter=tar tar-entry=rhel-disk1.vmdk $ guestfish --ro --format=vmdk -a nbd://localhost
In this case the tarball is opened readonly (-r option). The plugin supports write access, but writing to the VMDK file in the tarball does not change data checksums stored in other files (the
rhel.mf file in this example), and as these will become incorrect you probably won't be able to open the file with another tool afterwards.
Open a disk image inside a remote tar file
You can use other plugins apart from nbdkit-file-plugin(1) to provide the tar file. For example if the tar file is located on a web server use:
nbdkit -r curl https://example.com/file.tar \ --filter=tar tar-entry=disk.img
Open a compressed tar file (read-only)
This filter cannot handle compressed tar files itself, but you can combine it with nbdkit-gzip-filter(1) or nbdkit-xz-filter(1):
nbdkit file filename.tar.gz \ --filter=tar tar-entry=disk.img --filter=gzip nbdkit file filename.tar.xz \ --filter=tar tar-entry=disk.img --filter=xz
nbdkit-tar-filter is a filter which can read and writes files inside an uncompressed tar file without unpacking the tar file.
The tar file is provided by the underlying plugin. You must tell the filter which entry in the tar file you wish to read and write using the
tar-entry must exactly match the file name in the tar index. Use
tar tf filename.tar to list the index of a tar file.
This filter will not work directly on compressed tar files. You have to combine it with another filter as shown in the example above.
Use the nbdkit -r flag to open the file readonly. This is the safest option because it guarantees that the tar file will not be modified. Without -r writes will modify the tar file.
The disk image cannot be resized.
The path of the file inside the tarball to serve. This parameter is required. It must exactly match the name stored in the tarball, so use
tar tf filename.tar
Specify the program name or full path of GNU tar, in case
$PATHis not GNU tar. This filter requires GNU tar and will not normally work with other tar programs (eg. on FreeBSD).
nbdkit-tar-filter first appeared in nbdkit 1.22. It is derived from
nbdkit-tar-plugin which first appeared in nbdkit 1.2.
nbdkit(1), nbdkit-curl-plugin(1), nbdkit-file-plugin(1), nbdkit-gzip-filter(1), nbdkit-offset-filter(1), nbdkit-plugin(3), nbdkit-ssh-plugin(1), nbdkit-xz-filter(1), tar(1).
Richard W.M. Jones.
Based on the virt-v2v OVA importer written by Tomáš Golembiovský.
Copyright (C) 2017-2020 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.
nbdkit(1), nbdkit-captive(1), nbdkit-cdi-plugin(1), nbdkit-curl-plugin(1), nbdkit-filter(3), nbdkit-gzip-filter(1), nbdkit-offset-filter(1), nbdkit-release-notes-1.22(1), nbdkit-tar-plugin(1).