Skip to content

Instantly share code, notes, and snippets.

@andriytk
Last active April 26, 2021 16:31
Show Gist options
  • Save andriytk/b807310e06cee7d47e75d505a7730bc3 to your computer and use it in GitHub Desktop.
Save andriytk/b807310e06cee7d47e75d505a7730bc3 to your computer and use it in GitHub Desktop.
How to run Linux (or some other) VM on Windows in QEMU in nearly-native host speed?

How to run Linux (or some other) VM on Windows in QEMU in nearly-native host speed?

Easy. Hare are a few tips:

  1. Install Intel HAXM for acceleration as described here - https://www.qemu.org/2017/11/22/haxm-usage-windows/

    Note: you will need to reboot your PC after this. Again: reboot (not shutdown and start) to avoid Windows quick-start which skips some initialisations.

  2. Install QEMU from https://qemu.weilnetz.de/w64/ (I used 5.2 version.) And add it to your Path.

  3. [optional?] Convert your vmdk disk to native QEMU format qcow2:

    qemu-img.exe convert disk1.vmdk -O qcow2 -c disk1.qcow2 -p
    

    Note: QEMU can work with vmdk format directly, so you can try it and skip this step if it works for you. But if you see some disk-related issues (for example, like this one) - better to convert it.

    Tip: I find it convenient to run all commands in git-bash on Windows.

  4. Start your vm in QEMU (for example, with 4 CPUs and 4GB RAM configuration):

    qemu-system-x86_64.exe -accel hax -smp 4 -m 4G disk1.qcow2
    

    Note1: if you see errors like “could not load PC BIOS” you might need to specify the path to qemu directory with -L option:

    qemu-system-x86_64.exe -L /c/Program\ Files/qemu -accel hax -smp 4 -m 4G disk1.qcow2
    

    Note2: I find it convenient to work with the vm via ssh, so I start it with the port forwarding option -nic hostfwd:

    qemu-system-x86_64.exe -L /c/Program\ Files/qemu -accel hax -smp 4 -m 4G disk1.qcow2 -nic hostfwd=tcp:127.0.0.1:22222-:22 &
    

    Now you can ssh to your vm from the same git-bash terminal:

    ssh -p 22222 <user>@127.0.0.1
    

Have fun!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment