I finally went through the hassle of getting my WD drivers updated. The basic idea is I have a USB stick and want to get a working copy of windows on it just long enough to run the firmware update. Windows doesn’t like to install to USB’s, so we install to a VM first, and then boot straight off the vm disk image.
Here’s how I did it:
Prerequisites
- Have a USB stick with at least ~30GB, with decent speeds. After suffering decades of mediocre USB sticks, I purchased the Kingston Datatraveler-max and could not be happier with ~1gb/s ops
- Download the ventoy binary (or install it with yay -S ventoy-bin)
- Download ventoy_vhdboot.zip
- Install qemu (
pacman -S qemu
) - Download the Windows 10 ISO
- Download the 64 bit wifi drivers (make sure you don’t get the 32 bit ones by accident)
- Download the WD Dashboard exe to be used within the VM
Set up Ventoy
Warning: This erases your entire USB disk
Warning: If you choose the wrong disk you’ll erase things you don’t intend to erase
Plug in your USB stick and figure out what the device name is. You can use your OS’s partition manager GUI, or look at the output of lsblk
. My USB is at /dev/sda
but it’ll depend on your OS.
Then, we need to install Ventoy and leave enough room for the VM. Normally, Ventoy makes two partitions - an exfat partition where you can put your ISO images, and a second partition where it installs the boot magic. For this to work, we need a third partition that’s NTFS formatted for the image to boot from.
The command to run is
sudo ventoy -I /dev/YOUR_PATH_HERE -r NUMBER_OF_MB_FOR_VM
For example, on my machine, I ran:
sudo ventoy -I /dev/sda -r 50000
Which installed ventoy with 3 partitions: The normal ventoy partition, the hidden 30mb ventoy partition, and 50gb of unallocated space at the end.
You can pick whatever number you want but it needs to be bigger than the max size of the .vhd you create for Windows. By max size I mean that the .vhd dynamically grows, but even if it’s say 10Gb but you created it with a max size of 40gb, then this partition has to be > 50gb. Otherwise windows won’t boot.
There’s an optional step below to reduce the install size so this will fit on a smaller footprint (< 30 gb). If you don’t want to worry about it, just make it 40gb and it’ll work without any issues.
Now, you need to allocate the 50gb partition to be NTFS formatted. I suggest doing this in your distro’s partition manager gui otherwise search around for the CLI commands.
I’ve labeled this partition as VentoyWin, and will reference it as such in the rest of the tutorial.
Now we need to mount the Ventoy
partition and the VentoyWin
partitions in our newly initialized USB drive. Refer to your distro for how to do this, or you can use sudo mount
to do so manually.
Then, create a new folder called ventoy
Unzip the ventoy_vhdboot.zip file you downloaded, and locate the .img file (ventoy_vhtboot.img)
Copy the ventoy_vhdboot.img
into this folder.
Make a new text file named ventoy_grub.cfg and also place it in the ventoy folder, with these contents:
menuentry "Boot My Windows VHD" {
set my_vhd_path="/windows10.vhdx"
if search -n -s vdiskhd -f "$my_vhd_path"; then
vhdboot_common_func "($vdiskhd)$my_vhd_path"
else
echo "$my_vhd_path not found"
fi
}
For example, if your USB drive is mounted to /mnt/usb/Ventoy, then you should now have the two following files:
/mnt/usb/Ventoy/ventoy/ventoy_vhdboot.img and /mnt/usb/Ventoy/ventoy/ventoy_grub.cfg
Finally, copy over the intel wifi drivers, and the wd dashboard.exe to the VentoyWin partition. That way you can use them later.
Create a windows vm
First, create the disk. This file eventually needs to live at /mnt/usb/VentoyWin/windows10.vhdx (or wherever you’re going to mount that ntfs partition)
I suggest keeping the im
You can put it there now, or keep it on your local FS and then copy it later to make things install a bit faster.
Either way, the command is this: qemu-img create -f vhdx YOUR_FILENAME_HERE 40G
For example: qemu-img create -f vhdx windows10.vhdx 40G
Now, we can launch Windows using the VM we downloaded earlier. The command to use is:
qemu-system-x86_64 -cdrom PATH_TO_YOUR_windows10.iso -boot order=d -drive file=PATH_TO_YOUR_windows10.vhdx,format=vhdx -m 2G -smp 8 -cpu host,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time -enable-kvm -nic none
The arguments come from here, and here
Now we can go through the install phase.
First it will ask for a product key. Click the “I don’t have a product key”
(Tip using the keyboard for these steps (tab/space/enter) is much faster)
Then, choose Windows 10 Pro. The reason is we’re going to use group policy to nuke windows updates so we don’t pull in unwanted drivers later. Accept the license, then click “Custom: Install Windows only”. You don’t need to manually partition the 40g drive, just hit next.
Now it’ll take some time, and then reboot into OOBE.
For OOBE, it’s gotten more annoying since the last time I used windows. Now it won’t let you make a local account, unless there’s no internet access. This is why we’re running with -nic none
When it says let’s connect you to a network, choose “I don’t have internet” at the bottom. Then it tries to whine more, so you have to click “Continue with limited setup” at the bottom left again.
Continue and set your username/password. There’s no complexity requirements so my password is wd
for everything including the security questions.
Now go and uncheck every privacy-stealing-by-default checkbox. No we don’t want cortana…
And now we’ve created the VM!
Optional: Disabling windows updates
You don’t have to do this of course, but tl;dr: adding the fingerprint driver to windows messes up things nice and solidly for our linux installs so I’d just rather be safe and have windows never try to update.
Follow these instructions to use group policy to disable driver updates:
Automatic driver updates can cause problems — here’s how to turn them off
In this guide, we’ll show you the steps to disable updates for drivers through Windows Update using Group Policy and Registry.
and I’ve found in the past that sometimes even that isn’t enough. So later, we’ll set our wifi connection to be metered to stop any downloading as well
Optional: Reduce the size of the image
(From @Fadalf)
If your USB disk is < 40 gb, or you just want to save as much space as possible, here’s how you can shrink your VM size down:
- Remove Windows recovery partition with diskpart (link)
**diskpart** > **list disk** > **select disk #** > **list partition** > **select partition #** > **delete partition override**
- Resize Windows partition to < 25GB using disk manager
- Now, turn off your VM and do these remaining steps in your linux environment
- Convert the VM to raw :
qemu-img convert -O raw windows10.vhdx raw_win10.raw
- Shrink the VM to 25 GB :
qemu-img resize --shrinked raw_win10.raw 25G
- Convert it back to vhd(x) :
qemu-img convert -f raw raw_win10.raw -O vhdx windows10.vhdx
Time to boot off the USB
Copy your windows10.vhdx
into the root of your VentoyWin partition. (It needs to be named windows10.vhdx to match the boot entry you made in ventoy_grub.cfg earlier).
Now, we’re almost all ready to go. Make sure you’ve copied over the intel drivers and the Dashboard.
Now, turn off your computer. If you’ve enabled secure boot, you’ll need to go to your settings (f10) and turn it off temporarily. Otherwise, hit f12 and boot from the usb.
It should pop open the ventoy screen. Now you need to hit f6 to load the additional menu. Now, you should see “Boot my Windows VHD” from the grub config earlier. Select it and boot.
If it works, you can install the wifi drivers and the WD dashboard program. Connect to the internet, hit that sweet update firmware button. Then, when finished, just reboot back into linux and re-enable secure boot.