nbdkit-tmpdisk-plugin - create a fresh temporary filesystem for each client
nbdkit tmpdisk [size=]SIZE [type=ext4|xfs|vfat|...] [label=LABEL] [command=COMMAND]
This nbdkit(1) plugin is used for creating temporary filesystems for thin clients. Each time a client connects it will see a fresh, empty filesystem for its exclusive use. The filesystem is deleted when the client disconnects.
When a new client connects, a blank, sparse file of the required size is created in
$TMPDIR (or /var/tmp). mkfs(8) is then run on the file to create the empty filesystem, and this filesystem is served to the client. Unlike nbdkit-linuxdisk-plugin(1) each client of this plugin sees a different disk.
The size of the disk is chosen using the
size parameter. The filesystem type is
ext4 but this can be changed using the
type parameter (controlling the -t option of mkfs).
Instead of running mkfs you can run an arbitrary
command to create the disk.
One use for this is to create a kind of "remote tmpfs(5)" for thin clients. On the server you would run (see nbdkit-service(1)):
nbdkit tmpdisk 16G
and each thin client would have a file /etc/rc.d/rc.local containing:
nm-online modprobe nbd nbd-client server /dev/nbd0 mount /dev/nbd0 /var/scratch
Clients would see a fresh, empty
/var/scratch directory after boot.
Because each client gets a new disk, the amount of disk space required on the server can be as much as number of clients × size parameter. It is therefore best to limit the number of clients using nbdkit-limit-filter(1) or take steps to limit where clients can connect from using nbdkit-ip-filter(1), firewalls, or TLS client certificates.
Instead of running mkfs(8) to create the initial filesystem, run
COMMAND (which usually must be quoted to protect it from the shell). The following shell variables may be used in
The absolute path of the file that the command must initialize. This file is created by nbdkit before the command runs.
The filesystem label (from the
The virtual size in bytes, which is the same as the file size.
The filesystem type (from the
type parameter), defaulting to
ext4. (Commands can ignore this if it is not relevant).
Select the filesystem label. The default is not set.
Specify the virtual size of the disk image.
This parameter is required.
size= is a magic config key and may be omitted in most cases. See "Magic parameters" in nbdkit(1).
Select the filesystem type. The default is
ext4. Most non-networked, non-cluster filesystem types supported by the mkfs(8) command can be used here.
The temporary disks for this plugin are created in this directory, one per connected client. If not set this defaults to /var/tmp.
nbdkit --dump-config to find the location of
nbdkit-tmpdisk-plugin first appeared in nbdkit 1.20.
nbdkit(1), nbdkit-plugin(3), nbdkit-data-plugin(1), nbdkit-file-plugin(1), nbdkit-ip-filter(1), nbdkit-limit-filter(1), nbdkit-linuxdisk-plugin(1), nbdkit-memory-plugin(1), nbdkit-loop(1), nbdkit-tls(1), mkfs(8).
Richard W.M. Jones
Copyright (C) 2018-2020 Red Hat Inc.
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.