After your second Mac/macOS install can see the disk you want to install a recovery partition onto (use either Disk Utility or diskutil list to check its presence), do this: Run this in a terminal after you have downloaded Sierra, or your OS, from the App Store.
Note
This README
documents the new method to install macOS. The older README
isavailable here.
This new method does not require an existing physical/virtual macOSinstallation. However, this new method
requires internet access during themacOS installation process. This limitation may be addressed in a futurecommit.
Note: All blobs and resources included in this repository are re-derivable (allinstructions are included!).
Note: Checkout ideas.md. This project can always use your help,time and attention.
Requirements
A modern Linux distribution. E.g. Ubuntu 18.04 LTS 64-bit.
QEMU > 2.11.1
A CPU with Intel VT-x / AMD SVM support is required
A CPU with SSE4.1 support is required for macOS Sierra
A CPU with AVX2 support is required for macOS Mojave
Note: Older AMD CPU(s) are known to be problematic. AMD FX-8350 works butPhenom II X3 720 does not. Ryzen processors work just fine.
Installation Preparation
KVM may need the following tweak on the host machine to work.
To make this change permanent, you may use the following command.
Install QEMU and other packages.
This step may need to be adapted for your Linux distribution.
Clone this repository on your QEMU system. Files from this repository areused in the following steps.
Fetch macOS installer.
You can choose your desired macOS version here. After executing this step,you should have the
BaseSystem.dmg
file in the current folder.Sample run:
Attention: Modern NVIDIA GPUs are supported on HighSierra but not on Mojave(yet).
Next, convert this file into a usable format.
Create a virtual HDD image where macOS will be installed. If you change thename of the disk image from
mac_hdd.img
to something else, the boot scriptswill need updating to point to the new image name.Setup quick networking by running the following commands.
Note: If
virbr0
network interface is not present on your system, it mayhave been deactivated. Try enabling it by using the following commands,Now you are ready to install macOS
🚀
Installation
CLI method (primary). Just run the
boot-macOS-NG.sh
script to start theinstallation proces.If you are new to installing macOS, see the older README forhelp.
For macOS Catalina, use
boot-macOS-Catalina.sh
script.GUI method (alternate - functional but needs further debugging work).
Edit
macOS-libvirt-NG.xml
file and change the various file paths (searchforCHANGEME
strings in that file). The following command should do thetrick usually.Create a VM by running the following command.
Launch
virt-manager
, start themacOS
virtual machine and install macOSas usual.Note: You may need to run
sudo ip link delete tap0
command beforevirt-manager
is able to start themacOS
VM.Note: You may need to remove the following block from
macOS-libvirt-NG.xml
and runvirsh --connect ...
again. Alternate easier fix: RemoveSATA Disk 3
from the macOS virtual machine invirt-manager
.
Post-Installation
See networking notes to setup guest networking.
I have the following commands present in
/etc/rc.local
.This has been enough for me so far.
To get sound on your virtual Mac, see the 'Virtual Sound Device' in notes.
To passthrough GPUs and other devices, see these notes.
Need a different resolution? Check out the notes included in thisrepository.
Is This Legal?
The 'secret' Apple OSK string is widely available on the Internet. It is also included in a public court document available here. I am not a lawyer but it seems that Apple's attempt(s) to get the OSK string treated as a trade secret did not work out. Due to these reasons, the OSK string is freely included in this repository.
Gabriel Somlo also has some thoughts on the legal aspects involved in running macOS under QEMU/KVM.
Motivation
My aim is to enable macOS based builds + testing, kernel debugging, reversingand security tasks in an easy, reproducible manner without needing to invest inApple's closed ecosystem (too heavily).
Backstory: I was a (poor) student in Canada once and Apple made my work oncracking Apple Keychains a lotharder than it needed to be.
References
OS X's Disk Utility has a hidden Debug menu that, when enabled, can give you access to a few more Disk Utility features than you normally see. While Disk Utility has had a Debug menu for quite a while, it became even more useful with the advent of OS X Lion.
With OS X Lion, Apple added a Recovery HD partition on the startup drive that you can use to boot from and run utilities such as Disk Utility, reinstall OS X, and even access the internet to find solutions to problems you may be having. The Recovery HD partition is hidden, however, and isn't visible from within Disk Utility.
This can lead to a number of issues, including the possibility, over time, of having multiple Recovery HD partitions on various drives as you duplicate drives, replace drives, or re-install OS X. It can also prevent you from moving the Recovery HD partition to a new drive, should you ever need to replace a drive or just want to move things around on your drives.
Debug Menu Items
Disk Utilities Debug menu has quite a selection of capabilities, though most are designed for developers to use in testing apps that may work with the Mac's storage system. Most items are benign, such as List All Disks, or List All Disks with Properties. There is also control of how a progress bar is displayed, whether to turn on a Thousand Minute Countdown. The countdown just changes the Console logs for Disk Utility to show 60,000 seconds or one thousand minutes. The purpose is just to have a finer grain display of when log events occur. Once again this is really just for those developing storage products for the Mac.
More interesting for the average Mac user are two commands in the Debug menu:
- Force update of disk list — As the name implies, this will cause Disk Utility to update the disks listed in the sidebar. This can be useful when you have attached or removed a disk while Disk Utility is open.
- Show every partition — Aas its name implies, will display all partitions on a Mac's drive even if they are meant to be hidden.
It's understandable why Apple wants to hide some of the Recovery HD partitions. For instance, when you format a drive, the process creates a small 200 MB partition that the EFI bios needs for booting. These small EFI partitions don't contain any data that end users need, and there's no reason for them to be visible. But if you would like to be able to access the OS X Lion and later's Recovery HD partition to create clones or backups, enabling the Debug menu in Disk Utility is the easiest way to see and work with these invisible partitions.
Debug for OS X Yosemite and Earlier
With the release of OS X El Capitan, Apple finally decided to remove support for Disk Utilities hidden debug menu. This means the Terminal commands outlined below will only work for versions of OS X Yosemite and earlier.
Enable the Debug Menu in Disk Utility
Quit Disk Utility if it is open.
Launch Terminal, located at /Applications/Utilities.
Enter the following command at the Terminal prompt:
Debugging Tool For Mac Sierra Terminal Commands
The next time you launch Disk Utility, the Debug menu will be available.
If you wish to turn the Debug menu off again, perform the following steps.
Disable the Debug Menu in Disk Utility
Quit Disk Utility if it is open.
Launch Terminal, located at /Applications/Utilities.
Enter the following command at the Terminal prompt:
Adware Removal Tool For Mac
Don't forget that disabling Disk Utilities Debug menu does not reset the commands within the menu to their default state. If you have changed any of the settings, you may want to set them back to their original condition before disabling the Debug menu.
Use Terminal for OS X El Capitan and Later
Viewing hidden disk partitions can still be performed in OS X El Capitan or later, you just need to use the Terminal app instead of the Disk Utility app. To view a complete list of drive partitions do the following:
Launch Terminal, located at /Applications/Utilities.
In the Terminal window, enter the following at the command prompt:
Terminal will display all of the partitions currently connected to your Mac.
That's all there is to enabling or disabling the Disk Utility Debug menu. Go ahead and see what features are available under the Debug Menu, you will probably find the Show every partition item and the Force update of disk list item the most useful.