OSX-KVM: Difference between revisions

From NixOS Wiki
imported>Onny
(Page cleanup and easier setup approach)
imported>Onny
mNo edit summary
Line 36: Line 36:


<syntaxHighlight lang=bash>
<syntaxHighlight lang=bash>
git clone https://github.com/onny/OSX-KVM.git
git clone -b flake https://github.com/onny/OSX-KVM.git
cd OSX-KVM
cd OSX-KVM
git checkout flake
nix run
nix run
</syntaxHighlight>
</syntaxHighlight>

Revision as of 18:54, 6 January 2023

OSX-KVM allows to run macOS on Linux machines.

Installation

Enable virtualisation support in your system configuration by adding following lines

{
  virtualisation.libvirtd.enable = true;
  users.extraUsers.youruser.extraGroups = [ "libvirtd" ];

  boot.extraModprobeConfig = ''
    options kvm_intel nested=1
    options kvm_intel emulate_invalid_guest_state=0
    options kvm ignore_msrs=1
  '';
}

Replace youruser with the user name of your running system. After applying the configuration, reboot your system so the changes to the kernel modules can take effect.

Last but not least, configure a tap interface that will be used in macOS for networking:

 $ sudo ip tuntap add dev tap0 mode tap
 $ sudo ip link set tap0 up promisc on
 $ sudo ip link set dev virbr0 up
 $ sudo ip link set dev tap0 master virbr0

Usage

Note: This instruction uses a custom fork of OSX-KVM with Nix Flake support. Hopefully these changes will soon be merged to the upstream repository.

Git clone the project repository and run nix run to prepare and run your MacOS system

git clone -b flake https://github.com/onny/OSX-KVM.git
cd OSX-KVM
nix run

You may also want to adjust the cpu count/memory in ./OpenCore-Boot.sh if your systems resources allow it.

On the first run, from the boot menu, select disk utilities and erase / format the Qemu disk that will be used for installation. Then choose the installer from the boot menu. Select the previously created disk image as install target.

On the next boot you will a new boot entry containing the actual installation.

See also