nbdkit-truncate-filter - Man Page
change the size of plugins
Synopsis
nbdkit --filter=truncate plugin [truncate=SIZE] [round-up=N] [round-down=N]
Description
nbdkit-truncate-filter
is a filter that changes the size of the underlying plugin. It can:
- Make the plugin smaller (truncate it). Use the
truncate=SIZE
parameter to set the smaller size. - Make the plugin larger (the additional bytes read back as zeroes). Use
truncate=SIZE
to set the larger size. - Round the size of the plugin up or down to the next multiple of
N
. Use eitherround-up=N
orround-down=N
.
A common use for this filter is to handle NBD clients which have a problem dealing with device sizes which are not a multiple of 512 bytes. Use round-up=512
to round the size up to the next multiple of 512 bytes. If the size is already a multiple of 512 bytes then this has no effect.
Parameters
- truncate=SIZE
Set the absolute size in bytes of the apparent device. This may be smaller or larger or the same as the underlying plugin.
If the size is larger than the underlying plugin, reading the extra space returns zeroes. Writes are also permitted to the extra space, but you must only write zeroes (any attempts to write non-zero bytes will return an error back to the client).
This parameter is optional.
- round-up=N
Round the size up to the next multiple of
N
bytes. If the size of the underlying plugin is already a multiple ofN
bytes, this has no effect.This option is useful when combined with other filters (such as nbdkit-blocksize-filter(1)) that normally round down due to a larger granularity, in order to access the last few bytes of a file that would otherwise be rendered inaccessible.
This parameter is optional.
- round-down=N
Round the size down to a multiple of
N
bytes. If the size of the underlying plugin is already a multiple ofN
bytes, this has no effect.This parameter is optional.
Examples
Serve a file as if it were a block device that insists on 4k alignment, while still allowing access to any unaligned bytes at the end of the file:
nbdkit --filter=blocksize --filter=truncate file /path/to/file \ minblock=4k round-up=4k
Files
- $filterdir/nbdkit-truncate-filter.so
The filter.
Use
nbdkit --dump-config
to find the location of$filterdir
.
Version
nbdkit-truncate-filter
first appeared in nbdkit 1.6.
See Also
nbdkit(1), nbdkit-file-plugin(1), nbdkit-filter(3), nbdkit-blocksize-filter(1), nbdkit-cache-filter(1), nbdkit-cow-filter(1), nbdkit-offset-filter(1), nbdkit-partition-filter(1).
Authors
Richard W.M. Jones
Copyright
Copyright Red Hat
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.
Referenced By
nbdkit(1), nbdkit-blocksize-filter(1), nbdkit-filter(3), nbdkit-offset-filter(1), nbdkit-partition-filter(1), nbdkit-release-notes-1.6(1), nbdkit-swab-filter(1).