- Debian - Ubuntu
sudo apt install spice-vdagent
- Fedora
sudo dnf install spice-vdagent
- Arch
sudo pacman -S spice-vdagent
- NixOS
add the below line to configuration.nix
services.spice-vdagentd.enable = true;
- qemu-kvm version 5.0 at least
qemu-kvm -version
-
creat the folder you want to share
-
Open VM settings > Memory and enable
shared memory
or add:
<memoryBacking>
<source type="memfd"/>
<access mode="shared"/>
</memoryBacking>
-
Add Hardware and chose Filesystem:
- Driver
virtiofs
- Source path
/shared/folder/on/host
- Target path
shared-folder-name-on-guest
- Driver
Or add
<filesystem type="mount" accessmode="passthrough">
<driver type="virtiofs"/>
<source dir="/shared/folder/on/host"/>
<target dir="shared-folder-name-on-guest"/>
<address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0"/>
</filesystem>
- Start your VM
- Creat a folder to mount the share
mkdir host-share
- Run:
sudo mount -t virtiofs shared-folder-name-on-guest /path/to/mount/on/guest
- auto mount
sudo nano /etc/fstab
append
shared-folder-name-on-guest /path/to/mount/on/guest virtiofs defaults 0 0
or
echo "shared-folder-name-on-guest /path/to/mount/on/guest virtiofs defaults 0 0" | sudo tee -a /etc/fstab
- Mount
sudo mount -a
or
sudo reboot now
sudo nano /etc/nixos/configuration.nix
systemd.mounts = [
{
what = "shared-folder-name-on-guest";
where = "/path/to/mount/on/guest";
type = "virtiofs";
wantedBy = [ "multi-user.target" ];
enable = true;
}
];
sudo nixos-rebuild switch
sudo reboot now