.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Podwrapper::Man 1.36.3 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "nbdkit-data-plugin 1" .TH nbdkit-data-plugin 1 2024-01-17 nbdkit-1.36.3 NBDKIT .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME nbdkit\-data\-plugin \- nbdkit plugin for serving data from the command line .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 2 \& nbdkit data [data=]\*(Aq0 1 2 3 @0x1fe 0x55 0xaa\*(Aq \& [size=SIZE] [allocator=sparse|malloc|zstd] .Ve .PP .Vb 2 \& nbdkit data base64=\*(AqaGVsbG8gbmJka2l0IHVzZXI=\*(Aq \& [size=SIZE] [allocator=sparse|malloc|zstd] .Ve .PP .Vb 2 \& nbdkit data raw=\*(Aqbinary_data\*(Aq \& [size=SIZE] [allocator=sparse|malloc|zstd] .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" \&\f(CW\*(C`nbdkit\-data\-plugin\*(C'\fR is a plugin for \fBnbdkit\fR\|(1) which serves a small amount of data specified directly on the command line. The plugin gets its name from the \f(CW\*(C`data:\*(C'\fR URI scheme used by web browsers. This is mainly useful for testing NBD clients. .PP You can serve data read-only using the \fI\-r\fR flag, or read-write. Any writes are thrown away when nbdkit exits. .PP Most operating systems have command line size limits which are quite a lot smaller than any desirable disk image, so specifying a large, fully populated disk image on the command line would not be possible. However you can specify a small amount of data at the beginning of the image, possibly followed by zeroes (using the \f(CW\*(C`size\*(C'\fR parameter to pad the image to the full size), or use the \f(CW\*(C`data\*(C'\fR parameter creatively to make mostly sparse disk images. .PP The \f(CW\*(C`size\*(C'\fR parameter can specify any virtual size up to the maximum supported by nbdkit (2⁶³\-1\ bytes). .SH EXAMPLES .IX Header "EXAMPLES" .SS "Create small disks filled with test patterns" .IX Subsection "Create small disks filled with test patterns" .Vb 2 \& nbdkit data \*(Aq ( 0x55 0xAA )*2048 \*(Aq \& nbdkit data \*(Aq ( "Hello" )*2000 \*(Aq size=8192 .Ve .PP The first command creates a disk containing 4096 bytes filled with the repeating bytes 0x55 0xAA. The second command repeats \&\f(CW\*(C`HelloHelloHello...\*(C'\fR, truncating the disk to exactly 8192 bytes. .PP See also \fBnbdkit\-pattern\-plugin\fR\|(3). .SS "Create a 1 MB disk with MBR-format partition table" .IX Subsection "Create a 1 MB disk with MBR-format partition table" .Vb 11 \& nbdkit data \*(Aq \& @0x1be # MBR first partition entry \& 0 # Partition status \& 0 2 0 # CHS start \& 0x83 # Partition type (Linux) \& 0x20 0x20 0 # CHS last sector \& le32:1 # LBA first sector \& le32:0x7ff # LBA number of sectors \& @0x1fe # Boot signature \& 0x55 0xaa \& \*(Aq size=1M .Ve .PP A more flexible way to create partitions is to use \&\fBnbdkit\-partitioning\-plugin\fR\|(1). To create a data string from an existing disk use the \f(CW\*(C`disk2data.pl\*(C'\fR script provided in the nbdkit sources (https://gitlab.com/nbdkit/nbdkit/blob/master/plugins/data/disk2data.pl). .SS "Create a disk image with sector-aligned data" .IX Subsection "Create a disk image with sector-aligned data" .Vb 1 \& nbdkit data \*(Aq \e\fRNAME" 4 .IX Item "expression -> NAME" .PD 0 .IP \fB\e\fRNAME 4 .IX Item "NAME" .PD (nbdkit ≥ 1.24) .Sp Assign an expression to a name which can be used later. Names can be used in the current scope (or any scopes nested within the current scope), but disappear at the end of the current scope. Names start with a backslash character followed by one or more alphanumeric, dash and underscore. For example this makes two identical sectors both containing a boot signature at the end: .Sp .Vb 3 \& nbdkit data \*(Aq ( 0x55 0xAA ) \-> \eboot\-signature \& ( @0x1fe \eboot\-signature ) \-> \esector \& \esector \esector \*(Aq .Ve .IP \fB$\fRVAR 4 .IX Item "$VAR" (nbdkit ≥ 1.24) .Sp Substitute command line parameters or environment variables. The variable is written in the same language as the \f(CW\*(C`data\*(C'\fR parameter, and when substituted it creates a nested scope like \f(CW\*(C`(\ ...\ )\*(C'\fR expressions. These are all equivalent: .Sp .Vb 1 \& nbdkit data \*(Aq$pattern*16\*(Aq pattern=\*(Aq0x55 0xAA\*(Aq .Ve .Sp .Vb 2 \& export pattern=\*(Aq0x55 0xAA\*(Aq \& nbdkit data \*(Aq$pattern*16\*(Aq .Ve .Sp .Vb 1 \& nbdkit data \*(Aq( 0x55 0xAA )*16\*(Aq .Ve .IP "\fB#\fR COMMENT" 4 .IX Item "# COMMENT" (nbdkit ≥ 1.24) .Sp \&\f(CW\*(C`#\*(C'\fR begins a comment stretching to the end of the current line. .SS "disk2data.pl script" .IX Subsection "disk2data.pl script" This script can convert from small disk images into the data format described above. .PP It is provided in the nbdkit sources. See https://gitlab.com/nbdkit/nbdkit/blob/master/plugins/data/disk2data.pl .SH FILES .IX Header "FILES" .ie n .IP \fR\fI$plugindir\fR\fI/nbdkit\-data\-plugin.so\fR 4 .el .IP \fR\f(CI$plugindir\fR\fI/nbdkit\-data\-plugin.so\fR 4 .IX Item "$plugindir/nbdkit-data-plugin.so" The plugin. .Sp Use \f(CW\*(C`nbdkit \-\-dump\-config\*(C'\fR to find the location of \f(CW$plugindir\fR. .SH VERSION .IX Header "VERSION" \&\f(CW\*(C`nbdkit\-data\-plugin\*(C'\fR first appeared in nbdkit 1.6. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBnbdkit\fR\|(1), \&\fBnbdkit\-captive\fR\|(1), \&\fBnbdkit\-plugin\fR\|(3), \&\fBnbdkit\-info\-plugin\fR\|(1), \&\fBnbdkit\-memory\-plugin\fR\|(1), \&\fBnbdkit\-null\-plugin\fR\|(1), \&\fBnbdkit\-ones\-plugin\fR\|(1), \&\fBnbdkit\-partitioning\-plugin\fR\|(1), \&\fBnbdkit\-pattern\-plugin\fR\|(1), \&\fBnbdkit\-random\-plugin\fR\|(1), \&\fBnbdkit\-sparse\-random\-plugin\fR\|(1), \&\fBnbdkit\-tmpdisk\-plugin\fR\|(1), \&\fBnbdkit\-zero\-plugin\fR\|(1), https://gitlab.com/nbdkit/nbdkit/blob/master/plugins/data/disk2data.pl, https://en.wikipedia.org/wiki/Base64. .SH AUTHORS .IX Header "AUTHORS" Richard W.M. Jones .SH COPYRIGHT .IX Header "COPYRIGHT" Copyright Red Hat .SH LICENSE .IX Header "LICENSE" Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: .IP \(bu 4 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. .IP \(bu 4 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. .IP \(bu 4 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. .PP 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.