Disil's stuff

Make a Windows VM using KVM

Background

After exclusively using Debian for about 6 months, I have to say that this OS is great. However, I also got into trouble last week when me and my friend were making a scientific journal, and we were editing it in different programs. He used Office 2016, while I used LO 7.4. And as everyone expect, the formatting got messed up after a few revisions.

And that's where I realize that no matter the situation is, you still need backup. Office Online/Google Docs weren't good for most situation because it need constant internet connection. I need true MS Office. There were a few options that I could explore:

  1. Install Office on Wine. But after looking at Wine database, the best version supported is MS Office 2007, and they were silver-rated at best. And even then, the version is too old to be compatible with newer files.
  2. Install WPS Office. I've used it in the past, but I just couldn't trust my data with their shady permission (at least in Flatpak).
  3. Install Office on Windows VM.

So, I decided to went with the third option. This is the most difficult one, but the trade-off is worth it.

Preparing files for VM

Installing KVM

In this occasion I want to try to use KVM, a "near-native" (hardware based) hypervisor that is provided by Linux kernel. This is different from the likes of VMWare or Virtualbox, where they're based on software virtualization. Arch Linux wiki said that it's more fast and not that resource-hog, unlike that one virtualization program that has the name "Player" on it.

Installling KVM is easy. For your convenience, here's a command that will install all of the needed packages (assuming you're on debian):

sudo apt install qemu-utils qemu-kvm libvirt-daemon-system virtinst virt-manager

After that, open the Virtual Machine manager (virt-manager), and make sure to allow editing of xml files in the preferences.

Getting Windows ISO

This is easy. Just type "download windows 10 iso" on Google and you'll get it on MS site. But, yesterday I found a site where you can download Windows 11/10/8/7/Vista/XP iso and all versions of Office. Here's the website, it's called massgrave.dev.

Getting Drivers

Drivers are available in iso format. No other drivers is needed.

Installing Windows

In this case, I use the latest Windows 10. I don't use W11 because the system requirements are crazy, and my host barely met the requirement, let alone dividing the resources in VM.

Creating a new VM is really straight forward. Open virt-manager, and click on the computer icon. Then, select local install media. On the next screen, choose the Windows iso that you've downloaded. When you were prompted to choose how much memory & CPU you gonna dedicate to the VM, choose according to the minimum system requirement of the OS. For me, because I had little resources to began with, I've allocated 1.5 Gigs of RAM and 2 CPU cores. selecting windows iso When you are prompted to create disk image, set it according to your available hard disk space, but make sure it's more than 30 gigs. And, on the last screen, check the box beside "Customize configuration before install".

Now, you'll gonna see a complicated screen. Follow this steps:

  1. On that section, give the VM a name and a description.
  2. In memory section, and enable shared memory.
  3. In "SATA Disk 1" section, and change disk bus from SATA to VirtIO. If you have SSD, open the advanced options, and set the discard mode to "unset".
  4. In NIC section, change device model to virtio, and made sure link state is active.
  5. Press add hardware, change the device type to CDROM, and put the driver iso (virtio-win) in there. When done, press finish.
  6. In overview section, go into XML tab at the top of the screen. Find this:
<clock offset="localtime">
    <timer name="rtc" tickpolicy="catchup"/>
    <timer name="pit" tickpolicy="delay"/>
    <timer name="hpet" present="no"/>
    <timer name="hypervclock" present="yes"/>
</clock>
  1. Delete the first two lines inside the clock tag, and change the value to yes in the "hpet" code, so it look like this:
<clock offset="localtime">
    <timer name="hpet" present="yes"/>
    <timer name="hypervclock" present="yes"/>
</clock>

What that does is it will reduce CPU usage about 15% when idling the VM. Anyway, click began installation on the far-left corner of the screen.

When it's time to do partitioning, Windows setup will probably says that they couldn't found drives. To continue, press load driver, and press OK. Then select appropriate driver (depending on OS version). choosing driver in Windows setup After that, proceed to install Windows like usual.

Installing drivers & activating Windows

Despite you've chosen a driver at Windows setup, you still need to install this Virtio driver. It will enhance performance of disk and make network connection active. To do so, open file explorer, and open the right drives. Open virtio-win-guest-tools.exe and just spam the next button. If the installation runs fine, you'll get network connection and the ability to resize the Windows VM. virtio guest tools setup It's always a good measure to restart the VM, just in case something didn't work as intended. Also, update the VM. And for activating it, well, you could buy a license.

Or see this secret way to activate it.Open Powershell, type irm https://massgrave.dev/get | iex and press enter. Follow the instructions provided.

Conclusion

And there you go! You have succesfully setup a Windows VM. Now, go download any software that you want. Thanks for reading this, and see ya!

#tutorial