OSX-KVM: Difference between revisions

From NixOS Wiki
imported>BenSchZA
m Add details about erase/formatting of Qemu disk
imported>Flokli
fix typo
Line 32: Line 32:
</syntaxHighlight>
</syntaxHighlight>


After using cloning the repository use <code>./fetch-macOS.py</code> as described in the README
After cloning the repository use <code>./fetch-macOS.py</code> as described in the README
to download macOS
to download macOS
Than do:
Then do:


<syntaxHighlight lang=console>
<syntaxHighlight lang=console>
Line 47: Line 47:
</syntaxHighlight>
</syntaxHighlight>


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


<syntaxHighlight lang=console>
<syntaxHighlight lang=console>
Line 62: Line 62:
</syntaxHighlight>
</syntaxHighlight>


You may also want to adjust the increase cpu count/memory in <code>./OpenCore-Boot.sh</code> if your systems resources allows it.
You may also want to adjust the cpu count/memory in <code>./OpenCore-Boot.sh</code> 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 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.
On the next boot you will a new boot entry containing the actual installation.

Revision as of 14:05, 9 October 2020

OSX-KVM allows to run macOS on Linux machines.

Use the following shell.nix to get all the tools required to boot OSX-KVM:

with import <nixpkgs> {};
mkShell {
  buildInputs = [
    qemu
    python3
    iproute2
  ];
}

On NixOS also add the following lines to your configuration.nix:

{
  # this is needed to get a bridge with DHCP enabled
  virtualisation.libvirtd.enable = true;
  # Replace <youruser> with your actual username.
  users.extraUsers.<youruser>.extraGroups = [ "libvirtd" ];

  # reboot your computer after adding those lines
  boot.extraModprobeConfig = ''
    options kvm_intel nested=1
    options kvm_intel emulate_invalid_guest_state=0
    options kvm ignore_msrs=1
  '';
}

After cloning the repository use ./fetch-macOS.py as described in the README to download macOS Then do:

$ qemu-img convert BaseSystem.dmg -O raw BaseSystem.img

to create the base image containing the macOS installer, followed by creating your actual disk image where later the macOS will be installed to:

$ qemu-img create -f qcow2 mac_hdd_ng.img 128G

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

Then boot the system with:

$ ./OpenCore-Boot.sh

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.