Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fedora - How to run virtual machines with virt-manager

#1
How to run virtual machines with virt-manager

<div style="margin: 5px 5% 10px 5%;"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/07/how-to-run-virtual-machines-with-virt-manager.png" width="550" height="237" title="" alt="" /></div><div><p>In the beginning there was dual boot, it was the only way to have more than one operating system on the same laptop. At the time, it was difficult for these operating systems to be run simultaneously or interact with each other. Many years passed before it was possible, on common PCs, to run an operating system inside another through virtualization.</p>
<p>Recent PCs or laptops, including moderately-priced ones, have the hardware features to run virtual machines with performance close to the physical host machine.</p>
<p>Virtualization has therefore become normal, to test operating systems, as a playground for learning new techniques, to create your own home cloud, to create your own test environment and much more. This article walks you through using Virt Manager on Fedora to setup virtual machines.</p>
<h2>Introducing QEMU/KVM and Libvirt</h2>
<p>Fedora, like all other Linux systems, comes with native support for virtualization extensions. This support is given by KVM (Kernel based Virtual Machine) currently available as a kernel module.</p>
<p>QEMU is a complete system emulator that works together with KVM and allows you to create virtual machines with hardware and peripherals. </p>
<p>Finally <a href="https://libvirt.org/">libvirt</a> is the API layer that allows you to administer the infrastructure, ie create and run virtual machines.</p>
<p>The set of these three technologies, all open source, is what we’re going to install on our Fedora Workstation.</p>
<h2>Installation</h2>
<h3>Step 1: install packages</h3>
<p>Installation is a fairly simple operation. The Fedora repository provides the “virtualization” package group that contains everything you need.</p>
<pre class="wp-block-code"> <div class="codecolorer-container text default" style="overflow:auto;border:1px solid #9F9F9F;width:435px"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace">sudo dnf install @virtualization</div></div> </pre>
<h3>Step 2: edit the libvirtd configuration</h3>
<p>By default the system administration is limited to the root user, if you want to enable a regular user you have to proceed as follows.</p>
<p>Open the /etc/libvirt/libvirtd.conf file for editing</p>
<pre class="wp-block-code"> <div class="codecolorer-container text default" style="overflow:auto;border:1px solid #9F9F9F;width:435px"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace">sudo vi /etc/libvirt/libvirtd.conf</div></div> </pre>
<p>Set the domain socket group ownership to libvirt</p>
<pre class="wp-block-code"> <div class="codecolorer-container text default" style="overflow:auto;border:1px solid #9F9F9F;width:435px"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace">unix_sock_group = &quot;libvirt&quot;</div></div> </pre>
<p>Adjust the UNIX socket permissions for the R/W socket</p>
<pre class="wp-block-code"> <div class="codecolorer-container text default" style="overflow:auto;border:1px solid #9F9F9F;width:435px"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace">unix_sock_rw_perms = &quot;0770&quot;</div></div> </pre>
<h3>Step 3: start and enable the libvirtd service</h3>
<pre class="wp-block-code"> <div class="codecolorer-container text default" style="overflow:auto;border:1px solid #9F9F9F;width:435px"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace">sudo systemctl start libvirtd<br />
sudo systemctl enable libvirtd</div></div> </pre>
<h3>Step 4: add user to group</h3>
<p>In order to administer libvirt with the regular user you must add the user to the libvirt group, otherwise every time you start virtual-manager you will be asked for the password for sudo.</p>
<pre class="wp-block-code"> <div class="codecolorer-container text default" style="overflow:auto;border:1px solid #9F9F9F;width:435px"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace">sudo usermod -a -G libvirt $(whoami)</div></div> </pre>
<p>This adds the current user to the group. You must log out and log in to apply the changes.</p>
<h2>Getting started with virt-manager</h2>
<p>The libvirt system can be managed either from the command line (virsh) or via the virt-manager graphical interface. The command line can be very useful if you want to do automated provisioning of virtual machines, for example with <a href="https://fedoramagazine.org/get-the-latest-ansible-2-8-in-fedora/">Ansible</a>, but in this article we will concentrate on the user-friendly graphical interface.</p>
<p>The virt-manager interface is simple. The main form shows the list of connections including the local system connection.</p>
<p>The connection settings include virtual networks and storage definition. it is possible to define multiple virtual networks and these networks can be used to communicate between guest systems and between the guest systems and the host.</p>
<h2>Creating your first virtual machine</h2>
<p>To start creating a new virtual machine, press the button at the top left of the main form:</p>
<figure class="wp-block-image"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/07/how-to-run-virtual-machines-with-virt-manager.png" alt="" class="wp-image-28766" /></figure>
<p>The first step of the wizard requires the installation mode. You can choose between a local installation media, network boot / installation or an existing virtual disk import:</p>
<figure class="wp-block-image"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/07/how-to-run-virtual-machines-with-virt-manager-1.png" alt="" class="wp-image-28771" /></figure>
<p>Choosing the local installation media the next step will require the ISO image path:</p>
<figure class="wp-block-image"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/07/how-to-run-virtual-machines-with-virt-manager-2.png" alt="" class="wp-image-28767" /><figcaption></figcaption></figure>
<p>The subsequent two steps will allow you to size the CPU, memory and disk of the new virtual machine. The last step will ask you to choose network preferences: choose the default network if you want the virtual machine to be separated from the outside world by a NAT, or bridged if you want it to be reachable from the outside. Note that if you choose bridged the virtual machine cannot communicate with the host machine.</p>
<p>Check “Customize configuration before install” if you want to review or change the configuration before starting the setup:</p>
<figure class="wp-block-image"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/07/how-to-run-virtual-machines-with-virt-manager-3.png" alt="" class="wp-image-28768" /></figure>
<p>The virtual machine configuration form allows you to review and modify the hardware configuration. You can add disks, network interfaces, change boot options and so on. Press “Begin installation” when satisfied:</p>
<figure class="wp-block-image"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/07/how-to-run-virtual-machines-with-virt-manager-4.png" alt="" class="wp-image-28769" /></figure>
<p>At this point you will be redirected to the console where to proceed with the installation of the operating system. Once the operation is complete, you will have the working virtual machine that you can access from the console:</p>
<figure class="wp-block-image"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/07/how-to-run-virtual-machines-with-virt-manager-5.png" alt="" class="wp-image-28770" /></figure>
<p>The virtual machine just created will appear in the list of the main form, where you will also have a graph of the CPU and memory occupation:</p>
<figure class="wp-block-image"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/07/how-to-run-virtual-machines-with-virt-manager-6.png" alt="" class="wp-image-28772" /></figure>
<p>libvirt and virt-manager is a powerful tool that allows great customization to your virtual machines with enterprise level management. If something even simpler is desired, note that Fedora Workstation comes with <a href="https://fedoramagazine.org/getting-started-with-virtualization-in-gnome-boxes/">GNOME Boxes pre-installed and can be sufficient for basic virtualization needs</a>. </p>
</div>
Reply



Forum Jump:


Users browsing this thread:
2 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016