I am trying to use Rocky Linux with QEMU. I use cloud image Rocky-9-GenericCloud.latest.aarch64.qcow2. I can start guest VM, but I can’t share folder with my host machine.
This is the parameter I passed to QEMU.
-virtfs local,path=shared,mount_tag=shared,security_model=mapped-xattr
This is the mount point config. (cloud-init)
["shared", "/mnt/shared", "9p", "trans=virtio,version=9p2000.L", "0", "0"]
But it fails to mount because 9p is unknown file system. I don’t really need 9p if there is alternative. Thanks.
I can see
/usr/src/kernels/5.14.0-427.16.1.el9_4.x86_64/fs/9p
1 Like
Hi , Since you mentioned you don’t necessarily need 9p, you can try an alternative like Virtio-FS, which is often faster and better integrated for sharing directories between the host and guest in modern virtualized environments.
Steps to use Virtio-FS:
- Check host support: Make sure that your host supports Virtio-FS. You should have the
virtiofsd
package installed on your host. On Rocky Linux, you can install it with:
sudo dnf install virtiofsd
- QEMU command: When launching QEMU, use the parameter for Virtio-FS. For example:
-virtfs local,path=/path/to/host/directory,mount_tag=shared,security_model=none,id=fs0
-device vhost-user-fs-pci,chardev=char0,tag=shared
-chardev socket,id=char0,path=/var/run/vhost-user-fs.sock
Be sure to replace /path/to/host/directory
with the actual path on your host.
- Modify cloud-init or fstab on the guest: Update the mount configuration. If you are using
cloud-init
, the new mount point might look like this:
["shared", "/mnt/shared", "virtiofs", "defaults", "0", "0"]
Alternatively, you can manually add the entry in /etc/fstab
on the guest:
shared /mnt/shared virtiofs defaults 0 0
- Start the VM: Start the guest VM with the new configuration and check if you can successfully mount the shared directory using Virtio-FS.
This setup should provide a more stable and higher-performance solution than 9p for sharing directories between host and guest in modern virtual machines.
1 Like
Thanks for the detailed reply. Unfortunately, I am using MacOS. It seems virtiofsd
is not supported by MacOS right now. [1]
1: Add macOS support
I see. Perhaps cloud image doesn’t include that. I need to find out how to get it. Thanks.