nbdkit-tmpdisk-plugin(1)

πŸ’– nbdkit-tmpdisk-plugin(1) πŸ’–

okay bestie so this is a page from the NBDKIT manual and it's literally all about nbdkit-tmpdisk-plugin β€” the girlies who hand out a fresh temporary filesystem to every single client like it's nothing. πŸŽ€


✨ NAME ✨

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


🌸 SYNOPSIS 🌸

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

nbdkit tmpdisk [size=]SIZE command=COMMAND [VAR=VALUE ...]

πŸ¦‹ DESCRIPTION πŸ¦‹

so this nbdkit(1) plugin is the one you call when you're setting up temp filesystems for thin clients. every time a client connects, it gets a fresh, empty filesystem all for itself, no sharing, no crumbs. πŸ‘‘ and when the client disconnects? the filesystem is deleted. gone. poof. πŸ’€

if you actually want a filesystem that sticks around, that's not this girl β€” go use nbdkit-ondemand-plugin(1) instead.

here's the tea β˜•: when a new client connects, a blank, sparse file of the required size gets created in $TMPDIR (or /var/tmp). then mkfs(8) runs on that file to build the empty filesystem, and that filesystem gets served to the client. and unlike nbdkit-linuxdisk-plugin(1), every single client of this plugin sees a different disk. main character energy for real.

the size of the disk comes from the size parameter. the filesystem type is ext4 by default but you can switch it up with the type parameter (which controls the -t option of mkfs). and the filesystem label? set it with label. πŸ’…

🧚 The command parameter 🧚

instead of running mkfs, you can run literally any command or shell script you want to create the disk. go off.

all the other parameters you pass to the plugin get turned into shell variables handed to the command. like, type becomes the shell variable $type, etc. and no cap, any parameter you want can be passed to the plugin and it'll become a shell variable (not just type and label) β€” which makes this a super flexible way to create temporary disks of all kinds. obsessed. πŸ”₯

two special variables also get passed to the shell script fragment:

  • $disk β€” the absolute path of the disk file. ⚠️ note that this is not pre-created, you have to create it yourself, for example using:
truncate -s $size "$disk"

and $disk gets deleted automatically when the client disconnects.

  • $size β€” the virtual size in bytes. this is the size parameter, converted to bytes. heads up tho: the final size served to the client is whatever disk size command creates.

πŸ”’ Security considerations πŸ”’

because every client gets a new disk, the amount of disk space needed on the server can be as much as number of clients Γ— size. 😭 so pls, it's 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. protect your girl.


🌈 EXAMPLES 🌈

πŸ“ Remote tmpfs πŸ“

one use for this is creating a kind of "remote tmpfs(5)" for thin clients. on the server you'd run (see nbdkit-service(1)):

nbdkit tmpdisk 16G

to set up each thin client, follow the instructions in nbdkit-client(1). clients will see a fresh, empty, mounted directory after boot. slay. ✨

πŸŽ€ Overriding mkfs options πŸŽ€

using command lets you easily override any mkfs option, for example:

nbdkit tmpdisk 16G command='
    truncate -s $size "$disk"
    mke2fs -F -N 10000 -t ext4 "$disk"
'

πŸ’œ Serve a fresh blank disk to each client πŸ’œ

again using command, this demonstrates serving any file that you can create locally to the client. this is different from nbdkit-memory-plugin(1) because the clients all see their own private disk (instead of all seeing the same shared disk):

nbdkit tmpdisk 16G command=' truncate -s $size "$disk" '

πŸ‘‘ Serve a fresh operating system to each client πŸ‘‘

nbdkit tmpdisk 16G os=fedora-31 \
    command=' virt-builder -o "$disk" --size ${size}b "$os" '

🌸 Serve a throwaway snapshot of a base image to each client 🌸

you could create a base image using mke2fs(8) -d option, virt-builder(1), or similar tools. then in the command you could copy and serve different throwaway snapshots to each client:

truncate -s 1G base.img
mke2fs -d initial-content/ -F -t ext4 base.img
nbdkit tmpdisk size=0 base=$PWD/base.img \
    command=' cp --sparse=always "$base" "$disk" '

the unusual size=0 parameter is because when using command, size is only a request (but the parameter is still required, bestie, no skipping). in this case the command ignores the requested size. the final size is the size of $disk created by the cp(1) command.


πŸ’… PARAMETERS πŸ’…

  • command='COMMAND' β€” instead of running mkfs(8) to create the initial filesystem, run COMMAND (a shell script fragment which usually must be quoted to protect it from the shell). see the "The command parameter" and "EXAMPLES" sections up above. 🫢
  • label=LABEL β€” select the filesystem label. the default is not set.
  • [size=]SIZE β€” specify the virtual size of the disk image.

if you're using command, this is only a suggested size. the actual size of the resulting disk will be the size of the disk created by command.

this parameter is required. fr fr.

the size= prefix 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 it's 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. baby's been around a minute. πŸ’–


πŸ‘€ SEE ALSO πŸ‘€

nbdkit(1), nbdkit-plugin(3), nbdkit-data-plugin(1), nbdkit-eval-plugin(1), nbdkit-file-plugin(1), nbdkit-ip-filter(1), nbdkit-limit-filter(1), nbdkit-linuxdisk-plugin(1), nbdkit-memory-plugin(1), nbdkit-ondemand-plugin(1), nbdkit-sh-plugin(3), nbdkit-loop(1), nbdkit-service(1), nbdkit-tls(1), mkfs(8), mke2fs(8), virt-builder(1).


🫢 AUTHORS 🫢

Richard W.M. Jones


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:

  1. redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. 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.
  3. 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, mwah πŸ’‹ this was nbdkit-1.48.1, dated 2026-08-29, from the nbdkit-tmpdisk-plugin(1) manual β€” go make some temporary filesystems, you absolute icon ✨

πŸ“¦ where this page comes from