Skip to content

Support rootfstype=virtiofs#298

Open
7Ji wants to merge 1 commit intoanatol:masterfrom
7Ji:virtiofs
Open

Support rootfstype=virtiofs#298
7Ji wants to merge 1 commit intoanatol:masterfrom
7Ji:virtiofs

Conversation

@7Ji
Copy link
Copy Markdown
Contributor

@7Ji 7Ji commented May 23, 2025

This adds support to boot with virtiofs as rootfs, the behaviour stays in-line with mkinitcpio and dracut, in that rootfstype=virtiofs must be specified explicitly to distinguish it from other "virtual" roots (e.g. virtio-9p, nfs, etc), e.g.

rootfstype=virtiofs root=root

(Of course this only adds support of virtiofs)


virtiofs is a nice host-passthrough "fs" with which a virtual machine can use the host fs almost directly, saving the overhead of "guest fs -> guest disk -> host file -> host fs" hassle, a virtiofs root is especially useful when access to files in guest root fs from host directly is needed, e.g. when doing frequent debugging, or vice versa.

E.g. with the following snippet in corresponding libvirt-qemu config:

<filesystem type='mount' accessmode='passthrough'>
    <driver type='virtiofs'/>
    <source dir='/var/lib/libvirt/filesystems/root.arch-x64-testing'/>
    <target dir='root'/>
    <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
</filesystem>

And an Arch system installed in archiso with the following steps:

mount -t virtiofs root /mnt
pacstrap /mnt ......

With optionally the following fstab:

root / virtiofs rw 0 0

The guest os can be booted with the following libvirt-qemu snippet:

<os>
    <type arch='x86_64' machine='pc-q35-10.0'>hvm</type>
    <kernel>/var/lib/libvirt/filesystems/root.arch-x64-testing/boot/vmlinuz-linux</kernel>
    <initrd>/var/lib/libvirt/filesystems/root.arch-x64-testing/boot/booster-linux.img</initrd>
    <cmdline>rootfstype=virtiofs root=root</cmdline>
    <boot dev='hd'/>
    <bootmenu enable='no'/>
</os>

Booting is successful with this patchset:

[root@archout ~]# dmesg | grep virtio | grep root
[    0.000000] Command line: console=ttyS0,115200n8 rootfstype=virtiofs root=root booster.log=console,debug
[    0.120364] Kernel command line: console=ttyS0,115200n8 rootfstype=virtiofs root=root booster.log=console,debug
[    0.667763] virtiofs virtio1: discovered new tag: root
[    1.132546] booster: mounting root->/booster.root, fs=virtiofs, flags=0x0, options=
[root@archout ~]# mount | grep root
root on / type virtiofs (rw,relatime)

@7Ji 7Ji closed this May 23, 2025
@7Ji 7Ji reopened this May 23, 2025
@anatol
Copy link
Copy Markdown
Owner

anatol commented Mar 30, 2026

I, sorry I somehow missed this PR. Could you please rebase/retest it?

The change also needs integration tests.

@7Ji
Copy link
Copy Markdown
Contributor Author

7Ji commented Mar 31, 2026

I've added an integration test, and it passed the test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants