{"id":17346,"date":"2023-06-18T01:10:40","date_gmt":"2023-06-17T22:10:40","guid":{"rendered":"https:\/\/kifarunix.com\/?p=17346"},"modified":"2024-03-10T09:47:01","modified_gmt":"2024-03-10T06:47:01","slug":"install-kvm-on-debian-12","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-kvm-on-debian-12\/","title":{"rendered":"Install KVM on Debian 12"},"content":{"rendered":"\n<p>In this tutorial, you will learn how to install KVM on Debian 12. KVM, an acronym for <a href=\"https:\/\/www.linux-kvm.org\/page\/Main_Page\" target=\"_blank\" rel=\"noreferrer noopener\">Kernel-based Virtual Machine<\/a>, is an opensource, full virtualization too for Linux systems with Intel-VT&nbsp;or&nbsp;AMD-V based-processors hardware virtualization extensions.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#installing-kvm-on-debian-12\">Installing KVM on Debian 12<\/a><ul><li><a href=\"#verify-hardware-virtualization-support-on-your-system\">Verify Hardware Virtualization Support on your System<\/a><\/li><li><a href=\"#installing-kvm-on-debian-12-1\">Installing KVM on Debian 12<\/a><\/li><li><a href=\"#start-libvirt-management-daemon-libvirtd\">Start libvirt management daemon (libvirtd)<\/a><\/li><li><a href=\"#launching-kvm-virtual-machine-manager\">Launching KVM Virtual Machine Manager<\/a><\/li><li><a href=\"#other-tutorials\">Other Tutorials<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-kvm-on-debian-12\">Installing KVM on Debian 12<\/h2>\n\n\n\n<p>Before you can proceed to install KVM;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"verify-hardware-virtualization-support-on-your-system\">Verify Hardware Virtualization Support on your System<\/h3>\n\n\n\n<p>KVM can only be used on systems with Intel or AMD processors. Thus, verify the support by executing the command below. The command looks for the CPU flags; <strong>Intel vmx (Virtual Machine Extension)<\/strong> or <strong>AMD svm (Secure virtual Machine)<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep --color -iE 'vmx|svm' \/proc\/cpuinfo<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>flags\t\t: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq <strong>vmx<\/strong> ssse3 cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti tpr_shadow vnmi flexpriority ept vpid fsgsbase bmi1 avx2 bmi2 invpcid rdseed clflushopt md_clear flush_l1d arch_capabilities\nvmx flags\t: vnmi invvpid ept_x_only flexpriority tsc_offset vtpr vapic ept vpid unrestricted_guest ple<\/code><\/pre>\n\n\n\n<p>If the output has <strong><code>vmx\/svm<\/code><\/strong>, then you good to go.<\/p>\n\n\n\n<p>If not, then find out how to enable virtualization on your respective machine BIOS.<\/p>\n\n\n\n<p>Similarly, you can use the command below to check Virtualization support.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lscpu | grep Virtualization<\/code><\/pre>\n\n\n\n<p>Sample output;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Virtualization:                  VT-x\nVirtualization type:             full<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"installing-kvm-on-debian-12-1\">Installing KVM on Debian 12<\/h3>\n\n\n\n<p>Once you confirm the virtualization support, proceed to install KVM by executing the command below. In this tutorial, we are using Debian 12 desktop version.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install virt-manager qemu-system libvirt-daemon-system qemu-utils<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\nReading package lists... Done\nBuilding dependency tree... Done\nReading state information... Done\nThe following additional packages will be installed:\n  dmeventd gir1.2-ayatanaappindicator3-0.1 gir1.2-gtk-vnc-2.0 gir1.2-libosinfo-1.0 gir1.2-libvirt-glib-1.0 gir1.2-spiceclientglib-2.0 gir1.2-spiceclientgtk-3.0\n  gir1.2-vte-2.91 gnutls-bin ibverbs-providers iptables ipxe-qemu libaio1 libcacard0 libcapstone4 libdaxctl1 libdevmapper-event1.02.1 libexecs0 libfdt1 libfmt9 libgfapi0\n  libgfrpc0 libgfxdr0 libglusterfs0 libgnutls-dane0 libgtk-vnc-2.0-0 libgvnc-1.0-0 libibverbs1 libip6tc2 libiscsi7 libisoburn1 liblvm2cmd2.03 libndctl6 libnss-mymachines\n  libphodav-3.0-0 libphodav-3.0-common libpmem1 librados2 librbd1 librdmacm1 libslirp0 libspice-client-glib-2.0-8 libspice-client-gtk-3.0-5 libspice-server1 libssh-4\n  libtpms0 libunbound8 liburing2 libusbredirhost1 libusbredirparser1 libvdeplug2 libvirglrenderer1 libvirt-clients libvirt-daemon libvirt-daemon-config-network\n  libvirt-daemon-config-nwfilter libvirt-daemon-driver-lxc libvirt-daemon-driver-qemu libvirt-daemon-driver-vbox libvirt-daemon-driver-xen libvirt-daemon-system-systemd\n  libvirt-glib-1.0-0 libvirt-glib-1.0-data libvirt-l10n libvirt0 libxencall1 libxendevicemodel1 libxenevtchn1 libxenforeignmemory1 libxengnttab1 libxenhypfs1\n  libxenmisc4.17 libxenstore4 libxentoolcore1 libxentoollog1 libxml2-utils lvm2 mdevctl netcat-openbsd ovmf python3-libvirt python3-libxml2 qemu-block-extra\n  qemu-efi-aarch64 qemu-efi-arm qemu-system-arm qemu-system-common qemu-system-data qemu-system-gui qemu-system-mips qemu-system-misc qemu-system-ppc qemu-system-sparc\n  qemu-system-x86 qemu-utils seabios spice-client-glib-usb-acl-helper swtpm swtpm-libs swtpm-tools systemd-container thin-provisioning-tools virt-viewer virtinst xorriso\nSuggested packages:\n  firewalld libvirt-clients-qemu libvirt-login-shell libvirt-daemon-driver-storage-gluster libvirt-daemon-driver-storage-iscsi-direct libvirt-daemon-driver-storage-rbd\n  libvirt-daemon-driver-storage-zfs numad auditd nfs-common open-iscsi pm-utils systemtap zfsutils samba vde2 trousers python3-guestfs ssh-askpass python3-argcomplete\n  xorriso-tcltk jigit cdck\nThe following NEW packages will be installed:\n  dmeventd gir1.2-ayatanaappindicator3-0.1 gir1.2-gtk-vnc-2.0 gir1.2-libosinfo-1.0 gir1.2-libvirt-glib-1.0 gir1.2-spiceclientglib-2.0 gir1.2-spiceclientgtk-3.0\n  gir1.2-vte-2.91 gnutls-bin ibverbs-providers iptables ipxe-qemu libaio1 libcacard0 libcapstone4 libdaxctl1 libdevmapper-event1.02.1 libexecs0 libfdt1 libfmt9 libgfapi0\n  libgfrpc0 libgfxdr0 libglusterfs0 libgnutls-dane0 libgtk-vnc-2.0-0 libgvnc-1.0-0 libibverbs1 libip6tc2 libiscsi7 libisoburn1 liblvm2cmd2.03 libndctl6 libnss-mymachines\n  libphodav-3.0-0 libphodav-3.0-common libpmem1 librados2 librbd1 librdmacm1 libslirp0 libspice-client-glib-2.0-8 libspice-client-gtk-3.0-5 libspice-server1 libssh-4\n  libtpms0 libunbound8 liburing2 libusbredirhost1 libusbredirparser1 libvdeplug2 libvirglrenderer1 libvirt-clients libvirt-daemon libvirt-daemon-config-network\n  libvirt-daemon-config-nwfilter libvirt-daemon-driver-lxc libvirt-daemon-driver-qemu libvirt-daemon-driver-vbox libvirt-daemon-driver-xen libvirt-daemon-system\n  libvirt-daemon-system-systemd libvirt-glib-1.0-0 libvirt-glib-1.0-data libvirt-l10n libvirt0 libxencall1 libxendevicemodel1 libxenevtchn1 libxenforeignmemory1\n  libxengnttab1 libxenhypfs1 libxenmisc4.17 libxenstore4 libxentoolcore1 libxentoollog1 libxml2-utils lvm2 mdevctl netcat-openbsd ovmf python3-libvirt python3-libxml2\n  qemu-block-extra qemu-efi-aarch64 qemu-efi-arm qemu-system qemu-system-arm qemu-system-common qemu-system-data qemu-system-gui qemu-system-mips qemu-system-misc\n  qemu-system-ppc qemu-system-sparc qemu-system-x86 qemu-utils seabios spice-client-glib-usb-acl-helper swtpm swtpm-libs swtpm-tools systemd-container\n  thin-provisioning-tools virt-manager virt-viewer virtinst xorriso\n0 upgraded, 108 newly installed, 0 to remove and 11 not upgraded.\nNeed to get 147 MB of archives.\nAfter this operation, 987 MB of additional disk space will be used.\nDo you want to continue? [Y\/n] y\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code><strong>virt-manager<\/strong><\/code>: Virt-Manager is a graphical user interface (GUI) tool for managing virtual machines through libvirt-daemon.<\/li>\n\n\n\n<li><strong><code>qemu-system<\/code><\/strong> is an open source virtualizer that provides hardware emulation for the KVM hypervisor. It acts as a virtual machine monitor together with the KVM kernel modules, and emulates the hardware for a full system such as a PC and its associated peripherals.<\/li>\n\n\n\n<li><strong><code>libvirt-daemon-system<\/code><\/strong> provides API libraries that enables GUI apps such as virt-manager to communicate with libvirtd daemon, a system service <strong><code>libvirtd<\/code><\/strong> , and a <strong><code>virsh<\/code><\/strong> CLI tool.<\/li>\n<\/ul>\n\n\n\n<p>If you are running an headless server with no GUI, then it suffices to just run the command below;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install qemu-system libvirt-daemon-system virtinst qemu-utils<\/code><\/pre>\n\n\n\n<p>Once the installation is done, check if KVM modules are loaded;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lsmod | grep -i kvm<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>kvm_intel             380928  0\nkvm                  1142784  1 kvm_intel\nirqbypass              16384  1 kvm<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"start-libvirt-management-daemon-libvirtd\">Start libvirt management daemon (libvirtd)<\/h3>\n\n\n\n<p>According to man pages, <em>the libvirtd program is the server side daemon component of the libvirt virtualization management system. This daemon runs on host servers and performs required management tasks for virtualized guests. This includes activities such as starting, stopping and migrating guests between host servers, configuring and manipulating networking, and managing storage for use by guests. The libvirt client libraries and utilities connect to this daemon to issue tasks and collect information about the configuration and resources of the host system and guests<\/em>.<\/p>\n\n\n\n<p>Thus, start and enable this service to run on system boot;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl enable --now libvirtd<\/code><\/pre>\n\n\n\n<p>Check the status;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl status libvirtd<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n\u25cf libvirtd.service - Virtualization daemon\n     Loaded: loaded (\/lib\/systemd\/system\/libvirtd.service; enabled; preset: enabled)\n     Active: active (running) since Sun 2023-06-18 01:00:04 EAT; 11s ago\nTriggeredBy: \u25cf libvirtd-ro.socket\n             \u25cf libvirtd-admin.socket\n             \u25cf libvirtd.socket\n       Docs: man:libvirtd(8)\n             https:\/\/libvirt.org\n   Main PID: 11619 (libvirtd)\n      Tasks: 19 (limit: 32768)\n     Memory: 27.1M\n        CPU: 149ms\n     CGroup: \/system.slice\/libvirtd.service\n             \u2514\u250011619 \/usr\/sbin\/libvirtd --timeout 120\n\nJun 18 01:00:02 bookwork systemd[1]: Starting libvirtd.service - Virtualization daemon...\nJun 18 01:00:04 bookwork systemd[1]: Started libvirtd.service - Virtualization daemon.\n<\/code><\/pre>\n\n\n\n<p><em>By default, the libvirtd daemon listens for requests on a local Unix domain socket.  Using the <strong><code>-l | --listen<\/code><\/strong> command line option, the libvirtd daemon can be instructed to additionally listen on a TCP\/IP socket. The TCP\/IP socket to use is defined in the libvirtd configuration file<\/em>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"launching-kvm-virtual-machine-manager\">Launching KVM Virtual Machine Manager<\/h3>\n\n\n\n<p>If you are running a desktop system, then you can launch the Virtual Machine manager from your applications or command line;<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1130\" height=\"948\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/06\/launch-virt-manager-debian.png\" alt=\"Install KVM on Debian 12\" class=\"wp-image-17350\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/06\/launch-virt-manager-debian.png?v=1687039509 1130w, https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/06\/launch-virt-manager-debian-768x644.png?v=1687039509 768w\" sizes=\"(max-width: 1130px) 100vw, 1130px\" \/><\/figure><\/div>\n\n\n<p>To launch it from command line;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>virt-manager<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1360\" height=\"553\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/06\/kvm-virt-manager-debian-12.png\" alt=\"Install KVM on Debian 12\" class=\"wp-image-17351\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/06\/kvm-virt-manager-debian-12.png?v=1687039538 1360w, https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/06\/kvm-virt-manager-debian-12-768x312.png?v=1687039538 768w\" sizes=\"(max-width: 1360px) 100vw, 1360px\" \/><\/figure>\n\n\n\n<p>If you are launching Virt-manager as standard user, you may be prompted to enter your administrator password to run it, <strong>&#8220;system policy prevents management of local virtualized systems&#8221;<\/strong>.<\/p>\n\n\n\n<p>To fix this, add the standard user to <strong><code>libvirt<\/code><\/strong> and <strong><code>kvm<\/code><\/strong> group (<em>Replace USERNAME with your user account<\/em>).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo usermod -aG libvirt,kvm <strong>USERNAME<\/strong><\/code><\/pre>\n\n\n\n<p>You can now start creating virtual machines and run them over KVM!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"other-tutorials\">Other Tutorials<\/h3>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/change-windows-boot-device-from-ide-to-virtio-on-kvm\/\" target=\"_blank\" rel=\"noreferrer noopener\">Change Windows Boot Device from IDE to Virtio on KVM<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/easy-way-to-extend-kvm-virtual-machine-disk-size\/\" target=\"_blank\" rel=\"noreferrer noopener\">Easy Way to Extend KVM Virtual Machine Disk Size<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/start-and-stop-kvm-virtual-machines-from-command-line\/\" target=\"_blank\" rel=\"noreferrer noopener\">Start and Stop KVM Virtual Machines from Command Line<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to install KVM on Debian 12. KVM, an acronym for Kernel-based Virtual Machine, is an opensource, full virtualization<\/p>\n","protected":false},"author":10,"featured_media":17353,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[36,121,112],"tags":[6916,6919,6915,6918,6917,6920,6921],"class_list":["post-17346","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-virtualization","category-howtos","category-kvm","tag-debian-12-kvm","tag-debian-12-virt-manager","tag-kvm-install-debian-12","tag-qemu-install-debian-12","tag-qemu-system-debian-12","tag-virt-install","tag-virt-install-debian-12","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/17346"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=17346"}],"version-history":[{"count":9,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/17346\/revisions"}],"predecessor-version":[{"id":20769,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/17346\/revisions\/20769"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/17353"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=17346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=17346"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=17346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}