Boot MacOS under VirtualBox
Introduction
The following steps are needed to boot Mac OS under VirtualBox. I tested it using Mac OS X 10.13. I can't guarantee this works. You'll need a source/original mac to copy the OS install. Probably Apple won't approve of this because they want you to buy their original hardware, but sometimes you need hosted VMs in the cloud or similar, and they don't really offer that.
Steps
Commands below are typed in a command line like the Terminal.
1. On a Mac, do this to download an installer disk:
softwareupdate --fetch-full-installer --full-installer-version
... OR download from the app store.
If the operating system you want to install is out of date, ie if the Mac tells you the installer is damaged, set your Mac date and time to however many years ago that operating system came out, and turn of automatic date and time in the date and time system preferences. That way the signature of the installer disk / bundle will still be valid (it is invalid if it is older than a certain date).
2. Run the following commands:
Obviously things like X, Y, are names of disks, folders, or volume (drive) sizes.
This step is to create an ISO disk image of a Mac OS installer disk.
hdiutil create -o /tmp/[X] -size [Y]m -volname [X] -layout SPUD -fs HFS+J
hdiutil attach /tmp/[X].dmg -noverify -mountpoint /Volumes/[X]
sudo /Applications/Install\ macOS\ [X].app/Contents/Resources/createinstallmedia --volume /Volumes/[X] --nointeraction
hdiutil detach /Volumes/[X]
hdiutil convert /tmp/[X].dmg -format UDTO -o ~/Desktop/[X].cdr
mv ~/Desktop/[X].cdr ~/Desktop/[X].iso
Commands courtesy of:
3. Now, on your Windows / Linux machine:
cd "C:\Program Files\Oracle\VirtualBox\"
or on Linux, probably
cd /usr/local/bin/VirtualBox/
4. Create a virtual machine in VirtualBox and aim its drive at the ISO file you made in step 2. Note the name of the VirtualBox. For our purposes, we'll call it <VM_Name>.
5. Type in the command prompt (Bash) or command line on Windows (CMD):
VBoxManage modifyvm "<VM_Name>" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage modifyvm "<VM_Name>" --cpu-profile "Intel Core i7-6700K"
VBoxManage setextradata "<VM_Name>" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac19,1"
VBoxManage setextradata "<VM_Name>" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "<VM_Name>" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Mac-AA95B1DDAB278B95"
VBoxManage setextradata "<VM_Name>" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "<VM_Name>" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
VBoxManage setextradata "<VM_Name>" "VBoxInternal/TM/TSCMode" "RealTSCOffset"
// use this if the display is stuck at 1024x768
VBoxManage setextradata "<VM_Name>" VBoxInternal2/EfiGraphicsResolution 1920x1080
VBoxManage setextradata "<VM_Name>" GUI/ScaleFactor 1
// Scale factors are 1 = 100%, 1.25 = 125%, etc