How to boot from virtio-fs

This document describes how to boot from a virtio-fs root file system.

A guide for manually running QEMU with virtio-fs is available here. It covers how to compile virtio-fs software components. This document assumes you have compiled virtio-fs.

virtio-fs can be used to share directories between the host and the guest. Frequently these are "data" directories that do not contain the root file system. Sometimes it is useful to boot the root file system itself from virtio-fs.

When a guest boots from virtio-fs it does not require a disk image file. This is convenient when changes are made to the root file system periodically and rebuilding a disk image file each time would be slow.

Prerequisites

The instructions assume that you already have available a Linux host on which you can build and run the components.

Creating a Fedora root file system

Install a basic Fedora root file system as follows:

# mkdir virtio-fs-root
# dnf --installroot=$PWD/virtio-fs-root --releasever=29 install system-release vim-minimal systemd passwd dnf rootfiles
# $EDITOR virtio-fs-root/etc/shadow # set password or allow password-less root login

Booting from virtio-fs

Start the virtio-fs daemon:

# virtiofsd -o vhost_user_socket=/tmp/vhostqemu -o source=virtio-fs-root -o cache=none

The following QEMU options are required:

This assumes you are using a monolithic kernel. Use of an initramfs has not been tested and may require further steps.

For details on launching QEMU, see the QEMU HowTo.