LXD is a hypervisor to run both system containers (a la LXC) and virtual machines (a la QEMU) on Linux distributions. System containers are lightweight because they are based solely on the Linux kernel for their virtualization features, and support Linux guests only. However, virtual machines can run other operating systems. In this post, we see how to run Windows in a LXD virtual machine.
The benefit with running Windows through LXD is that you are using the familiar LXD workflow and takes away some of the the complexity from the other ways of running a VM (like virt-manager
).
The content of this tutorial came from https://discuss.linuxcontainers.org/t/running-virtual-machines-with-lxd-4-0/7519 Look towards the end of the thread where Stéphane Graber describes how to simplify the process compared to the instructions at the top of that thread.
The prerequisite is that you have LXD configured and running.
In the following, we
- Download a Windows 10 ISO from Microsoft.
- Prepare the ISO using
distrobuilder
(we do this once per ISO). - Start the virtual machine from that prepared ISO and go through the installation.
Download a Windows 10 ISO
You can download a Windows 10 ISO from Microsoft, through the following URL.
https://www.microsoft.com/en-us/software-download/windows10ISO
You will be given the option to select Windows 10. Then, select a language for the Windows 10 ISO, and finally to select whether to download a 32-bit or 64-bit version. Select your preferred language, and then choose the 64-bit version.
Once the ISO file has been downloaded, move to the next section.
Prepare the ISO using distrobuilder
Install the distrobuilder
package. It is available as a snap package, using the classic
type of confinement. Currently, the repack-windows
option is available in the very latest version of distrobuilder
. Therefore, we have to add for now the --edge
parameter. This means that distrobuilder
as a snap package will be updated frequently, being the edge
channel. Once you perform the repack
, you may switch distrobuilder
to the stable
channel with sudo snap refresh distrobuilder --stable
for the typical use of the tool. In addition, distrobuilder
, although it is a snap package, it has the classic confinement, which means that it uses packages from the host. It uses libguestfs-tools
which provides the utility hivexregedit
. We install that package as well.
sudo snap install distrobuilder
--edge --classic
sudo apt install -y libguestfs-tools
Then, run distrobuilder
over the Windows 10 ISO as follows. Obviously, the filename of the ISO file might be different in your case. Adapt and overcome.
$ sudo distrobuilder repack-windows Win10_1809Oct_English_x64.iso Win10_1809Oct_English_x64-distrobuilder.iso
2021/02/13 23:15:57 Mounting Windows ISO ...
2021/02/13 23:15:57 Downloading drivers ISO ...
2021/02/13 23:24:19 Mounting driver ISO ...
2021/02/13 23:24:20 Injecting drivers into boot.wim (index 2)...
2021/02/13 23:24:24 Injecting drivers into install.wim (index 1)...
2021/02/13 23:25:01 Injecting drivers into install.wim (index 2)...
2021/02/13 23:25:09 Injecting drivers into install.wim (index 3)...
2021/02/13 23:25:17 Injecting drivers into install.wim (index 4)...
2021/02/13 23:25:25 Injecting drivers into install.wim (index 5)...
2021/02/13 23:25:33 Injecting drivers into install.wim (index 6)...
2021/02/13 23:25:41 Injecting drivers into install.wim (index 7)...
2021/02/13 23:25:49 Injecting drivers into install.wim (index 8)...
2021/02/13 23:25:57 Injecting drivers into install.wim (index 9)...
2021/02/13 23:26:05 Injecting drivers into install.wim (index 10)...
2021/02/13 23:26:13 Injecting drivers into install.wim (index 11)...
2021/02/13 23:26:21 Generating new ISO ...
$
In my case, it generated a new ISO, the one with a name Win10_1809Oct_English_x64-distrobuilder.iso
. We have the prepared ISO, we can now start.
Start the Windows 10 installation
Run the following commands to initialize the VM, to configure (=increase) the allocated disk space and finally attach the full path of your prepared ISO file. Note that the installation of Windows 10 takes about 10GB (before updates), therefore a 30GB disk gives you about 20GB of free space.
lxc init win10 --empty --vm -c security.secureboot=false lxc config device override win10 root size=30GiB lxc config device add win10 iso disk source=/home/myusername/Downloads/Win10_1809Oct_English_x64-distrobuilder.iso boot.priority=10
Now, the VM win10
has been configured and it is ready to be started. The following command starts the virtual machine and opens up a VGA console so that we go through the graphical installation of Windows.
lxc start win10 --console=vga

Note that the installation of Windows 10 does a few restarts before you end up on the desktop. Those will appear as errors in your terminal that look like the following.
(remote-viewer:13539): dbind-WARNING **: 15:51:45.744: Couldn't register with accessibility bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken. (remote-viewer:13539): GLib-GIO-CRITICAL **: 15:51:45.765: g_dbus_proxy_new_sync: assertion 'G_IS_DBUS_CONNECTION (connection)' failed
You just need to launch again the console as follows. To start the VM we run lxc start
but to re-attach to the running VM (since it was restarted by itself), we run lxc console
.
lxc console win10 --type=vga
It will take you two lxc console
s until you get to the Windows desktop.

Notes
- When installing Windows, you will be prompted to use your personal information. If this is an expendable virtual machine, you can get away with creating a new
outlook.com
account and adding some telephone number (it does not verify the telephone number). You will be prompted for a PIN as well, and it will be asking for that PIN when you use this installation. - To shutdown the VM, click to Shutdown from the Windows desktop. To start it again at a later time, run the following (as we did before).
lxc start win10 --console=vga
- When the VM is stopped, you may remove the Windows 10 ISO with the following.
iso
was the name of the ISO device we setup earlier.lxc config device remove win10 iso
- This VM setup does not have sound.
It is probably easy to add that using a QEMU option. There are no virtio drivers yet for a virtualized audio card. But it is not an issue if you go for Audio Passthrough, using a tool like Remmina. For this to work, you need to enable Remote Desktop in Windows, and also should have installed Windows Professional (instead of Windows Home). - By default, the VM gets a private IP address, one from the
lxdbr0
network range. I could not get toping
that IP address from the host or from a container.It is likely a VM issue. But of couse, the VM has networking. edit It is a Windows Firewall issue. You can enable an inbound IPv4 ICMP rule, such as the following. We selected to enable some existing rule instead of composing it from scratch.

Summary
We have seen how to get to run Windows 10 on a LXD virtual machine. At the moment, these are the easiest instructions. Once more features are added, I’ll update this page.
7 comments
Skip to comment form
Hi Simos;
Thanks for everyting about LXC/LXD. I wrote samething on container discuss. If anyone want to use only copy/paste…
snap install distrobuilder --classic --edge
apt install -y libguestfs-tools wimtools
distrobuilder repack-windows /home/muslu/win10.iso /home/muslu/win10_distrobuilder.iso
lxc init win10 --empty --vm -c security.secureboot=false
lxc config device override win10 root size=50GiB
lxc config device add win10 iso disk source=/home/muslu/win10_distrobuilder.iso boot.priority=10
lxc start win10 --console=vga
Note: remmina (for slice) or virt-viewer can connect vga.
apt install -yqq remmina-plugin-spice virt-viewer
Author
Thanks Muslu!
I notice that you install
distrobuilder
from theedge
channel. However, since recently, thestable
channel has been updated and there is no need any more to use theedge
channel. Have a look.I notice that you install
libguestfs-tools wimtools
. What is the significance of these tools?How do you connect to the Windows VM through SPICE (with remmina)?
For me distrobuilder does not recognize command repack-windows. I’ve installed it via snap as is show in this tutorial.
“Error: unknown command “repack-windows” for “distrobuilder”
“$ distrobuilder –version
1.1”
Author
The Windows support in
distrobuilder
has been added recently, which means that the package should be recent enough.Here is the version I have installed,
I tried to repack the ISO, and I got as well
Ok, this is embarrassing and thanks for reporting. Above it show that I have installed
distrobuilder
from thestable
, published on the 20th of January 2021. But that is not recent enough. We need to refresh ourdistrobuilder
so that it comes from theedge
channel for now. Once the version from thestable
channel gets updated, we can switch back to thestable
channel.Here is how to switch from the stable channel to the edge channel.
I am updating the post as well on this.
Thanks for reporting!
Thanks. 🙂
I’ve got error:
“Error: Required tool “hivexregedit” is missing”
After fast google solution seems to be:
sudo apt-get install libguestfs-tools
Author
Thanks for this. Apparently, my test system is not vanilla any more 🙁 and I have to reinstall.
I’ll update accordingly.