Scroll to navigation

nbdkit-truncate-filter(1) NBDKIT nbdkit-truncate-filter(1)

NAME

nbdkit-truncate-filter - 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 either "round-up=N" or "round-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

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 the size up to the next multiple of "N" bytes. If the size of the underlying plugin is already a multiple of "N" 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 the size down to a multiple of "N" bytes. If the size of the underlying plugin is already a multiple of "N" 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 (C) 2018 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.

2022-03-26 nbdkit-1.30.2