1nbdkit-tar-plugin(1) NBDKIT nbdkit-tar-plugin(1)
2
3
4
6 nbdkit-tar-plugin - read and write files inside tar files without
7 unpacking
8
10 nbdkit tar tar=FILENAME.tar file=PATH_INSIDE_TAR
11
13 Serve a single file inside a tarball
14 nbdkit tar tar=file.tar file=some/disk.img
15 guestfish --format=raw -a nbd://localhost
16
17 Opening a disk image inside an OVA file
18 The popular "Open Virtual Appliance" (OVA) format is really an
19 uncompressed tar file containing (usually) VMDK-format files, so you
20 could access one file in an OVA like this:
21
22 $ tar tf rhel.ova
23 rhel.ovf
24 rhel-disk1.vmdk
25 rhel.mf
26 $ nbdkit -r tar tar=rhel.ova file=rhel-disk1.vmdk
27 $ guestfish --ro --format=vmdk -a nbd://localhost
28
29 In this case the tarball is opened readonly (-r option). The plugin
30 supports write access, but writing to the VMDK file in the tarball does
31 not change data checksums stored in other files (the "rhel.mf" file in
32 this example), and as these will become incorrect you probably won't be
33 able to open the file with another tool afterwards.
34
36 "nbdkit-tar-plugin" is a plugin which can read and writes files inside
37 an uncompressed tar file without unpacking the tar file.
38
39 The "tar" and "file" parameters are required, specifying the name of
40 the uncompressed tar file and the exact path of the file within the tar
41 file to access as a disk image.
42
43 This plugin will not work on compressed tar files.
44
45 Use the nbdkit -r flag to open the file readonly. This is the safest
46 option because it guarantees that the tar file will not be modified.
47 Without -r writes will modify the tar file.
48
49 The disk image cannot be resized.
50
51 Alternatives to the tar plugin
52 The tar plugin ought to be a filter so that you can extract files from
53 within tarballs hosted elsewhere (eg. using nbdkit-curl-plugin(1)).
54 However this is hard to implement given the way that the tar(1) command
55 works.
56
57 Nevertheless you can apply the same technique even to tarballs hosted
58 remotely, provided you can run tar(1) on them first. The trick is to
59 use the "tar -tRvf" options to find the block number of the file of
60 interest. In tar files, blocks are 512 bytes in size, and there is one
61 hidden block used for the header, so you have to take the block number,
62 add 1, and multiply by 512.
63
64 For example:
65
66 $ tar -tRvf disk.tar
67 block 2: -rw-r--r-- rjones/rjones 105923072 2020-03-28 20:34 disk
68 └──┬──┘ └───┬───┘
69 offset = (2+1)*512 = 1536 range
70
71 You can then apply the offset filter:
72
73 nbdkit --filter=offset \
74 curl https://example.com/disk.tar \
75 offset=1536 range=105923072
76
77 If the remote file is compressed then add nbdkit-xz-filter(1):
78
79 nbdkit --filter=offset --filter=xz \
80 curl https://example.com/disk.tar.xz \
81 offset=1536 range=105923072
82
84 "nbdkit-tar-plugin" first appeared in nbdkit 1.2.
85
87 https://github.com/libguestfs/nbdkit/blob/master/plugins/tar/tar.pl,
88 nbdkit(1), nbdkit-offset-filter(1), nbdkit-plugin(3),
89 nbdkit-perl-plugin(3), nbdkit-xz-filter(1), tar(1).
90
92 Richard W.M. Jones.
93
94 Based on the virt-v2v OVA importer written by Tomáš Golembiovský.
95
97 Copyright (C) 2017-2020 Red Hat Inc.
98
100 Redistribution and use in source and binary forms, with or without
101 modification, are permitted provided that the following conditions are
102 met:
103
104 · Redistributions of source code must retain the above copyright
105 notice, this list of conditions and the following disclaimer.
106
107 · Redistributions in binary form must reproduce the above copyright
108 notice, this list of conditions and the following disclaimer in the
109 documentation and/or other materials provided with the
110 distribution.
111
112 · Neither the name of Red Hat nor the names of its contributors may
113 be used to endorse or promote products derived from this software
114 without specific prior written permission.
115
116 THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND ANY
117 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
118 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
119 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR CONTRIBUTORS BE
120 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
121 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
122 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
123 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
124 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
125 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
126 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
127
128
129
130nbdkit-1.18.4 2020-04-16 nbdkit-tar-plugin(1)