DEV Community

Cover image for Install windows 11 virtual machine on KVM, libvirt, qemu, virt-manager in Linux, fedora 36/37, RPM based distribution
Christian Bueno
Christian Bueno

Posted on • Updated on

Install windows 11 virtual machine on KVM, libvirt, qemu, virt-manager in Linux, fedora 36/37, RPM based distribution

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.

sudo dnf install @virtualization
Enter fullscreen mode Exit fullscreen mode

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

sudo vim /etc/libvirt/libvirtd.conf
Enter fullscreen mode Exit fullscreen mode

Set the domain socket group ownership to libvirt.

unix_sock_group = "libvirt"
Enter fullscreen mode Exit fullscreen mode

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

unix_sock_rw_perms = "0770"
Enter fullscreen mode Exit fullscreen mode

Start and enable the libvirtd service.

sudo systemctl start libvirtd
sudo systemctl enable libvirtd
Enter fullscreen mode Exit fullscreen mode

Add your user to the libvirt group.

sudo usermod -aG libvirt $(whoami)
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Source, secure boot

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

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
Enter fullscreen mode Exit fullscreen mode

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.

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]
Enter fullscreen mode Exit fullscreen mode

Select the QEMU/KVM drop-dawn tab then in the menu select Edit>Connection Details.

virt-manager-1

virt-manager-2

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

virt-manager-3

Type and select the following data.

In Name type any name you like, in my case vmtest.

In the type select fs:Pre-Formatted Block Device.

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.

in Format auto.

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

You can enable Autostart On Boot option of the new pool vmtest created if you like.

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

Create the windows 11 virtual machine

Click in the create a new virtual machine button.

virt-manager-6

Select Local install media, click in Forward.

virt-manager-7

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

virt-manager-8

virt-manager-9

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

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

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

virt-manager-12

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.

As name. you can use win11, in format qcow2, as capacity 65GiB.
Click in Finish.

virt-manager-13

virt-manager-14

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

virt-manager-15

Then click Forward.

virt-manager-16

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

virt-manager-17

In the new window select in firmware option:

UEFI x86_64:/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd

Click the Apply button to save the current change.

virt-manager-18

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

virt-manager-20

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

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

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 and download spice-guest-tools and install inside the virtual machine.

virt-manager-23

virt-manager-24

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 and download it, run it and install inside the virtual machine.

virt-manager-25

virt-manager-26

virt-manager-27

Source getlabsdone website, install windows 11 vm on KVM

Top comments (1)

Collapse
 
karthidreamer profile image
Karthi Keyan