$filterdir/nbdkit-tar-filter.so
The plugin.
Use "nbdkit --dump-config" to find the location of $filterdir.
Read and write files inside tar files without unpacking
nbdkit file
FILENAME.tar
--filter=tar
tar-entry=PATH_INSIDE_TAR
[tar=TAR_COMMAND]
[tar-limit=SIZE]
nbdkit file file.tar --filter=tar tar-entry=some/disk.imgguestfish --format=raw -a nbd://localhost
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.ovarhel.ovfrhel-disk1.vmdkrhel.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.
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
This filter cannot handle compressed tar files itself, but you can combine it with a decompression filter such as nbdkit-gzip-filter(1) or nbdkit-xz-filter(1):
nbdkit file filename.tar.gz \--filter=tar tar-entry=disk.img --filter=gzipnbdkit 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" parameter. "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.
tar-entry=]PATH_INSIDE_TARThe 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"
tar-limit=]SIZEWhen opening the tar file we have to locate the file ("tar-entry") inside the tarball. Because tar files do not have a central index we must iterate over the tar file to find the entry, and that may be costly (especially with untrusted tar files). In the worst case where "tar-entry" starts near the end of the file we may have to iterate over the whole tar file. If this is a problem you may set "tar-limit" to some smaller value, eg:
nbdkit -r curl https://example.com/file.tar \--filter=tar tar-entry=disk.img \tar-limit=10M
which ensures no more than 10 megabytes are read before we give up and reject the tar file (sending an error back to the NBD client).
The default is 0 meaning no limit.
tar=gtartar=/PATH/TO/GTARSpecify the program name or full path of GNU tar, in case "tar" on $PATH is not GNU tar. This filter requires GNU tar and will not normally work with other tar programs (eg. on FreeBSD).
$filterdir/nbdkit-tar-filter.so
The plugin.
Use "nbdkit --dump-config" to find the location of $filterdir.
"nbdkit-tar-filter" first appeared in nbdkit 1.22. It is derived from "nbdkit-tar-plugin" which first appeared in nbdkit 1.2.
3 releases since Debian 11 (Bullseye); the text changed 2 times.