$filterdir/nbdkit-truncate-filter.so
The filter.
Use "nbdkit --dump-config" to find the location of $filterdir.
Change the size of plugins
nbdkit --filter=truncate
plugin
[truncate=SIZE]
[round-up=N]
[round-down=N]
"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.
truncate=SIZESet 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=NRound 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-down=NRound 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.
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
$filterdir/nbdkit-truncate-filter.so
The filter.
Use "nbdkit --dump-config" to find the location of $filterdir.
"nbdkit-truncate-filter" first appeared in nbdkit 1.6.
4 releases since Debian 10 (Buster); the text changed 3 times.