You need a mac machine, mac laptop or pc to download and convert installer.
Download macOS
Visit link
https://support.apple.com/en-sg/HT211683
scroll down to bottom, you will see list of macOS version. select one on them will take you to appStore, click ‘Get’ will start downloading installer.
When downloading finished, you will see ‘Install macOS xxx.app’ under /Applications where xxx is name of macOS you selected just now.
Now open Terminal.app to convert installer to ISO file.
Convert installer to ISO
We take xxx as Mojava here. Replace it with your selection. and make sure
Create a disk image DMG file buy issuing the following command:
$> hdiutil create -o /Users/yourname/tmp/Mojave -size 1400m -volname Mojave -layout SPUD -fs HFS+J
Mount the created DMG disk image as follows:
$> hdiutil attach /Users/yourname/tmp/Mojave.dmg -noverify -mountpoint /Volumes/Mojave
Next we will use createinstallmedia to create the macOS installer application on the mounted volume:
$> sudo /Applications/Install\ macOS\ Mojave.app/Contents/Resources/createinstallmedia --volume /Volumes/Mojave --nointeraction
When createinstallmedia has finished, next you can unmount the volume you just created:
$> hdiutil detach /volumes/Install\ macOS\ Mojave
If above command failed with error:
hdiutil: couldn’t unmount “disk blabal” – Resource busy
Simply restart your mac.
Now we convert the DMG disk image file to an ISO disk image file (technically a CDR file but it’s the same as an iso)
$> hdiutil convert /Users/yourname/tmp/Mojave.dmg -format UDTO -o ~/Desktop/Mojave.cdr
Finally, we rename the CDR file extension to ISO to convert the CDR to ISO:
$> mv ~/Desktop/Mojave.cdr ~/Desktop/Mojave.iso
Install macOS to VirtualBox
Create VirtualMachine
Choose MacOS 64bit when create virtualmachine.
Then change settings:
Enable PAE/NX in System tab.
If install macOS Ventura, make sure ‘USB 3.0 controller’ is selected in USB tab of settings of vm. If not it will stuck on booting.
Then attach ISO file to storage and start virtual machine to install macOS.
There is nothing special for installation. After installtion, there are somes errros.
Error
After installation, got error
AppleKeyStore:10683:268: operation failed,
Power off virtual machine first. From host machine, let say, in Linux, run following command:
VBoxManage modifyvm "Virtual Machine Name" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata "Virtual Machine Name" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,7"
VBoxManage setextradata "Virtual Machine Name" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "Virtual Machine Name" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "Virtual Machine Name" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "TVirtual Machine Name" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
After this, power on the virtual machine. It should boot into system successfully.