docs: Add VERSION section giving first version a plugin/filter appeared.
[nbdkit/ericb.git] / filters / cow / nbdkit-cow-filter.pod
blob5e5d2b9fe2c37f3120a1e2896a10699302ffbf0d
1 =head1 NAME
3 nbdkit-cow-filter - nbdkit copy-on-write (COW) filter
5 =head1 SYNOPSIS
7  nbdkit --filter=cow plugin [plugin-args...]
9 =head1 DESCRIPTION
11 C<nbdkit-cow-filter> is a filter that makes a temporary writable copy
12 on top of a read-only plugin.  It can be used to enable writes for
13 plugins which only implement read-only access.  Note that:
15 =over 4
17 =item *
19 B<Anything written is thrown away as soon as nbdkit exits.>
21 =item *
23 All connections to the nbdkit instance see the same view of the disk.
25 This is different from L<nbd-server(1)> where each connection sees its
26 own copy-on-write overlay and simply disconnecting the client throws
27 that away.  It also allows us to create diffs, see below.
29 =item *
31 The plugin is opened read-only (as if the I<-r> flag was passed), but
32 you should B<not> pass the I<-r> flag to nbdkit.
34 =item *
36 Note that the use of this filter rounds the image size down to a
37 multiple of the caching granularity (4096), to ease the
38 implementation. If you need to round the image size up instead to
39 access the last few bytes, combine this filter with
40 L<nbdkit-truncate-filter(1)>.
42 =back
44 Limitations of the filter include:
46 =over 4
48 =item *
50 The underlying file/device must not be resized.
52 =item *
54 The underlying plugin must behave “normally”, meaning that it must
55 serve the same data to each client.
57 =back
59 =head1 PARAMETERS
61 =over 4
63 =item B<cow-on-cache=true>
65 Treat a client cache request as a shortcut for copying unmodified data
66 from the plugin to the overlay, rather than the default of passing
67 cache requests on to the plugin. This parameter defaults to false
68 (which leaves the overlay as small as possible), but setting it can be
69 useful for converting cache commands into a form of copy-on-read
70 behavior, in addition to the filter's normal copy-on-write semantics.
72 =back
74 =head1 EXAMPLES
76 Serve the file F<disk.img>, allowing writes, but do not save any
77 changes into the file:
79  nbdkit --filter=cow file disk.img
81 L<nbdkit-xz-plugin(1)> only supports read access, but you can provide
82 temporary write access by doing (although this does B<not> save
83 changes to the file):
85  nbdkit --filter=cow xz disk.xz
87 =head1 CREATING A DIFF WITH QEMU-IMG
89 Although nbdkit-cow-filter itself cannot save the differences, it is
90 possible to do this using an obscure feature of L<qemu-img(1)>.
91 B<nbdkit must remain continuously running during the whole operation,
92 otherwise all changes will be lost>.
94 Run nbdkit:
96  nbdkit --filter=cow file disk.img
98 and then connect with a client and make whatever changes you need.
99 At the end, disconnect the client.
101 Run these C<qemu-img> commands to construct a qcow2 file containing
102 the differences:
104  qemu-img create -f qcow2 -b nbd:localhost diff.qcow2
105  qemu-img rebase -b disk.img diff.qcow2
107 F<diff.qcow2> now contains the differences between the base
108 (F<disk.img>) and the changes stored in nbdkit-cow-filter.  C<nbdkit>
109 can now be killed.
111 =head1 ENVIRONMENT VARIABLES
113 =over 4
115 =item C<TMPDIR>
117 The copy-on-write changes are stored in a temporary file located in
118 F</var/tmp> by default.  You can override this location by setting the
119 C<TMPDIR> environment variable before starting nbdkit.
121 =back
123 =head1 FILES
125 =over 4
127 =item F<$filterdir/nbdkit-cow-filter.so>
129 The filter.
131 Use C<nbdkit --dump-config> to find the location of C<$filterdir>.
133 =back
135 =head1 VERSION
137 C<nbdkit-cow-filter> first appeared in nbdkit 1.2.
139 =head1 SEE ALSO
141 L<nbdkit(1)>,
142 L<nbdkit-file-plugin(1)>,
143 L<nbdkit-xz-plugin(1)>,
144 L<nbdkit-truncate-filter(1)>,
145 L<nbdkit-filter(3)>,
146 L<qemu-img(1)>.
148 =head1 AUTHORS
150 Eric Blake
152 Richard W.M. Jones
154 =head1 COPYRIGHT
156 Copyright (C) 2018 Red Hat Inc.