How to install QEMU/KVM on Debian based Distros

How to install QEMU/KVM on Debian based Distros


   Quick Emulator and Kernel-based Virtual Machine (QEMU/KVM) are two essential parts of a powerful open-source virtualization solution. On Linux-based systems, it enables users to construct and manage virtual machines (VMs). KVM is a flexible solution for running different operating systems on a single physical host because it combines hardware virtualization with QEMU's hardware emulation features.
 


Why It's Useful:

  • Performance: 

    • QEMU/KVM delivers high performance by directly using host hardware resources.
  • Open Source: 

    • It's free and open source, making it cost-effective and community-driven.
  • Wide OS Support: 

    • It runs various guest OSes, including Linux, Windows, and macOS.
  • Advanced Features: 

    • Supports live migration and snapshots for flexibility.
  • Security: 

    • Enhanced by Linux kernel security
 

Differences vs. VirtualBox and VMware:

  • Performance:

    • QEMU/KVM excels for CPU-intensive tasks, outperforming VirtualBox, and rivals VMware.
  • Licensing: 

    • QEMU/KVM is free, while VMware often requires paid licenses. VirtualBox is also free but more suited for personal use.
  • Integration:

    • VMware is feature-rich for enterprises, VirtualBox is user-friendly for individuals, and QEMU/KVM offers a balance of performance and customization.
  • Snapshotting: 

    • VMware has advanced snapshot management, while both QEMU/KVM and VirtualBox support basic snapshot functionality.

 

Automated KVM Installation:

Step-1 : Pull the Github repo 

Go to my QEMU/KVM Installation Script Github Repo and copy installation link and pull it, Or run this command to pull :

git clone https://github.com/aaaalmassri/Bash-Automation.git

 

 
 
 
 

Step-2 :Check script file integrity

Count script hash value and then check it with Hash-Value.txt file to ensure its integrity during transportation:

md5sum Bash-Automation/QEMU-KVM_Installation/QEMU-KVM_Installation.sh 

 

 
 
 
Then cat Hash-Value.txt content and compare the two value to check if there is any tampering in the script file:

cat Bash-Automation/QEMU-KVM_Installation/Hash-Value.txt 

 

 

 

Step-3 : Change script file permission

Now, It's time to run the script file, but first must change File Permission to Executable by running this command:

chmod 100 Bash-Automation/QEMU-KVM_Installation/QEMU-KVM_Installation.sh 

 

 
 

Step-4 : Start the installation process by running the script file 

Now. Let's run the script With Root-Privilege using this command:  

./Bash-Automation/QEMU-KVM_Installation/QEMU-KVM_Installation.sh 

  (In my screenshot, I'm already Root-User and I have QEMU/KVM installed)


 

 

 

 

 

 

 

 

 

 

 

 

Manual KVM Installation:

Step-1 : Pre-Installation Checks 

Before you install KVM, you must check if your CPU support virtualization by count the CPU cores that support hardware virtualization like "Intel VT-x (VMX) or AMD-v (SVM)". For that, you must fetch {cpurinfo} by running the following command in the terminal: 

egrep -c '(vmx|svm)' /proc/cpuinfo


 

If the output of the above command is Greater than 1, it means your processor supports hardware virtualization. But further checks needed, check your virtualization option is enabled in the BIOS setup. 

Install (cpu-checker) utility to use one of its tools called (kvm-ok) to check that your KVM acceleration can be used. Don't freak out if you see an output saying KVM acceleration cannot be used. You can still run your virtual machines, but it will be much slower without the KVM extensions.

Use this command to install cpu-checker:  

apt install cpu-checker -y 

 

 

Then use this command to check if KVM acceleration supported by your machine:

  kvm-ok 





Step-2 : Install Necessary Packages

Run the following command to install a suite of packages related to QEMU/KVM virtualization and virtual machine management. It includes "qemu-guest-agent" for guest-host communication, "qemu-utils" for image manipulation, "qemu-block-extra" for additional storage options, "qemu-system-common" for common QEMU/KVM files. QEMU is the backend of KVM.

 apt install qemu-guest-agent qemu-utils qemu-block-extra qemu-system-common  -y

(Note, I already have these packages installed this why don't show too many lines in the result, in your side you will see more lines to show you the packages that have been installed)


 



Step-3 :Add Users to QEMU/KVM Groups

You need to make sure that your user (Regular user, not the root user) is added to the libvirt and KVM user group. Run the following commands to add your specific username to respective groups.

 

 sudo adduser UserName libvirt  


 

   sudo adduser UserName kvm 


 

 

Step-4 : Install Virtual Machine Manager

A GUI utility called virt-manager is used to manage virtual machines using libvirt. It provides an overview of active domains, their real-time performance, and resource usage data. The wizard makes it possible to create new domains. Additionally, it configures and modifies the virtual hardware and resource distribution for the domain. The following command can be used to install this utility.

 

 sudo apt install virt-manager -y 

 (Same note as before)

 

 

 

Now, you can open the Virtual Machine Manager using the command line by using the "virt-manager" command on the terminal.

  virt-manager 

(Forget about my Virtual Machine Manager screen, I have already setup some machines)



 

Or by using the application menu by searching for "Virtual Machine Manager".

 Manage virtual machines

 

 

Conclusion


   We have briefly covered KVM virtualization in this post, so we've unlocked a world of versatile virtualization possibilities. QEMU/KVM empowers users to harness the full potential of their hardware, offering remarkable performance, security, and flexibility in managing virtual environments.

   From understanding the fundamentals to executing the installation steps, you've gained the expertise needed to embark on your virtualization adventures. Whether you're looking to consolidate server resources, experiment with different operating systems, or enhance your software development workflow, QEMU/KVM stands as a robust and open-source solution that can meet your needs.

 

Comments

Popular posts from this blog

How To Setup Bridge Network in QEMU/KVM

How to setup Perfect Windows Virtual Machine On QEMU/KVM