mount virtio-9p folder to qemu
- User
mount virtio-9p folder to qemu
- Assistant
mount virtio-9p folder to qemu
To mount a virtio-9p folder in QEMU, you need to perform a few steps to set up the shared folder between the host and the virtual machine (VM). Below are the steps to do that:
Create a Shared Directory: On your host machine, create the directory that you want to share with the guest.
mkdir /path/to/shared-folder
Start QEMU with virtio-9p Configuration: When launching QEMU, you'll need to use the -virtfs option to configure the 9p virtio filesystem. Here’s an example command to start QEMU with a shared directory:
qemu-system-x86_64 \
-hda /path/to/your/disk/image.qcow2 \ # Path to your disk image
-virtfs local,security_model=none,mount_tag=hostshare,path=/path/to/shared-folder \
-nographic \ # Optional, remove this if you want a graphical interface
-m 2048 \ # Allocate 2GB of memory to the VM
-enable-kvm # Enable KVM for better performance (if supported)
Here, mount_tag=hostshare is an arbitrary name you'll use in your guest OS to reference the shared folder.
Mount the Directory in the Guest OS: Once the guest OS is booted, you can mount the shared folder using the mount command. In your guest system's terminal, run:
mkdir /mnt/hostshare # Create a directory for mounting
mount -t 9p -o trans=virtio hostshare /mnt/hostshare
This command mounts the shared folder to /mnt/hostshare in the guest OS.
You can verify that the shared folder is mounted correctly by listing the contents of the mount point:
ls /mnt/hostshare
You should see the contents of the shared folder from your host system.
-nographic option is optional, and you can launch QEMU with a graphical interface by removing that option.This setup should allow you to easily share files between your host and guest operating system using virtio-9p in QEMU.
Not yet included in a published release.