nbdkit-linuxdisk-plugin(1) | NBDKIT | nbdkit-linuxdisk-plugin(1) |
nbdkit-linuxdisk-plugin - create virtual Linux disk from directory
nbdkit linuxdisk [dir=]DIRECTORY [label=LABEL] [type=ext2|ext3|ext4] [size=[+]SIZE]
"nbdkit-linuxdisk-plugin" is a plugin for nbdkit(1) which creates an ext2-, ext3- or ext4-formatted disk image from a directory on the fly. The files in the specified directory (and subdirectories) appear in the virtual disk, which is served read-only over the NBD protocol.
The virtual disk is partitioned with a single GPT partition containing the filesystem.
The virtual disk can be used as a Linux root (or other) filesystem. Most features of Linux filesystems are supported, such as hard links, symbolic links, block special devices etc.
To create a FAT-formatted virtual floppy disk, see nbdkit-floppy-plugin(1). To create a CD/ISO, see nbdkit-iso-plugin(1). To create an empty filesystem for each client that connects (like a "remote tmpfs") use nbdkit-tmpdisk-plugin(1).
mkdir -p root/{bin,dev,proc,sbin,sys,usr/bin,usr/sbin} sudo mknod root/dev/console c 5 1 cp /sbin/busybox root/sbin/ ln root/sbin/busybox root/sbin/init ln root/sbin/busybox root/bin/ls ln root/sbin/busybox root/bin/sh nbdkit -U - linuxdisk root --run ' qemu-kvm -display none -kernel /boot/vmlinuz -drive file=nbd:unix:$unixsocket,snapshot=on -append "console=ttyS0 root=/dev/sda1 rw" -serial stdio '
You can drop any extra files you need into the root/ directory and they will be copied into the appliance before boot. After booting type these commands to complete the environmental setup:
/sbin/busybox --install mount -t proc proc /proc mount -t sysfs sys /sys
This parameter is required.
"dir=" is a magic config key and may be omitted in most cases. See "Magic parameters" in nbdkit(1).
If the "size" parameter is omitted the plugin will try to size the filesystem with just enough space to contain the files and directories that are initially loaded, and there will not be much extra space.
Using "size=SIZE" specifies the required virtual size of the whole filesystem (including initial files and extra space). If this is set too small for the initial filesystem then the plugin will fail to start.
Using "size=+SIZE" specifies the minimum free space required after the initial filesystem has been loaded. (The actual free space might be slightly larger).
The original file UIDs and GIDs are recreated as far as possible. Note that UIDs/GIDs will likely map to different users and groups when read by a virtual machine or other NBD client machine.
Use "nbdkit --dump-config" to find the location of $plugindir.
"nbdkit-linuxdisk-plugin" first appeared in nbdkit 1.12.
mke2fs(8), nbdkit(1), nbdkit-plugin(3), nbdkit-captive(1), nbdkit-cow-filter(1), nbdkit-file-plugin(1), nbdkit-floppy-plugin(1), nbdkit-iso-plugin(1), nbdkit-partition-filter(1), nbdkit-partitioning-plugin(1), nbdkit-tmpdisk-plugin(1),
Richard W.M. Jones
Copyright (C) 2019 Red Hat Inc.
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.
2021-01-20 | nbdkit-1.24.1 |