# Linux - Install KVM

<article class="post-14411 post type-post status-publish format-standard has-post-thumbnail hentry category-how-to tag-kvm-rhel-9 ast-article-single" id="bkmrk-prequisites-minimal-">#### <span data-darkreader-inline-color="">Prequisites</span>

<div class="ast-post-format- single-layout-1 ast-no-date-box"><div class="entry-content clear" itemprop="text">- Minimal Installed RHEL 9 with Desktop Environment
- Sudo user with admin rights
- Local Yum Repository or Red Hat Subscription
- Internet Connectivity (for Red Hat Subscription)

</div></div>Once the prerequisites are met then jump into installation steps of KVM.

### <span data-darkreader-inline-color="">1) Check Whether Virtualization is Enabled or not</span>

To get off the ground, you need to verify if your system supports Virtualization. By default, this is usually enabled in the BIOS. Therefore, to verify if Virtualization is enabled on your system, run the following commands:

<span data-darkreader-inline-color="">For Intel CPUs</span>

```bash
sudo grep -e 'vmx' /proc/cpuinfo
```

<span data-darkreader-inline-color="">For AMD CPUs</span>

```bash
sudo grep -e 'svm' /proc/cpuinfo
```

We are running an Intel CPU and the output of the command confirms that virtualization is already enabled.

Alternatively, you can run the following command. VT-x is Intel’s virtualization technology and this is yet another confirmation that Virtualization is enabled in the BIOS.

```bash
sudo lscpu | grep Virtualization
```

Also, you might want to check if KVM modules are loaded.

```bash
sudo lsmod | grep kvm
```

#### <span data-darkreader-inline-color="">2) Install Virtualization Packages</span>

The second step is to install the required virtualization packages on your system. But first, consider refreshing the repositories and install all available updates.

```bash
sudo dnf update -y
```

Once all the updates are installed successfully then reboot the system once</article><article class="post-14411 post type-post status-publish format-standard has-post-thumbnail hentry category-how-to tag-kvm-rhel-9 ast-article-single" id="bkmrk-sudo-reboot-next%2C-in">```bash
sudo reboot
```

Next, install the virt-install and virt-viewer packages using the following command.

```bash
sudo dnf install virt-install virt-viewer -y
```

<span data-darkreader-inline-color="">virt-install</span> is a command-line tool for creating virtual machines from the command line.

The <span data-darkreader-inline-color="">virt-viewer</span> application is a lightweight UI interface that enables you to interact with the KVM virtual machine using VNC or SPICE remote desktop protocol.

Next, install the <span data-darkreader-inline-color="">libvirt</span> virtualization daemon.

```bash
sudo dnf install -y libvirt
```

Once the virtualization daemon has been installed, proceed and install virt-manager. This is a Qt-based graphical interface for managing virtual machines using the libvirt daemon. ```bash
sudo dnf install virt-manager -y
```

Finally, install additional virtualization tools to provide a seamless user experience. ```bash
sudo dnf install -y virt-top libguestfs-tools
```

<span data-darkreader-inline-color="">3) Start and Enable Libvirtd Virtualization Daemon</span></article><article class="post-14411 post type-post status-publish format-standard has-post-thumbnail hentry category-how-to tag-kvm-rhel-9 ast-article-single" id="bkmrk-"></article><article class="post-14411 post type-post status-publish format-standard has-post-thumbnail hentry category-how-to tag-kvm-rhel-9 ast-article-single" id="bkmrk-once-you-have-instal">Once you have installed all the required virtualization packages, be sure to start and enable the virtualization daemon as follows.</article><article class="post-14411 post type-post status-publish format-standard has-post-thumbnail hentry category-how-to tag-kvm-rhel-9 ast-article-single" id="bkmrk-sudo-systemctl-start">```bash
sudo systemctl start libvirtd
sudo systemctl enable libvirtd
```

Then verify if the daemon is running.

```bash
sudo systemctl status libvirtd
```

<span data-darkreader-inline-color="">4) Configure Network Bridge for KVM</span>If you want to access your kvm virtual machines outside of your KVM hypervisor then you must configure a network bridge (kvmbr0) and attach physical interface to it.

<span data-darkreader-inline-color="">Note:</span> Virtual Bridge ‘vbr0’ automatically created when we install KVM packages. But this is used only for testing purpose. VMs will get the nated IP address via this bridge.

To create a network bridge kvmbr0, run following commands from the terminal,

```
$ nmcli connection show
$ sudo nmcli connection add type bridge autoconnect yes con-name kvmbr0 ifname kvmbr0
$ sudo nmcli connection modify kvmbr0 ipv4.addresses 192.168.1.179/24 gw4 192.168.1.1 ipv4.method manual
$ sudo nmcli connection modify kvmbr0 ipv4.dns 192.168.1.1
$ sudo nmcli connection del enp0s3
$ sudo nmcli connection add type bridge-slave autoconnect yes con-name enp0s3 ifname enp0s3 master kvmbr0
$ sudo nmcli connection up kvmbr0
```

<span data-darkreader-inline-color="">Note:</span> Replace the interface name and ip address details as per you setup.

Output of above commands,

Check network bridge (kvmbro) status using <span data-darkreader-inline-color="">[ip command](https://linuxtechi.com/ip-command-examples-for-linux-users/ "12 IP Command Examples for Linux Users")</span>, ```
$ ip addr show
```

  
### <span data-darkreader-inline-color="">5) Create Virtual Machine using Virt-Manager GUI</span>

With all the packages required by KVM already installed along with network bridge configuration. we will now launch a virtual machine using the Virtual Machine Manager GUI utility.

Using the GNOME search tool, search and launch the Virtual Machine Manager.

  
Next, you will be required to authenticate in order to start using the Virtual machine manager. So, provide your password and hit ‘<span data-darkreader-inline-color="">ENTER</span>’ or click the ‘<span data-darkreader-inline-color="">Authenticate</span>’ button.

  
On the Virtual Machine Manager, click on <span data-darkreader-inline-color="">File</span> &gt; <span data-darkreader-inline-color="">Add Connection.</span>

  
Set ‘<span data-darkreader-inline-color="">QEMU/KVM</span>’ as the default Hypervisor and click ‘<span data-darkreader-inline-color="">Connect</span>’.

  
To start creating a virtual machine, click on <span data-darkreader-inline-color="">File</span> &gt; <span data-darkreader-inline-color="">New Virtual Machine</span>

  
This opens the Virtual machine creation wizard. The first step will present you with a list of options for creating a virtual machine. In our case, we already have a Ubuntu 22.04 ISO image in place, and therefore, we will go with the first option – ‘<span data-darkreader-inline-color="">Local install media (ISO image or CDROM’</span>.

Once you have chosen your preferred choice, click ‘<span data-darkreader-inline-color="">Forward</span>’.

  
Next, click on ‘<span data-darkreader-inline-color="">Browse</span>’ to navigate to the directory containing the ISO file.

  
Since the ISO file is located on our local system, we will click on <span data-darkreader-inline-color="">‘Browse local</span>’.

  
Navigate to the destination directory and select the ISO image file and click ‘<span data-darkreader-inline-color="">Open’</span>.

  
Having selected the ISO image file, click ‘<span data-darkreader-inline-color="">Forward</span>’ to move to the next step.

  
Next, click ‘<span data-darkreader-inline-color="">Yes</span>’ to grant the emulator permissions to access the path of the ISO image file.

  
Next, select RAM size and the number of CPUs and then click ‘<span data-darkreader-inline-color="">Forward</span>’.

  
Next, specify the storage size for your virtual hard disk and click ‘<span data-darkreader-inline-color="">Forward</span>’.

  
On the next screen, Specify the name of virtual machine and then click on Network Selection and Choose ‘<span data-darkreader-inline-color="">kvmbro</span>’

  
click ‘<span data-darkreader-inline-color="">Finish</span>’ to begin OS installation.

The Virtual Machine Manager will start creating the VM.

  
Finally, the virtual machine will be launched and you will see the GRUB menu options listed for installing your virtual machine. From here, you can proceed to install your virtual machine.

  
The menu bar provides a couple of options for managing the virtual machine. Under the ‘<span data-darkreader-inline-color="">Virtual Machine</span>’ option you find options that allow you to pause, shutdown, migrate, delete or take a screenshot of the virtual machine.

  
The view option provides options for scaling or resizing the screen dimensions of the virtual machine.

  
Alternatively, you can right-click on the virtual machine on the Virtual Machine Manager and select your preferred options.

  
#### <span data-darkreader-inline-color="">Conclusion</span>

And there you have it. In this guide, we have illustrated how to install KVM on RHEL 9. We are glad to have your feedback on this guide.

</article>