.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Podwrapper::Man 1.38.1 (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-file-plugin 1" .TH nbdkit-file-plugin 1 2024-04-21 nbdkit-1.38.1 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\-file\-plugin \- nbdkit file plugin .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 2 \& nbdkit file [file=]FILENAME \& [cache=default|none] [fadvise=normal|random|sequential] .Ve .PP .Vb 1 \& nbdkit file dir=DIRECTORY .Ve .PP .Vb 1 \& nbdkit file fd=FILE_DESCRIPTOR .Ve .PP .Vb 1 \& nbdkit file dirfd=FILE_DESCRIPTOR .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" \&\f(CW\*(C`nbdkit\-file\-plugin\*(C'\fR is a file serving plugin for \fBnbdkit\fR\|(1). .PP It serves the named \f(CW\*(C`FILENAME\*(C'\fR over NBD. Local block devices (eg. \fI/dev/sda\fR) may also be served. .PP If you use the \f(CW\*(C`dir\*(C'\fR parameter the plugin works in a different mode where it serves files from the given \f(CW\*(C`DIRECTORY\*(C'\fR, chosen by the client using the NBD export name. .PP If you use the \f(CW\*(C`fd\*(C'\fR or \f(CW\*(C`dirfd\*(C'\fR parameter then you can pass the file descriptor of a single disk or a directory to the plugin, inherited from the parent process. This can be useful where special permissions or capabilities are needed to open the file descriptor, or you want to run nbdkit in a sandboxed environment. .PP The file is writable unless either the \fI\-r\fR command line option, or \&\fBnbdkit\-readonly\-filter\fR\|(1) is used. .SH PARAMETERS .IX Header "PARAMETERS" Exactly one of \fBfile\fR, \fBdir\fR, \fBfd\fR or \fBdirfd\fR must be given. This controls the mode of the plugin, either serving a single file, the files in a directory, a single file descriptor, or the files in the directory of the file descriptor. .IP \fBcache=default\fR 4 .IX Item "cache=default" .PD 0 .IP \fBcache=none\fR 4 .IX Item "cache=none" .PD (nbdkit ≥ 1.22, not Windows) .Sp Using \f(CW\*(C`cache=none\*(C'\fR tries to prevent the kernel from keeping parts of the file that have already been read or written in the page cache. .IP \fBdir=\fRDIRECTORY 4 .IX Item "dir=DIRECTORY" (nbdkit ≥ 1.22, not Windows) .Sp Serve all regular files and block devices located directly inside the directory named \f(CW\*(C`DIRECTORY\*(C'\fR, including those found by following symbolic links. Other special files in the directory (such as subdirectories, pipes, or Unix sockets) are ignored. .Sp See "Serving multiple files and block devices" below. .IP \fBdirfd=\fRFILE_DESCRIPTOR 4 .IX Item "dirfd=FILE_DESCRIPTOR" (nbdkit ≥ 1.34, not Windows) .Sp This is like the \f(CW\*(C`dir=\*(C'\fR option, but instead of specifying the directory by name, the parent process should open the directory and pass this file descriptor by inheritance to nbdkit. .Sp See "Serving multiple files and block devices" below. .IP \fBfadvise=normal\fR 4 .IX Item "fadvise=normal" .PD 0 .IP \fBfadvise=random\fR 4 .IX Item "fadvise=random" .IP \fBfadvise=sequential\fR 4 .IX Item "fadvise=sequential" .PD (nbdkit ≥ 1.22, not Windows) .Sp This optional flag hints to the kernel that you will access the file normally, or in a random order, or sequentially. The exact behaviour depends on your operating system, but for Linux using \f(CW\*(C`normal\*(C'\fR causes the kernel to read-ahead, \f(CW\*(C`sequential\*(C'\fR causes the kernel to read-ahead twice as much as \f(CW\*(C`normal\*(C'\fR, and \f(CW\*(C`random\*(C'\fR turns off read-ahead. See also \fBposix_fadvise\fR\|(2). .Sp The default is \f(CW\*(C`normal\*(C'\fR. .IP \fBfd=\fRFILE_DESCRIPTOR 4 .IX Item "fd=FILE_DESCRIPTOR" (nbdkit ≥ 1.34, not Windows) .Sp The parameter is the number of a file descriptor. Serve the file or device already open on this file descriptor. The file descriptor is usually inherited from the parent process. .IP [\fBfile=\fR]FILENAME 4 .IX Item "[file=]FILENAME" Serve the file named \f(CW\*(C`FILENAME\*(C'\fR. A local block device name can also be used here. When this mode is used, the export name requested by the client is ignored. .Sp \&\f(CW\*(C`file=\*(C'\fR is a magic config key and may be omitted in most cases. See "Magic parameters" in \fBnbdkit\fR\|(1). .IP [\fBfile=\fR]\fB\e\e.\e\fRC\fB:\fR 4 .IX Item "[file=].C:" .PD 0 .IP [\fBfile=\fR]\fB\e\e.\e\fRVolume 4 .IX Item "[file=].Volume" .IP [\fBfile=\fR]\fB\e\e.\ePhysicalDisk\fR\fIN\fR 4 .IX Item "[file=].PhysicalDiskN" .IP [\fBfile=\fR]\fB\e\e.\eCdRom\fR\fIN\fR 4 .IX Item "[file=].CdRomN" .PD (Windows only) .Sp Serve the Windows volume specified by the device name. See: https://docs.microsoft.com/en\-us/windows/win32/fileio/naming\-a\-file#win32\-device\-namespaces. .SH NOTES .IX Header "NOTES" .SS "Serving multiple files and block devices" .IX Subsection "Serving multiple files and block devices" Using \f(CW\*(C`dir=DIRECTORY\*(C'\fR (or \f(CW\*(C`dirfd=DIRFD\*(C'\fR) you can serve all regular files and block devices located directly inside the directory named \&\f(CW\*(C`DIRECTORY\*(C'\fR, including those found by following symbolic links. Other special files in the directory (such as subdirectories, pipes, or Unix sockets) are ignored. .PP When this mode is used, the file to be served is chosen by the export name passed by the client. For security, when using directory mode, this plugin will not accept export names containing slash (\f(CW\*(C`/\*(C'\fR). .PP For example: .PP .Vb 6 \& $ ls \-l /var/tmp/exports \& total 0 \& \-rw\-r\-\-r\-\-. 1 rjones rjones 1048576 Dec 14 15:34 disk1 \& \-rw\-r\-\-r\-\-. 1 rjones rjones 2097152 Dec 14 15:34 disk2 \& lrwxrwxrwx. 1 rjones rjones 9 Dec 14 15:35 sda1 \-> /dev/sda1 \& $ nbdkit file dir=/var/tmp/exports .Ve .PP will serve three exports called \f(CW"disk1"\fR, \f(CW"disk2"\fR and \f(CW"sda1"\fR. The first two are regular files and the last is a block device. You can add or remove files or symbolic links from the directory while nbdkit is running. .PP To list exports, use \fBnbdinfo\fR\|(1) \fI\-\-list\fR option, for example: .PP .Vb 6 \& $ nbdinfo \-\-list nbd://localhost \& protocol: newstyle\-fixed without TLS, using structured packets \& export="disk1": \& export\-size: 1048576 (1M) \& uri: nbd://localhost:10809/disk1 \& [etc] .Ve .PP An NBD client can request a list of available exports using \&\f(CW\*(C`NBD_OPT_LIST\*(C'\fR. For libnbd clients see \fBnbd_opt_list\fR\|(3). .PP A client that requests the default export (\f(CW""\fR) will be rejected. However, you can use \fBnbdkit\-exportname\-filter\fR\|(1) to adjust the default export as well as other transformations of export names. For example to make \fI/var/tmp/exports/disk1\fR be the default export: .PP .Vb 2 \& nbdkit file dir=/var/tmp/exports \e \& \-\-filter=exportname default\-export=disk1 .Ve .SS "Optimizing for random or sequential access" .IX Subsection "Optimizing for random or sequential access" If you know in advance that the NBD client will access the file randomly or only sequentially then you can hint that to the kernel using: .PP .Vb 2 \& nbdkit file disk.img fadvise=random \& nbdkit file disk.img fadvise=sequential .Ve .PP As described in the "PARAMETERS" section above, on Linux this disables or increases the amount of read-ahead that the kernel does. .SS "Reducing evictions from the page cache" .IX Subsection "Reducing evictions from the page cache" If the file is very large and you know the client will only read/write the file sequentially one time (eg for making a single copy or backup) then this will stop other processes from being evicted from the page cache: .PP .Vb 1 \& nbdkit file disk.img fadvise=sequential cache=none .Ve .PP Only use fadvise=sequential if reading, and the reads are mainly sequential. .SS "Files on tmpfs" .IX Subsection "Files on tmpfs" If you want to expose a file that resides on a file system known to have poor \f(CWlseek(2)\fR performance when searching for holes (\f(CW\*(C`tmpfs\*(C'\fR is known to be one such file system), you can use \&\fBnbdkit\-noextents\-filter\fR\|(1) to avoid the penalty of probing for holes. .SS "Plugin \fI\-\-dump\-plugin\fP output" .IX Subsection "Plugin --dump-plugin output" You can obtain extra information about how the file plugin was compiled by doing: .PP .Vb 1 \& nbdkit file \-\-dump\-plugin .Ve .PP Some of the fields which may appear are listed below. Note these are for information only and may be changed or removed at any time in the future. .ie n .IP """file_blksszget=yes""" 4 .el .IP \f(CWfile_blksszget=yes\fR 4 .IX Item "file_blksszget=yes" .PD 0 .ie n .IP """file_blkzeroout=yes""" 4 .el .IP \f(CWfile_blkzeroout=yes\fR 4 .IX Item "file_blkzeroout=yes" .PD If both set, the plugin may be able to efficiently zero ranges of block devices, where the driver and block device itself supports this. .ie n .IP """file_extents=yes""" 4 .el .IP \f(CWfile_extents=yes\fR 4 .IX Item "file_extents=yes" If set, the plugin can read file extents. .ie n .IP """file_falloc_fl_punch_hole=yes""" 4 .el .IP \f(CWfile_falloc_fl_punch_hole=yes\fR 4 .IX Item "file_falloc_fl_punch_hole=yes" If set, the plugin may be able to punch holes (make sparse) files and block devices. .ie n .IP """file_falloc_fl_zero_range=yes""" 4 .el .IP \f(CWfile_falloc_fl_zero_range=yes\fR 4 .IX Item "file_falloc_fl_zero_range=yes" If set, the plugin may be able to efficiently zero ranges of files and block devices. .ie n .IP """winfile=yes""" 4 .el .IP \f(CWwinfile=yes\fR 4 .IX Item "winfile=yes" If present, this is the Windows version of the file plugin with reduced functionality and some special Windows-only features, as noted in this manual. .SS "Windows sparse files" .IX Subsection "Windows sparse files" This plugin supports sparse files on Windows (with hole punching). However for this to work the files must already have the sparse property, the plugin will not make existing files sparse. Use the \&\f(CW\*(C`fsutil\ sparse\*(C'\fR command to control the sparseness property of files. .ie n .SS "Old ""rdelay"" and ""wdelay"" parameters." .el .SS "Old \f(CWrdelay\fP and \f(CWwdelay\fP parameters." .IX Subsection "Old rdelay and wdelay parameters." Before nbdkit supported filters (< 1.2) this plugin had extra parameters \f(CW\*(C`rdelay\*(C'\fR and \f(CW\*(C`wdelay\*(C'\fR to insert delays. These parameters have been moved to \fBnbdkit\-delay\-filter\fR\|(1). Modify the command line to add \fI\-\-filter=delay\fR in order to use these parameters. .SS "Concatenating files" .IX Subsection "Concatenating files" To concatenate and export multiple files, use \&\fBnbdkit\-split\-plugin\fR\|(1). .SH "DEBUG FLAG" .IX Header "DEBUG FLAG" .IP "\fB\-D file.zero=1\fR" 4 .IX Item "-D file.zero=1" This enables very verbose debugging of the NBD zero request. This can be used to tell if the file plugin is able to zero ranges in the file or block device efficiently or not. .SH FILES .IX Header "FILES" .ie n .IP \fR\fI$plugindir\fR\fI/nbdkit\-file\-plugin.so\fR 4 .el .IP \fR\f(CI$plugindir\fR\fI/nbdkit\-file\-plugin.so\fR 4 .IX Item "$plugindir/nbdkit-file-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\-file\-plugin\*(C'\fR first appeared in nbdkit 1.0. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBnbdkit\fR\|(1), \&\fBnbdkit\-plugin\fR\|(3), \&\fBnbdkit\-split\-plugin\fR\|(1), \&\fBnbdkit\-partitioning\-plugin\fR\|(1), \&\fBnbdkit\-tmpdisk\-plugin\fR\|(1), \&\fBnbdkit\-exportname\-filter\fR\|(1), \&\fBnbdkit\-fua\-filter\fR\|(1), \&\fBnbdkit\-luks\-filter\fR\|(1), \&\fBnbdkit\-noextents\-filter\fR\|(1), \&\fBnbdkit\-readonly\-filter\fR\|(1), \&\fBnbdinfo\fR\|(1). .SH AUTHORS .IX Header "AUTHORS" Eric Blake .PP Nir Soffer .PP 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.