nbdkit-cow-filter(1) | NBDKIT | nbdkit-cow-filter(1) |
nbdkit-cow-filter - nbdkit copy-on-write (COW) filter
nbdkit --filter=cow plugin [plugin-args...] [cow-block-size=N] [cow-on-cache=false|true] [cow-on-read=false|true|/PATH]
"nbdkit-cow-filter" is a filter that makes a temporary writable copy on top of a plugin. It can also be used to enable writes for plugins which are read-only.
The underlying plugin is opened read-only. This filter does not pass any writes or write-like operations (like trim and zero) through to the underlying plugin.
Note that anything written is thrown away as soon as nbdkit exits. If you want to save changes, either copy out the whole disk using a tool like nbdcopy(1), or use the method described in "NOTES" below to create a diff.
Limitations of the filter include:
The default is 64K.
Serve the file disk.img, allowing writes, but do not save any changes into the file.
nbdkit-xz-filter(1) only supports read access, but you can provide temporary write access by using the command above. Because xz decompression is slow, using "cow-on-read=true" causes reads to be cached as well as writes, improving performance at the expense of using more temporary space. Note that writes are thrown away when nbdkit exits and do not get saved into the file.
Although nbdkit-cow-filter itself cannot save the differences, it is possible to do this using an obscure feature of qemu-img(1). nbdkit must remain continuously running during the whole operation, otherwise all changes will be lost.
Run nbdkit:
nbdkit --filter=cow file disk.img
and then connect with a client and make whatever changes you need. At the end, disconnect the client.
Run these "qemu-img" commands to construct a qcow2 file containing the differences:
qemu-img create -F raw -b nbd:localhost -f qcow2 diff.qcow2 qemu-img rebase -F raw -b disk.img -f qcow2 diff.qcow2
diff.qcow2 now contains the differences between the base (disk.img) and the changes stored in nbdkit-cow-filter. "nbdkit" can now be killed.
All connections to the nbdkit instance see the same view of the disk. This is different from nbd-server(1) -c option where each connection sees its own copy-on-write overlay and simply disconnecting the client throws that away. It also allows us to create diffs as above.
Use "nbdkit --dump-config" to find the location of $filterdir.
"nbdkit-cow-filter" first appeared in nbdkit 1.2.
nbdkit(1), nbdkit-file-plugin(1), nbdkit-cache-filter(1), nbdkit-cacheextents-filter(1), nbdkit-xz-filter(1), nbdkit-filter(3), nbdcopy(1), qemu-img(1).
Eric Blake
Richard W.M. Jones
Copyright (C) 2018-2021 Red Hat Inc.
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.
2023-01-04 | nbdkit-1.32.5 |