nbdkit-tar-plugin(1)

๐Ÿ“ฆ version 1.24.1, in ubuntu jammy

๐ŸŽ€ nbdkit-tar-plugin ๐ŸŽ€

okay so this is the manual page for nbdkit-tar-plugin(1) and bestie, it's a whole vibe, let me tell you everything ๐Ÿ’…


๐ŸŒธ NAME ๐ŸŒธ

nbdkit-tar-plugin โ€” read and write files inside tar files without unpacking


โœจ SYNOPSIS โœจ

nbdkit tar [tar=]FILENAME.tar file=PATH_INSIDE_TAR

that's it. that's the whole incantation. slay ๐Ÿซถ


๐Ÿ’€ DEPRECATED ๐Ÿ’€

not me having to tell you this butโ€ฆ the tar plugin is deprecated in nbdkit โ‰ฅ 1.22 and will be removed in nbdkit 1.26. it's giving "on its way out".

It got replaced by a filter with the exact same functionality, so go peek at nbdkit-tar-filter(1) instead. You can use the filter like this:

nbdkit file FILENAME.tar --filter=tar tar-entry=PATH_INSIDE_TAR

same energy, new outfit โœจ


๐Ÿฆ‹ EXAMPLES ๐Ÿฆ‹

Serve a single file inside a tarball

nbdkit tar file.tar file=some/disk.img
guestfish --format=raw -a nbd://localhost

literally that easy. no unpacking, no mess, no crumbs ๐Ÿ’–

Opening a disk image inside an OVA file

So the popular "Open Virtual Appliance" (OVA) format? It's really just an uncompressed tar file containing (usually) VMDK-format files. So you can access one file in an OVA like this:

$ tar tf rhel.ova
rhel.ovf
rhel-disk1.vmdk
rhel.mf
$ nbdkit -r tar rhel.ova file=rhel-disk1.vmdk
$ guestfish --ro --format=vmdk -a nbd://localhost

In this case the tarball is opened readonly (the -r option). Now listen โ€” the plugin does support write access, but writing to the VMDK file inside the tarball does not change the data checksums stored in the other files (the rhel.mf file in this example), and since those will become incorrect you probably won't be able to open the file with another tool afterwards. so likeโ€ฆ don't ๐Ÿ™ˆ


๐ŸŒˆ DESCRIPTION ๐ŸŒˆ

nbdkit-tar-plugin is a plugin which can read and write files inside an uncompressed tar file without unpacking the tar file. the way that it justโ€ฆ reaches inside the tarball? iconic.

The tar and file parameters are required โ€” you're specifying the name of the uncompressed tar file, plus 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. no zips, no gz, no xz, nope, not today ๐Ÿ’€

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

Also: the disk image cannot be resized. it's giving fixed size, no glow-up available ๐Ÿ˜ญ


๐Ÿ’œ PARAMETERS ๐Ÿ’œ

  • [tar=]FILENAME.tar โ€” the path of the tarball. This parameter is required.

tar= is a magic config key and may be omitted in most cases. See "Magic parameters" in nbdkit(1). iykyk โœจ

  • file=PATH_INSIDE_TAR โ€” 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 to check, bestie. no guessing ๐Ÿ”

๐Ÿ‘‘ NOTE ๐Ÿ‘‘

Alternatives to the tar plugin

ngl, the tar plugin ought to be a filter so that you could 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. it's a whole situation ๐Ÿ˜ญ

But!! 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. math girlies rise up ๐Ÿงฎโœจ

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

see? stacking filters like accessories ๐Ÿ’…๐Ÿ”ฅ


โญ VERSION โญ

nbdkit-tar-plugin first appeared in nbdkit 1.2. a little legend from the start ๐ŸŽ€


๐ŸŒธ SEE ALSO ๐ŸŒธ

nbdkit(1), nbdkit-offset-filter(1), nbdkit-plugin(3), nbdkit-tar-filter(1), nbdkit-xz-filter(1), tar(1).


๐Ÿ’– AUTHORS ๐Ÿ’–

Richard W.M. Jones.

Based on the virt-v2v OVA importer written by Tomรกลก Golembiovskรฝ.


Copyright (C) 2017-2020 Red Hat Inc.


๐Ÿ“œ LICENSE ๐Ÿ“œ

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.


and that's the whole page, bestie ๐Ÿซถ this one's from nbdkit-1.24.1, dated 2021-01-20, and it's the nbdkit-tar-plugin(1) manual โ€” go forth and read your tarballs, ily, mwah ๐Ÿ’‹โœจ

๐Ÿ“ฆ where this page comes from