jeremyd2019 / winautoconfig

automatic config for a Windows VM in QEMU, for ARM64 and AMD64
14 stars 0 forks source link

Creating A Windows 11 LXD VM Image #1

Open the-wondersmith opened 2 years ago

the-wondersmith commented 2 years ago

I've built a three-node LXD cluster using Raspberry Pi 4's and have been trying to get the win11 arm64 preview image spun up in an LXD VM for the last week or so. So far I've been able to run all of the linux distros I've tried, and I didn't have any issues using Botspot's WoR-flasher to create an install medium and get the win11 preview up and running on bare metal.

tl;dr I know it's possible, it's just a matter of fiddling at this point. I suspect that the issue is some difference or otherwise obscure silliness between the way that the "actual" RPi EFI firmware loads up on bare metal versus the way the edk2 firmware loads up in qemu (which lxd uses under the hood for vms).

Is there any way you could point me in the right direction, or perhaps clue me in to what I'm missing? Is your winautoconfig project what I need in order to get the LXD VM booting properly?

jeremyd2019 commented 2 years ago

Probably not, this "project" is mostly just a place for me to stash what I'm doing with automating setting up a windows vm. But, it may have some helpful hints for you.

https://github.com/jeremyd2019/winautoconfig/wiki/Windows-ARM64-VMs-with-QEMU may be helpful. Basically, I've found you need a moderately up-to-date qemu, but a newer OVMF firmware. Also, one of the things some of these scripts do is inject the virtio drivers into the Windows image before it boots for the first time (the WoR stuff does the same with RPi hardware drivers, but you don't need those you need the virtio drivers).

If you don't have virtio drivers, the only virtual storage you can reasonably boot from is nvme. You can use usb-storage sometimes, but it's flaky, and likes to drop out, so I haven't had good success installing from an ISO. You'd have better luck using DISM or wimapply to deploy Windows, use DISM to add the virtio drivers, and then boot that Windows image.

jeremyd2019 commented 2 years ago

The DISM command to install the drivers: https://github.com/jeremyd2019/winautoconfig/blob/53f8806a95b73894f56a7afde9205f3d7c41491e/deploy.cmd#L4

I documented how I got the drivers in https://github.com/jeremyd2019/winautoconfig/blob/master/dist/Out-of-Box%20Drivers/arm64/README

the-wondersmith commented 2 years ago

Thank you for all of that! I did read the wiki before I opened the issue, it's just such an out-of-the-way topic that I wasn't sure how to phrase it or describe what I was getting at.

I assume that anything involving DISM is going to require a functional Windows instance to start with? My "ideal" outcome I'm shooting for is figuring out how to make a Windows 11 LXD VM as easy to spin up as any other Linux-based VM would be (i.e. something like lxc init images:windows/11 arm64 --vm).

I know there are tools like hivexregedit and wimtools. I also that distrobuilder now ships with a built-in command called repack-windows, but I don't know if they're as... reliable (?) as DISM or if something else is going on I just haven't thought of. I'm still working my way through figuring out what's causing the VM's created using the "official" distrobuilder method to refuse to boot, so I can't say for certain it doesn't work on RPi hardware at the moment, I can only say that I personally haven't been able to get it to work on my RPi hardware.

If it's in anyway helpful (or just for context) all three nodes in my LXD cluster are identical 8GB units running the latest 64-bit Ubuntu Server 21.10 image. No crazy mods or custom packages or anything.

jeremyd2019 commented 2 years ago

Thank you for all of that! I did read the wiki before I opened the issue, it's just such an out-of-the-way topic that I wasn't sure how to phrase it or describe what I was getting at.

I assume that anything involving DISM is going to require a functional Windows instance to start with?

Yes. I don't know of a way to do the more complicated things like adding drivers with existing open-source tools. You can use wimapply to "install" the wim though.

My "ideal" outcome I'm shooting for is figuring out how to make a Windows 11 LXD VM as easy to spin up as any other Linux-based VM would be (i.e. something like lxc init images:windows/11 arm64 --vm).

You could use a 'normal' x86/x64 Windows install, or x86 WinPE (stupid Microsoft only supports dealing with "foreign" arch images from 32-bit, even though they don't support 32-bit anymore in Win11, and WinPE doesn't include WoW) to inject drivers into a wim, and then use wimapply on linux to extract it into a VM, which is probably what is going on under the hood there with distrobuilder.