Skip to content

Instantly share code, notes, and snippets.

@fabiolimace
Last active September 15, 2024 14:35
Show Gist options
  • Save fabiolimace/8c4c476e195c9e6f85878aff8f220877 to your computer and use it in GitHub Desktop.
Save fabiolimace/8c4c476e195c9e6f85878aff8f220877 to your computer and use it in GitHub Desktop.
Share Host Folder with Guests in VirtManager

Share Host Folder with Guests in VirtManager

In VirtManager, in "show virtual hardware details":

  1. In "Memory", check "Enable shared memory";
  2. Press the button "Add hardware";
  3. In "File system":
    • Driver: virtiofs
      • if an error blocks the vm boot, use "virtio-9p" here and use Type=9p in the file mnt-shared.mount.
    • Source path: /shared (this value is the name of the host folder)
    • Target path: /shared (this value will be used in the file mnt-shared.mount)

In the host, create a folder to be shared with all guests:

sudo mkdir /shared
sudo chmod a+w /shared

In each guest, create a folder to be mapped with the host folder:

sudo apt install qemu-guest-agent;
sudo mkdir /mnt/shared
cat <<EOF > /tmp/mnt-shared.mount
[Unit]
Description=Ponto de montagem '/mnt/shared' para VirtManager Guest

[Mount]
What=/shared
Where=/mnt/shared
Type=virtiofs
Options=defaults,rw,noatime

[Install]
WantedBy=multi-user.target
EOF
sudo mv /tmp/mnt-shared.mount /etc/systemd/system/mnt-shared.mount
sudo systemctl enable mnt-shared.mount
sudo systemctl start mnt-shared.mount
# reboot

The end.

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