I’m writing a new nbdkit plugin called linuxdisk. nbdkit is our flexible, plugin-based NBD server, and this new plugin lets you create a complete Linux-compatible virtual disk from a host directory on the fly.
One of the many uses for this is booting minimal VMs very quickly. Here’s an example you can set up in a few seconds. It boots to an interactive busybox shell:
$ mkdir /tmp/root /tmp/root/sbin /tmp/root/bin /tmp/root/dev $ sudo mknod /tmp/root/dev/console c 5 1 $ cp /sbin/busybox /tmp/root/sbin/ $ ln /tmp/root/sbin/busybox /tmp/root/bin/sh $ ln /tmp/root/sbin/busybox /tmp/root/bin/ls $ ln /tmp/root/sbin/busybox /tmp/root/sbin/init $ nbdkit -U - linuxdisk /tmp/root \ --run 'qemu-kvm -display none -kernel /boot/vmlinuz-4.20.8-200.fc29.x86_64 -drive file=nbd:unix:$unixsocket,snapshot=on -append "console=ttyS0 root=/dev/sda1 rw" -serial stdio'
If you need any extra files in the VM just drop them straight into /tmp/root
before booting it.
Edit: How the heck does /dev
get populated in this VM?