Install Windows 11 in virtual machine using virt-manager
15 Jan 2022Lets install Windows 11 in a virtual machine using an emulated TPM module. It can be useful to have a virtual Windows machine for some software.
Install SWTPM - Emulated TPM module
If your computer already have a supported TPM module and it is activated in the UEFI settings you can skip this part and choose to passthrough your TPM module.
Lets install the swtpm package to emulate a TPM module. At the moment there is no Debian package for this, so we have to build it. First we need the source code so clone the repository using git
git clone https://github.com/stefanberger/swtpm.git
First install some build dependencies
cd swtpm
mk-build-deps -i
if that fails you can run this to install dependencies
sudo apt-get -y install dpkg-dev debhelper libssl-dev libtool net-tools libfuse-dev libglib2.0-dev libgmp-dev expect libtasn1-dev socat python3-twisted gnutls-dev gnutls-bin libjson-glib-dev python3-setuptools softhsm2 libseccomp-dev gawk libtpms-dev
Now we can build the packages
dpkg-buildpackage -us -uc -j$(nproc)
Now there will be lots of packages in the parent folder of swtpm, lets install what we need
apt install libtpms0
apt install ./swtpm-libs_0.8.0~dev1_amd64.deb
apt install ./swtpm__0.8.0~dev1_amd64.deb
apt install ./swtpm-tools_0.8.0~dev1_amd64.deb
Download Windows 11 iso and Virtio drivers
Microsoft is nice to have the Windows 11 iso on their site. Just remember that you still have to own a license to use it.
The virtio driver iso can be found over at the Fedora Projects site. virtio-win-0.1.208.iso
Create virtual machine
Now lets create the virtual machine
But it is important that you chose to Customize configuration before install
Change BIOS to UEFI
Change the firmware to UEFI
Replace SATA disk with Virtio disk
Now I want to replace the emulated SATA disk with the better virtio disk controller.
Click Add hardware again and choose Storage, click Manage… to browse for our harddrive image
Add a second CD-Rom device for virtio drivers iso
Because Windows install iso will be placed in the default CD rom device we have to add a second CD Rom device for the virtio device drivers.
Click Add Hardware again and choose Storage, this time we change the Device type to CDROM device. Then click Manage… to browse for the virtio drivers iso
Ready to install
Almost ready to install, click Boot Options and make sure the boot order is correct with SATA CDROM 1 first.
Windows Install, virtio drivers
Remember to press a button to boot the installer, then just install almost as on bare hardware.