The solutions of virtualization are increasingly used, and its benefits are out of the question as they allow us to have at our disposal different platforms, whether for development, testing, servers or the task we will need, without having to fall into the cost of acquiring new hardware for this. And among the best known alternatives we have in VMware, Virtualbox or Hyper-V, but there is one that is virtually native to GNU / Linux and it is called KVM.
Its name is due to the initials of Kernel Virtual Machine (Kernel Virtual Machine) and allows us to run Linux and Windows platforms on a Linux computer. It is a very powerful solution but above all very flexible things, mainly because of being integrated into the core but also because we can use it from the command line or from a graphical interface (Virt-Manager) if we prefer.
That if, in order to install KVM we will need our hardware to support virtualization, Which in general any new team offered us but since it never hurts to know for sure. So we opened a terminal window (Ctrl + Alt + T) and executed:
egrep -c ‘(SVM | VMX)’ / proc / cpuinfo
If the result is 0 this means that our hardware does not offer support for virtualization, both Intel VT-x and AMD-V, but if on the contrary we get a 1 or a 2 this means that we are enabled to install KVM on our computerSo let’s get ready for this but beware, we may need it enable virtualization from the BIOS, So if something goes wrong despite getting your approval with this order, we already know where to go.
We install the necessary packages:
sudo apt-get install qemu-kvm libvirt-bin bridge-utils virt-manager
then we need add our user to the libvirtd group, Since only users belonging to this group or root are the skills to use KVM. For example, to add the user guille to libvirtd we run:
suo adduser guille libvitd
Once this is done we need to log out and log back in, and the first thing we need to do when doing this is run the next command, which will show us the list of virtual machines. Which of course should be empty:
virsh -c qemu: /// system list
Okay, we’re ready to get started to Create a Virtual Machine in KVM |, And the easiest is to use Virtual Machine Manager, The graphical tool we installed a few steps back. We click on the first icon on the left (in the top menu bar) which allows us to create virtual machines, and indicate the name that our virtual machine will have, indicating under the form in which we will use- la: by means of an ISO or CDROM image, network installation (HTTP, FTP, NFS), Network boot (PXE) or by importing an already pre-existing image.
We click on ‘Next’ and now we are asked to enter the path to the ISO image (Either to the network address, or to the image to import, depending on what we have selected in the previous step), and once we do we choose the type of operating system and the version that corresponds to it. Then click ‘Next’ and now what we will indicate will be the amount of memory and CPU that will have our virtual machine, always taking into account the fact that in a way this will be ‘subtracted’ from our host computer, so it is always advisable not to exceed the 50 percent of what we have available.
After a click on the next we are taken to the step in which we must configure the network, And here by default we always use a NAT configuration that allows us to ‘exit’ to the network but will not show us the guest computer as one more on our local network. Of course, we can modify this if we have different needs (for example, if we are running virtual servers). When we have everything ready we click ‘Finish’ and we can start at install the operating system as we would in a common, ordinary team.
We will be able to test different virtual machines and operating systems, and here again we say the same thing as many times: in the freedom of choice we have one of the strengths of Linux. Some will prefer Virtualbox, QEMU or VMware, and the reality is that performance in favor of one or the other will depend on several factors so the best we can do is try.