Virt-Manager

Table of Contents

Install Virt-Manager

In Arch Linux:

sudo pacman -S qemu virt-manager ebtables

Enable Virtualization In BIOS

Enable virtualization in your computer’s BIOS settings, since it is usually disabled by default. To get into the BIOS, restart your computer and at the first boot screen, hit the appropriate key to get into the BIOS (it should tell you the key to hit onscreen). Typically, the key is F2 or DEL, but it could be another key depending on the motherboard. Once in the BIOS, look for a setting for SVM and set it to enabled.

libvirtd

Enable libvirtd

Enable and start libvirtd with systemd:

sudo systemctl enable libvirtd
sudo systemctl status libvirtd

Other useful systemd commands to know include:

sudo systemctl stop libvirtd  ## stop the service
sudo systemctl restart libvirtd  ## restart the service

Add your user to the libvirt group

Run the following command to add your user to the libvirt group:

sudo usermod -G libvirt -a your_username

Convert VirtualBox images to Qcow2

Many virt-manager users also sometimes create virtual machines in VirtualBox. And sometimes you want to be able to convert your VirtualBox images (vdi) to the format that virt-manager uses (qcow2).

The following is an example of converting a VirtualBox VM named “Ubuntu 20.04” (notice the space in the name) over to the qcow2 format:

sudo qemu-img convert -f vdi -O qcow2 Ubuntu\ 20.04.vdi /var/lib/libvirt/images/ubuntu-20-04.qcow2

Shared folders

On the host machine:

mkdir share
chmod 777 share/

Make sure the guest machine is not running. Then, attach the new filesystem:

  • Open virtual hardware details: View > Details
  • Then: Add Hardware > Filesystem
  • Put the name of the source path (/path/to/share).
  • Put the virtual target path (example: /sharepoint)
  • Switch mode to Mapped if you need write access from the guest
  • Confirm and start the VM

Inside the VM, you need to mount your shared folder:

mkdir share
sudo mount -t 9p -o trans=virtio /sharepoint /path/to/share

Or, you could permanently add it to the guest’s /etc/fstab:

/sharepoint   /path/to/share    9p  trans=virtio,version=9p2000.L,rw    0   0

If you don’t have SELinux enabled everything should work now. If you do, then you will need to add a policy for files under your /share folder on your host. SELinux won’t allow you to share this folder until it’s labeled svirt_image_t. Here is how to add this policy on your host using semanage:

# semanage fcontext -a -t svirt_image_t "/share(/.*)?"
# restorecon -vR /share

Footer

Copyright © 2020-2021 Derek Taylor (DistroTube)

This page is licensed under a Creative Commons Attribution-NoDerivatives 4.0 International License (CC-BY-ND 4.0).

The source code for distro.tube can be found on GitLab. User-submitted contributions to the site are welcome, as long as the contributor agrees to license their submission with the CC-BY-ND 4.0 license.

Author: dt

Created: 2022-02-20 Sun 10:16