{"id":9143,"date":"2024-08-27T15:32:56","date_gmt":"2024-08-27T15:32:56","guid":{"rendered":"https:\/\/www.linuxandotherstuff.com\/?p=9143"},"modified":"2024-08-27T16:49:52","modified_gmt":"2024-08-27T16:49:52","slug":"how-to-install-kvm-on-ubuntu","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2024\/08\/27\/how-to-install-kvm-on-ubuntu\/","title":{"rendered":"How to Install KVM on Ubuntu"},"content":{"rendered":"\n<p>Update Ubuntu<\/p>\n\n\n\n<p>Run the command below:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo apt update\n<\/pre><\/div>\n\n\n<p>Check Virtualization Support on Ubuntu<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\negrep -c &#039;(vmx|svm)&#039; \/proc\/cpuinfo\n<\/pre><\/div>\n\n\n<p>Output:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nrogerp@skynet:~\/.ssh$ sudo egrep -c &#039;(vmx|svm)&#039; \/proc\/cpuinfo\n16\n<\/pre><\/div>\n\n\n<p>If the command returns a value of 0, your processor is not capable of running KVM. On the other hand, any other number means you can proceed with the installation.<\/p>\n\n\n\n<p>Next, check if your system can use KVM acceleration:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo kvm-ok\n<\/pre><\/div>\n\n\n<ol start=\"2\" class=\"wp-block-list\"><\/ol>\n\n\n\n<p><\/p>\n\n\n\n<p>The output should look like this:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nrogerp@skynet:~\/.ssh$ sudo kvm-ok\nINFO: \/dev\/kvm exists\nKVM acceleration can be used\n<\/pre><\/div>\n\n\n<p>If kvm-ok returns an error, install cpu-checker to resolve the issue.<\/p>\n\n\n\n<p>To install cpu-checker, run the following command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo apt install cpu-checker\n<\/pre><\/div>\n\n\n<ol start=\"3\" class=\"wp-block-list\"><\/ol>\n\n\n\n<p><\/p>\n\n\n\n<p>When the installation completes, rerun the command to check KVM acceleration availability, and if everything is ok, you are ready to start installing KVM.<\/p>\n\n\n\n<p><br>Install KVM Packages<\/p>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\"><\/ol>\n\n\n\n<p>Install the essential KVM packages with the following command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils -y\n<\/pre><\/div>\n\n\n<p>Wait until the system installs all the packages.<\/p>\n\n\n\n<p><br>Authorize Users<\/p>\n\n\n\n<p>Only members of the libvirt and kvm user groups can run virtual machines. If you want specific users to run VMs, add them to those user groups. Follow the steps below:<\/p>\n\n\n\n<p>Add the user you want to run the virtual machines to the libvirt group:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo adduser &#x5B;username] libvirt\n<\/pre><\/div>\n\n\n<ol class=\"wp-block-list\"><\/ol>\n\n\n\n<p>Replace [username] with the actual username.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, do the same for the kvm group:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo adduser &#x5B;username] kvm\n<\/pre><\/div>\n\n\n<ol start=\"2\" class=\"wp-block-list\"><\/ol>\n\n\n\n<p>Verify the Installation<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo virsh list --all\n Id   Name   State\n--------------------\n<\/pre><\/div>\n\n\n<p>Alternatively, use the systemctl command to check the status of libvirtd, the daemon that provides the backend services for the libvirt virtualization management system:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo systemctl status libvirtd\n<\/pre><\/div>\n\n\n<p>If everything is functioning properly, the output returns an active (running) status.<\/p>\n\n\n\n<p>Create Virtual Machine on Ubuntu<\/p>\n\n\n\n<p>Before you choose one of the two methods below for creating a VM, install virt-manager, a tool for creating and managing VMs:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo apt install virt-manager -y\n<\/pre><\/div>\n\n\n<p>Start virt-manager by running the command below:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo virt-manager\n<\/pre><\/div>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Update Ubuntu Run the command below: Check Virtualization Support on Ubuntu Output: If the command returns a value of 0, your processor is not capable of running KVM. On the other hand, any other number means you can proceed with the installation. Next, check if your system can use KVM acceleration: The output should look &#8230; <a title=\"How to Install KVM on Ubuntu\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2024\/08\/27\/how-to-install-kvm-on-ubuntu\/\" aria-label=\"Read more about How to Install KVM on Ubuntu\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[57],"tags":[],"class_list":["post-9143","post","type-post","status-publish","format-standard","hentry","category-kvm"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/9143","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=9143"}],"version-history":[{"count":10,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/9143\/revisions"}],"predecessor-version":[{"id":9160,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/9143\/revisions\/9160"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=9143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=9143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=9143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}