Disclaimer
This instruction is only care how to install MacOS on WSL2, but not whether you have right permission to install MacOS on your device or not. (EULA)
Steps
- prerequirements
- Setting WSL2
- Enable KVM
- set QEMU VM
- create macOS-Simple-KVM on QEMU
- Launch
prerequirements
- KVM supporting Intel CPU.
- Device to install MacOS (that does not conflict with EULA)
Setting WSL2
- First of all you need to check your Windows 10 version is greater than 2004 (means it was released at April 2020 in general). If you are not, then you update your Windows and come back here.
- Then You can enable Windows Subsystem Linux at
Control
-Apps
-Programs and Features
-Turn Windows features on or off
. - I have not enough idea that you will need Hyper-V feature for this work, but if you can, please enable Hyper-V and virtualization feature.
- Then go to Microsoft Store. Install
Ubuntu
. (If you don’t want to use Ubuntu, then you can try any other linux. maybe.. :) ) - Sure you should set your Linux. Just follow instruction by starting
Ubuntu
app. At this moment you have the WSL but not WSL2. - After all, upgrade WSL to version 2. This official instruction is kind and easy enough. https://docs.microsoft.com/en-us/windows/wsl/install-win10
PS C:\WINDOWS\system32> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
# you may need to restart!
PS C:\WINDOWS\system32> wsl --list --verbose
NAME STATE VERSION
* Ubuntu Running 2
PS C:\WINDOWS\system32> wsl --set-version Ubuntu 2
변환이 진행 중입니다. 몇 분 정도 걸릴 수 있습니다...
WSL 2와의 주요 차이점에 대한 자세한 내용은 https://aka.ms/wsl2를 참조하세요
Congrats, you have WSL2 now! but it is just first step.
Enable KVM
- You may think it was dizzy work to set WSL2, but it is absolutely clear than this step. So, take a deep breath before start.
- First you should get WSL2 Kernel codes. It is preferred to have code of released version. (I am using 4.19.104) https://github.com/microsoft/WSL2-Linux-Kernel
- Before clone or unzip the code, you may need to set
per-directory case sensitivity
. Its quite hassle but if you skip this, you will fail to build after all!PS C:\Windows\system32> fsutil.exe file SetCaseSensitiveInfo C:\some\path\you\use enable
- Then extract( or clone) code somewhere you set case-sensitive.
- Following below instruction. It cames from Accelerated KVM guests on WSL 2 ```bash $ sudo apt update && sudo apt -y upgrade $ sudo apt -y install build-essential libncurses-dev bison flex libssl-dev libelf-dev cpu-checker qemu-kvm aria2
$ tar -xf WSL2-Linux-Kernel-4.19.104-microsoft-standard.tar.gz $ cd WSL2-Linux-Kernel-4.19.104-microsoft-standard/
$ cp Microsoft/config-wsl .config $ make menuconfig
Because he captured many screenshots about this, it is better to follow original blog's instruction in this stage.
6. should check `.config` after setting, you should have followings.
```bash
KVM_GUEST=y
CONFIG_KVM=y
CONFIG_KVM_INTEL=m
CONFIG_VHOST_NET=y
CONFIG_VHOST=y
- Let’s build! It takes an hour.
make -j 8
- After-build setting:
$ sudo make modules_install $ cp arch/x86/boot/bzImage /mnt/c/somewhere/windows/can/access
- Are you done? then make a
.wslconfig
on your windows user home directory (C:\Users\<username>
). Below is assuming your build image was copied to user home directory.[wsl2] nestedVirtualization=true kernel=C:\\Users\\<username>\\bzImage
- Let’s get back to PowerShell(administrator).
PS C:\WINDOWS\system32> wsl --shutdown Ubuntu PS C:\WINDOWS\system32> wsl -d Ubuntu
- You should check your Kernel(and CPU) support KVM in linux shell, after that.
$ uname -ar Linux DESKTOP-E5KKPEB 4.19.104-microsoft-standard #1 SMP Sat Jun 20 14:08:58 KST 2020 x86_64 x86_64 x86_64 GNU/Linux $ egrep -c "(svm|vmx)" /proc/cpuinfo 8
- If you cannot get some positive number after last line, then you are a unfortunate guy! (I did. haha)
- If you are not, you can go to next step. Otherwise follow below steps.
- You need
WinDbg Preview
in Microsoft store. - Get script from here: https://gist.github.com/steffengy/62a0b5baa124830a4b0fe4334ccc2606 (Thank you Steffengy!)
get
run-wsl.bat
andscript.js
at same directory. - If you launch
run-wsl.bat
: then you will see WinDbg window and the WSL terminal after few seconds. now you can try below again!$ uname -ar Linux DESKTOP-E5KKPEB 4.19.104-microsoft-standard #1 SMP Sat Jun 20 14:08:58 KST 2020 x86_64 x86_64 x86_64 GNU/Linux $ egrep -c "(svm|vmx)" /proc/cpuinfo 8
set QEMU VM
- You are using Windows as host, thus you may need to install X server on your Windows.
- I installed vcXsrv by following this instruction. https://blog.nadekon.net/115(Korean)
- It is preferred to add below line in your
.bashrc
.VETHER_IP=$(/usr/bin/grep nameserver /etc/resolv.conf 2> /dev/null | /usr/bin/tr -s ' ' | /usr/bin/cut -d' ' -f2) export DISPLAY=$VETHER_IP:0.0
- We will use KVM, thus should import KVM modules every running. Adding belows to
.bashrc
are preferred.sudo modprobe kvm_intel sudo chmod 666 /dev/kvm
- Simply check setting is okay:
$ kvm-ok INFO: /dev/kvm exists KVM acceleration can be used(svm|vmx)
create macOS-Simple-KVM on QEMU
- this steps are from https://computingforgeeks.com/how-to-run-macos-on-kvm-qemu/ . some are changed but note reference.
- Let’s install requirements and code.
$ sudo apt -y install qemu-kvm libvirt-daemon qemu-system qemu-utils python3 python3-pip bridge-utils virtinst libvirt-daemon-system virt-manager $ git clone https://github.com/foxlet/macOS-Simple-KVM.git
- Get install disk from server.
$ cd macOS-Simple-KVM $ ./jumpstart.sh --catalina
- make disk image.
$ qemu-img create -f qcow2 macOS.qcow2 60G # you may need enough disk size for some Applications like Xcode.
- add below disk options to
./basic.sh
.-drive id=SystemDisk,if=none,file=macOS.qcow2 \ -device ide-hd,bus=sata.4,drive=SystemDisk \
- You will need to format disk, install macOS from internet, and setting your preferences with ‘Clover’. Details are described at the origin instruction.
launch
- when you run
.basic.sh
, you will see a window is opening via vcXsrv! - you may take 2 or more hours to install Catallina on your VM, after that, you are free to use MacOS VM.
- Memory and Display settings might be uncomfortable, but you can find options easily from internet: keyword is
QEMU mem/vga setting
.
References
- https://docs.microsoft.com/en-us/windows/wsl/install-win10
- https://github.com/microsoft/WSL2-Linux-Kernel
- https://boxofcables.dev/accelerated-kvm-guests-on-wsl-2/
- https://gist.github.com/steffengy/62a0b5baa124830a4b0fe4334ccc2606
- https://blog.nadekon.net/115
- https://computingforgeeks.com/how-to-run-macos-on-kvm-qemu/
- https://wiki.gentoo.org/wiki/QEMU/Options