NAME

nbdkit-tmpdisk-plugin - create a fresh temporary filesystem for each client

SYNOPSIS

 nbdkit tmpdisk [size=]SIZE
                [type=ext4|xfs|vfat|...] [label=LABEL]
                [command=COMMAND]

DESCRIPTION

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.

Example

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.

Security considerations

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.

PARAMETERS

command='COMMAND'

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 COMMAND:

$disk

The absolute path of the file that the command must initialize. This file is created by nbdkit before the command runs.

$label

The filesystem label (from the label parameter).

$size

The virtual size in bytes, which is the same as the file size.

$type

The filesystem type (from the type parameter), defaulting to ext4. (Commands can ignore this if it is not relevant).

label=LABEL

Select the filesystem label. The default is not set.

[size=]SIZE

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).

type=FS

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.

ENVIRONMENT VARIABLES

TMPDIR

The temporary disks for this plugin are created in this directory, one per connected client. If not set this defaults to /var/tmp.

FILES

$plugindir/nbdkit-tmpdisk-plugin.so

The plugin.

Use nbdkit --dump-config to find the location of $plugindir.

VERSION

nbdkit-tmpdisk-plugin first appeared in nbdkit 1.20.

SEE ALSO

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).

AUTHORS

Richard W.M. Jones

COPYRIGHT

Copyright (C) 2018-2020 Red Hat Inc.

LICENSE

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

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.