Recently I had an assignment that asked us to use Qemu. It took me some trouble to get it running on Windows so I thought I could document it here in case I need it in the future. It would be nice if this helps someone, too!
- Download Qemu and .iso
- Add Qemu path to environment variables settings
- Create an image
- Starting the VM
- Some problems you might encounter
Click here to download Qemu and download your desired .iso file. After installing Qemu, open Windows Powershell and type
qemu-img. Now you might see that it does not recognize the command. This takes us to number 2.
Copy the Qemu path (should be
C:\Program Files\qemu if you didn't change anything) and open environment variables settings by
Right click on "This PC" -> Properties -> Advanced system settings -> Environment Variables.
path once and click "Edit...". Click "New" and paste the Qemu path.
Here's the youtube video that taught me how to do this. Otherwise, I'd stuck here forever :P.
Now you can create an image by typing
qemu-img create -f qcow2 [name].qcow2 30G.
When starting the VM, you would want to use an accelerator, or else it is going to take a lot of time installing the OS. It took me more than an hour to install Ubuntu 16.04 without the accelerator.
For Windows, there are two options: HAXM and whpx. Note that HAXM can only be used on Windows Enterprise/Pro/Education so I'm not going to introduce it here. Although I did get it working for whatever reason and after a Windows update, it just stopped working.🤔
Windows Features and tick
Windows Hypervisor Platform. After that, restart the computer and type this command in the powershell (in the directory where the image and .iso resides):
qemu-system-x86_64 -accel whpx -hda .\[name].qcow2 -m 512 -net nic,model=virtio -net user -cdrom .\[name].iso -vga std -boot strict=on. It should start up and you can proceed to install the OS.
The second time you start up the machine you don't need to type
-cdrom anymore. Just
qemu-system-x86_64 -accel whpx -hda .\[name].qcow2 -m 512 -net nic,model=virtio -net user -vga std -boot strict=on should do it.
You might get stuck when rebooting after installing the OS
My friend and I both encountered the problem and we both used Ubuntu 16.04 for the VM. Just close the window and restart it and it should work fine. Pretty sure this is not best practice, though.
You can't seem to do migration using whpx
I got this error when trying to do migration. I found this Github code and I think it has something to do with whpx. I'm not sure how to resolve this. My TA simply allowed me to do migration on the server.
Windows Hypervisor Platformwhen using VirtualBox You might get an error from VirtualBox when starting the machine if you keep it ticked. Remember to untick it.