nbdkit-tar-plugin - Man Page

read and write files inside tar files without unpacking

Synopsis

 nbdkit tar tar=FILENAME.tar file=PATH_INSIDE_TAR

Examples

Serve a single file inside a tarball

 nbdkit tar tar=file.tar file=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 tar tar=rhel.ova file=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.

Description

nbdkit-tar-plugin is a plugin which can read and writes files inside an uncompressed tar file without unpacking the tar file.

The tar and file parameters are required, specifying the name of the uncompressed tar file and the exact path of the file within the tar file to access as a disk image.

This plugin will not work on compressed tar files.

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.

Alternatives to the tar plugin

The tar plugin ought to be a filter so that you can extract files from within tarballs hosted elsewhere (eg. using nbdkit-curl-plugin(1)). However this is hard to implement given the way that the tar(1) command works.

Nevertheless you can apply the same technique even to tarballs hosted remotely, provided you can run tar(1) on them first.  The trick is to use the tar -tRvf options to find the block number of the file of interest.  In tar files, blocks are 512 bytes in size, and there is one hidden block used for the header, so you have to take the block number, add 1, and multiply by 512.

For example:

 $ tar -tRvf disk.tar
 block 2: -rw-r--r-- rjones/rjones 105923072 2020-03-28 20:34 disk
 └──┬──┘                           └───┬───┘
 offset = (2+1)*512 = 1536           range

You can then apply the offset filter:

 nbdkit --filter=offset \
          curl https://example.com/disk.tar \
               offset=1536 range=105923072

If the remote file is compressed then add nbdkit-xz-filter(1):

 nbdkit --filter=offset --filter=xz \
          curl https://example.com/disk.tar.xz \
               offset=1536 range=105923072

Version

nbdkit-tar-plugin first appeared in nbdkit 1.2.

See Also

https://github.com/libguestfs/nbdkit/blob/master/plugins/tar/tar.pl, nbdkit(1), nbdkit-offset-filter(1), nbdkit-plugin(3), nbdkit-perl-plugin(3), nbdkit-xz-filter(1), tar(1).

Authors

Richard W.M. Jones.

Based on the virt-v2v OVA importer written by Tomáš Golembiovský.

License

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

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.

Referenced By

nbdkit(1), nbdkit-captive(1), nbdkit-offset-filter(1), nbdkit-plugin(3), nbdkit-release-notes-1.20(1).

2020-05-26 nbdkit-1.21.4