1nbdkit-truncate-filter(1) NBDKIT nbdkit-truncate-filter(1)
2
3
4
6 nbdkit-truncate-filter - change the size of plugins
7
9 nbdkit --filter=truncate plugin [truncate=SIZE]
10 [round-up=N] [round-down=N]
11
13 "nbdkit-truncate-filter" is a filter that changes the size of the
14 underlying plugin. It can:
15
16 · Make the plugin smaller (truncate it). Use the "truncate=SIZE"
17 parameter to set the smaller size.
18
19 · Make the plugin larger (the additional bytes read back as zeroes).
20 Use "truncate=SIZE" to set the larger size.
21
22 · Round the size of the plugin up or down to the next multiple of
23 "N". Use either "round-up=N" or "round-down=N".
24
25 A common use for this filter is to handle NBD clients which have a
26 problem dealing with device sizes which are not a multiple of 512
27 bytes. Use "round-up=512" to round the size up to the next multiple of
28 512 bytes. If the size is already a multiple of 512 bytes then this
29 has no effect.
30
32 truncate=SIZE
33 Set the absolute size in bytes of the apparent device. This may be
34 smaller or larger or the same as the underlying plugin.
35
36 If the size is larger than the underlying plugin, reading the extra
37 space returns zeroes. Writes are also permitted to the extra
38 space, but you must only write zeroes (any attempts to write non-
39 zero bytes will return an error back to the client).
40
41 This parameter is optional.
42
43 round-up=N
44 Round the size up to the next multiple of "N" bytes. If the size
45 of the underlying plugin is already a multiple of "N" bytes, this
46 has no effect.
47
48 This option is useful when combined with other filters (such as
49 nbdkit-blocksize-filter(1), nbdkit-cache-filter(1), or
50 nbdkit-cow-filter(1)) that normally round down due to a larger
51 granularity, in order to access the last few bytes of a file that
52 would otherwise be rendered inaccessible.
53
54 This parameter is optional.
55
56 round-down=N
57 Round the size down to a multiple of "N" bytes. If the size of the
58 underlying plugin is already a multiple of "N" bytes, this has no
59 effect.
60
61 This parameter is optional.
62
64 Serve a file as if it were a block device that insists on 4k alignment,
65 while still allowing access to any unaligned bytes at the end of the
66 file:
67
68 nbdkit --filter=blocksize --filter=truncate file /path/to/file \
69 minblock=4k round-up=4k
70
72 $filterdir/nbdkit-truncate-filter.so
73 The filter.
74
75 Use "nbdkit --dump-config" to find the location of $filterdir.
76
78 "nbdkit-truncate-filter" first appeared in nbdkit 1.6.
79
81 nbdkit(1), nbdkit-file-plugin(1), nbdkit-filter(3),
82 nbdkit-blocksize-filter(1), nbdkit-cache-filter(1),
83 nbdkit-cow-filter(1), nbdkit-offset-filter(1),
84 nbdkit-partition-filter(1).
85
87 Richard W.M. Jones
88
90 Copyright (C) 2018 Red Hat Inc.
91
93 Redistribution and use in source and binary forms, with or without
94 modification, are permitted provided that the following conditions are
95 met:
96
97 · Redistributions of source code must retain the above copyright
98 notice, this list of conditions and the following disclaimer.
99
100 · Redistributions in binary form must reproduce the above copyright
101 notice, this list of conditions and the following disclaimer in the
102 documentation and/or other materials provided with the
103 distribution.
104
105 · Neither the name of Red Hat nor the names of its contributors may
106 be used to endorse or promote products derived from this software
107 without specific prior written permission.
108
109 THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND ANY
110 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
111 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
112 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR CONTRIBUTORS BE
113 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
114 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
115 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
116 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
117 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
118 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
119 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
120
121
122
123nbdkit-1.16.1 2019-12-03 nbdkit-truncate-filter(1)