Windows 11 LXD Virtual Machine (Updated November 2023)

We all know about Virtual Machines (VM). We know that there are many hypervisors like VirtualBox, Windows Hyper-V and VMWare. Linux also has Kernel Virtual Machines (KVM) which are accessed with the Linux QEMU program.

If you watch my channel regularly, you know that I like to focus on the strengths and capabilities of Linux Containers (LXC/LXD). Linux Containers behave like fully featured Linux machines, but they use the kernel of the host machine and really only reproduce user space virtually in a container. That allows a LXD container to install any components required for an application.

LXD containers are pretty much instant on and have no installation process or boot cycle.

This presentation focuses on LXD Virtual Machines. LXD VMs use the “lxc” CLI to create and manage containers. However, LXD VMs make calls to QEMU components are are really virtual machines. This allows LXD VMs to be any operating system including Windows.

In this presentation, I expanded on the last presentation where I introduced LXD VMs. This time I showed how to create a LXD VM for Windows 11.

The prerequisites are that you have LXD installed and also QEMU on your Linux Host. You also need to download the latest Windows ISO from the Microsoft site and rename it to windows11.iso.

This requires a minimum of LXD V4.0:

lxc version

At the time of this writing, the latest version of LXD is 5.1. To update to the latest version of LXD:

sudo snap refresh lxd --channel=latest/stable

Next install distrobuilder which is used to repackage iso images in a form that LXD can work with.

sudo snap install distrobuilder --edge --classic

Next, install the basic dependencies:

sudo apt install -y libguestfs-tools wimtools remmina-plugin-spice virt-viewer genisoimage

Now use distro-builder to repackage your Windows11 ISO:

sudo distrobuilder repack-windows --windows-version=w11 --windows-arch=amd64 windows11.iso win11.lxd.iso

Now create an empty LXD VM:

lxc init win11 --vm --empty

Set the size of your Drive C for the Windows LXD VM:

lxc config device override win11 root size=50GiB

Set your number of CPUs and memory allocation:

lxc config set win11 limits.cpu=4 limits.memory=8GiB

Set the override for TPM

lxc config device add win11 vtpm tpm

Define the installation media:

lxc config device add win11 install disk source=/home/scott/win11.lxd.iso boot.priority=10

Start the installation and connect to the console in one command:

lxc start win11 --console=vga

Windows installation will reboot many times as is normal. To reconnect to the console you will issue this command:

lxc console win11 --type=vga

Near the end of the video, we discovered that the Windows 11 LXD VM was not reachable via a ping on our bridged network adapter to the main LAN. In order to resolve this, you will need to install the Redhat VirtIO Drivers for Linux.

These drivers include a network adapter driver that resolves the network issue and a display adapter driver that allows the display resolution to be selected and changed. The download is an ISO disk image with an install file on the image. In addition, you will want to go into the Windows device manager and update drivers while pointed to this disk image.

Once these drivers are installed, go back to the LXD VM host and run the following command to add sound support to your Windows LXD VM:

lxc config set win11 raw.qemu -- "-device intel-hda -device hda-duplex"
1 Like

Hi Scott,

Thanks for your videos, I’m learning lots about Linux. I am just playing with setting up a server to be a LXD server and really could use a Windows VM. I tried this method, with a Win 10 iso but got an error:
Error: failed to read directory “”: open : no such file or directory.

I did run it as sudo and made the change to specify the different version of Windows and file names.

Google didn’t seem to offer any advice about using distrobuilder to repack windows so I’m asking if you have any suggestions to try.

Please visit https://chat.scottibyte.com/ and we can discuss this. Thx.