Install windows 11 virtual machine on KVM, libvirt, qemu, virt-manager in Linux, fedora 36/37, RPM based distribution
Tags: kvm, libvirt, qemu, virtmanager
Published: 2022-11-25 22:10:31

The following tutorial will tech you how to create a virtual machine on Linux, first we are going to install the virtual machine tools.

## Install and configure the virtual machine tools

Install the virtual machine tools grouped in @virtualization, some packages are: virt-manager, libvirt, qemu-kvm, etc. Source, [full virtualization on fedora workstation linux](https://fedoramagazine.org/full-virtualization-system-on-fedora-workstation-30/).

    sudo dnf install @virtualization

Edit the **libvirtd** configuration to enable a regular user the system administration privileges.

    sudo vim /etc/libvirt/libvirtd.conf

Set the domain socket group ownership to libvirt.

    unix_sock_group = "libvirt"

Adjust the UNIX socket permissions for the R/W socket.

    unix_sock_rw_perms = "0770"

Start and enable the libvirtd service.

    sudo systemctl start libvirtd
    sudo systemctl enable libvirtd

Add your user to the libvirt group.

    sudo usermod -aG libvirt $(whoami)

## Install the secure boot tool package

It is needed when you are configuring the virtual machine, windows 11 need it. To install run the following command.

    sudo dnf install edk2-ovmf

Source, [secure boot](https://fedoraproject.org/wiki/Using_UEFI_with_QEMU)

## Install TPM

We need to install the Software Trusted Platform Module Emulator it will be used when being customizing the virtual machine configuration, close virt-manager and got to the link below, download and install **swtpm-tools-0.7.3-1.20220427gitf2268ee.fc36.x86_64.rpm**, select according your distribution number, will select that for fedora 36 and today its the last version.

[swtpm-tools rpm fedora centos redhat](https://rpmfind.net/linux/rpm2html/search.php?query=swtpm-tools)

Go to the directory where you downloaded the package and install it with **dnf** package manager.

    cd Downloads
    sudo dnf install ./swtpm-tools-0.7.3-1.20220427gitf2268ee.fc36.x86_64.rpm


## Create a Pool to store the virtual machines

Before create a virtual machine first we will create a pool. A pool is a directory and you can use a partition for example. You can create the virtual machine in the default directory, but if you are thinking format your root directory in the future and want to preserve the virtual machine , save it in a new pool is a good option. 

Source, [new pool using a partition](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/virtualization_administration_guide/sect-virtualization-storage_pools-creating-file_systems).<br>

We will use a LVM partition **forvm-vmtest** and *You do not need to mount the partition*.

```
  ~                                                                                                                                                                       
❯ lsblk
NAME             MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda                8:0    0 447.1G  0 disk 
└─sda1             8:1    0   100G  0 part 
  └─forvm-vmtest 253:0    0   100G  0 lvm  
sdb                8:16   0   1.8T  0 disk 
├─sdb1             8:17   0   839G  0 part /run/media/chris/New Volume
├─sdb2             8:18   0  27.9G  0 part 
└─sdb3             8:19   0  93.2G  0 part 
  └─vg2-vms      253:1    0  93.2G  0 lvm  
sdc                8:32   0 223.6G  0 disk 
├─sdc1             8:33   0   100M  0 part /boot/efi
├─sdc2             8:34   0    16M  0 part 
├─sdc3             8:35   0   100G  0 part 
├─sdc4             8:36   0   123G  0 part /
└─sdc5             8:37   0   509M  0 part 
sdd                8:48   1     0B  0 disk 
sr0               11:0    1  1024M  0 rom  
zram0            252:0    0     8G  0 disk [SWAP]
```
Select the **QEMU/KVM drop-dawn tab** then in the menu select **Edit>Connection Details**.

![virt-manager-1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wcb4x1yr0902fr0qdq8n.png)

![virt-manager-2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bp526renyerz19uba02w.png)

Click in the **Storage tab**, click in bottom left corner the **Add Pool** plus symbol button.

![virt-manager-3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/okqffacgskjfel6ficyx.png)

Type and select the following data.

In Name type any name you like, in my case **vmtest**.<br>
In the type select **fs:Pre-Formatted Block Device**.<br>
In target path, you can create a directory in your home or any place of your directory system it will be the mount point, if it doesn’t exist yet it will be created, in my case it will be mounted in my root **"/"** directory with the following name. **/vmtest**.<br>
in Format **auto**.<br>
In the source path, select the device partition, in my case can use **/dev/mapper/forvm-vmtest** or **/dev/forvm/vmtest**.

Click in **Finish**.

![virt-manager-4](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qgdcnr2txj14g2hba17t.png)

You can enable **Autostart On Boot** option of the new pool **vmtest** created if you like.<br>
If the **State** of the pool is **Inactive**, click in the bottom left side the **play** button to start the pool. Click in Apply.

![virt-manager-5](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kozaovihn4j7vsr9d2ef.png)

## Create the windows 11 virtual machine

Click in the create a new virtual machine button.

![virt-manager-6](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p2nlwwf3t1ns3huszbmk.png)

Select Local install media, click in **Forward**.

![virt-manager-7](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6qvhi7rt7wvj51s4i1ko.png)

Select the ISO image file, click in **Browse**, Click in **Browse Local**, select your windows 11 image iso file, click **Open**.

![virt-manager-8](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6zdmnztsmccf8t35wsnf.png)

![virt-manager-9](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yt5lidkllhvosbf829ak.png)

Enable automatically detect from the installation media. So far windows 11 is not an option there, but windows 10 option works fine for now. Then click in **Forward**.

![virt-manager-10](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kp4eerx79k2myjh1wvh0.png)

Select the memory and cpu, its depent of your host machine capacity. For memory you can use **8192MiB** which is equivalent to 8GiB, for cpu **2**. Click **Forward**.

![virt-manager-11](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xh4gio0h9s8mjk93eitv.png)

Enable storage for the virtual machine, select **Select or Create custom storage**, click in **manage**.

![virt-manager-12](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qr73bhpqubmsrtvkgm3b.png)

Select the new pool in my case **vmtest**, click in the **plus symbol to Create a new volume** . Its important to use as capacity a minimum value of 65GiB.<br>
As name. you can use **win11**, in format **qcow2**, as capacity **65GiB**.
Click in **Finish**.

![virt-manager-13](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nrjvfm23g14j037smghz.png)

![virt-manager-14](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pr2unsu0an6ovckpta1f.png)

Select the new created volume **win11.qcow2**, click in **Choose Volume**.

![virt-manager-15](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eako0c2v7sxubfunyr1o.png)

Then click  **Forward**.

![virt-manager-16](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mjrc6yru9bopq5ipzq7g.png)

Fix the name to **win11** if you like. Enable customize configuration before install, click **Finish**.

![virt-manager-17](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ie5yp6dcjmrplv4gp7bi.png)

In the new window select in firmware option:<br>
**UEFI x86_64:/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd**

Click the **Apply** button to save the current change.

![virt-manager-18](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zdincpbe3i55wjydtjxs.png)

In the left side bar, click in **Boot options**. In **Boot device order** enable **SATA CDROM  1** and set that as the highest boot priority using the up arrow next to it.

Click **Apply**.

![virt-manager-19](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gmoxu52bspr8rwm8om4w.png)

![virt-manager-20](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8jnkjo228w9kgn0h66s1.png)

In the left side bar in the bottom click in **Add Hardware**, in the new window add a virtual TPM module, click in **TPM**, in Type select **Emulated**, click in **Advanced options** drop-dawn, in Model select **CRB**, in Version select **2.0**. Click **Finish**.

![virt-manager-21](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sy912gb75gktlkpwsks0.png)

Click the **Apply** button if you haven’t saved the changes yet.
Then in the top left corner click in **Begin Installation** button.

![virt-manager-22](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7bw2nr7ficl9zggxxo0w.png)

## Installing Windows 11, soon the tutorial

Go to the web

## Install Guest tools in the virtual machine

### Install spice-guest-tools

After install the windows 11 virtual machine, you can install **spice-guest-tools** to enable copy and paste, drag and drop files from host to guest, and fix screen resolution.

Power on the virtual machine and from inside the windows 11 virtual machine, go to [here](https://www.spice-space.org/download.html) and download **spice-guest-tools** and install inside the virtual machine.

![virt-manager-23](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1u7vj0mu4xegoyvn8nw3.png)

![virt-manager-24](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5pko8e2d7todz1xqap3s.png)

### Bonus: Enable **Auto resize VM with window** if it isn’t enable

If the **Auto resize VM with window** is not enable, you can install the latest **virtio-win-guest-tools**. Go to this [direct link](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win-guest-tools.exe) and download it, run it and install inside the virtual machine.

![virt-manager-25](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hvevyhsczx64huuz9i3r.png)

![virt-manager-26](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/flhvsdeeixvu8ubhfs0y.png)

![virt-manager-27](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i2rug3yj4v44apgbkxk1.png)

Source [getlabsdone website, install windows 11 vm on KVM](https://getlabsdone.com/how-to-install-windows-11-on-kvm/)