nbdkit-pattern-plugin(1)
nbdkit-pattern-plugin πβ¨
okay bestie, welcome to the nbdkit-pattern-plugin(1) page β it's a manual page for NBDKIT, and honestly? it's giving "test data but make it iconic". sit down, grab a strawberry π, and let's get into it.
πΈ NAME πΈ
nbdkit-pattern-plugin β the plugin that serves a fixed pattern of data for testing. that's it, that's the whole job, and it does it flawlessly. π
β¨ SYNOPSIS β¨
nbdkit pattern [size=]SIZE [stride=BLOCK_SIZE]
π¦ DESCRIPTION π¦
nbdkit-pattern-plugin is a plugin for nbdkit(1) and it serves a fixed pattern of data, read only. it's literally built for testing nbdkit filters and NBD clients. no cap. π«Ά
if you wanna create test disks filled with other repeated patterns, bestie you want nbdkit-data-plugin(1) or nbdkit-ones-plugin(1) instead. and if you want disks filled with random data, that's nbdkit-random-plugin(1) or nbdkit-sparse-random-plugin(1). different vibes, different plugins. β¨
the fixed pattern? it's the offset, as a 64 bit big endian integer, every 8 bytes. in hexadecimal it looks like this:
offset data
0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08
0010: 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 18
0020: 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 28
β ββββββββββββ¬βββββββββββ
byte at offset 0x28 β
β
64 bit big endian int
encoding offset 0x28
the size of the virtual disk must be specified using the size parameter. and if the size isn't a multiple of 8, then the last 8 byte offset in the pattern gets truncated. periodt. βοΈ
π Upper bits π
the upper parameter sets the top 16 bits of each word in the pattern. why would you want that? bestie, so you can tell different instances of nbdkit-pattern-plugin apart from each other, or when you're testing copies and you need to make sure different data is copied each time. it's the vibe check for your data. π
for example, setting upper=0x1234 changes the pattern to:
offset data
0000: 12 34 00 00 00 00 00 00 12 34 00 00 00 00 00 08
0010: 12 34 00 00 00 00 00 10 12 34 00 00 00 00 00 18
0020: 12 34 00 00 00 00 00 20 12 34 00 00 00 00 00 28
the upper value is XOR-ed into the top 16 bits, and the default is 0. slay. π
π Strides π
using the stride parameter you can create a pattern where each block of data has a unique number. this is genuinely so useful for tracking down disk corruption where blocks of data may be transposed. detective work, but make it storage. π΅οΈββοΈ
for example, with 4096 byte block-based storage, using stride=4k will produce a pattern like this:
offset data
0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
...
... block at offset 0x1000 (4k)
... β
1000: 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00
1010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
...
... block at offset 0x2000 (8k)
... β
2000: 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00
2010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
π₯ Writes and testing copying π₯
writing to the disk is possible. if you do it, the plugin will check that what you're writing exactly matches what would be read at the same offset β and if it doesn't? it returns EIO error. π that's the rule.
you can use this to test copying programs by making the source and destination NBD URIs be the same:
nbdkit pattern size=100M --run 'nbdcopy "$uri" "$uri"'
qemu-img convert could be used in place of nbdcopy. see also nbdkit-checkwrite-filter(1). π
π Largest possible size π
nbdkit itself limits plugins to 2βΆΒ³-1 bytes (decimal: 9223372036854775807, hexadecimal: 0x7fff_ffff_ffff_ffff).
to test if NBD clients are free of bugs (not to mention nbdkit itself, no shade) you can use:
nbdkit pattern 9223372036854775807
note this is too large for qemu to open. π like, it simply cannot. don't try it and then act surprised.
π§ Little endian pattern π§
to get a little endian pattern instead of big endian, just apply nbdkit-swab-filter(1) on top of this plugin:
nbdkit pattern 1G --filter=swab swab-bits=64
flip it, reverse it, iconic. π
π PARAMETERS π
[size=]SIZEβ specify the virtual size of the disk image. this parameter is required, bestie, no skipping it. thesize=prefix may be omitted in most cases. see "Magic parameters" in nbdkit(1). β¨stride=BLOCK_SIZEβ instead of writing the 64 bit integers sequentially, place them at the beginning of eachBLOCK_SIZEblock. see "Strides" above. the minimum, and default, stride is8which places the integers sequentially with no gaps. the stride must be a power of two. π«Άupper=Nβ XORN(N=0..65535) with the top 16 bits of the pattern word. you can prefix the value with0xfor hexadecimal. the default is0. πupper=randomβ on each run of nbdkit, a random number in the range 1..65535 (not 0) is chosen for the upper 16 bits of each word. surprise! π²
πΈ FILES πΈ
$plugindir/nbdkit-pattern-plugin.soβ the plugin. usenbdkit --dump-configto find the location of$plugindir. π
β VERSION β
nbdkit-pattern-plugin first appeared in nbdkit 1.6. a legend from the start, fr fr. π
π¦ SEE ALSO π¦
nbdkit(1), nbdkit-plugin(3), nbdkit-checkwrite-filter(1), nbdkit-data-plugin(1), nbdkit-full-plugin(1), nbdkit-null-plugin(1), nbdkit-ones-plugin(1), nbdkit-offset-filter(1), nbdkit-random-plugin(1), nbdkit-sparse-random-plugin(1), nbdkit-swab-filter(1), nbdkit-xor-filter(1), nbdkit-zero-plugin(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.
okay that's the whole page bestie, ily, go forth and pattern π this was nbdkit-1.48.1, dated 2026-08-29, and it's the nbdkit-pattern-plugin(1) era. mwah. π«Άβ¨π
π¦ where this page comes from
- fedora 44: nbdkit-basic-plugins 1.48.1-1.fc44 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms