At first
Describes a script for building and destroying macOS Catalina virtual machines built using scripts.
The script you are using is published as vm-configure on github, so please download it from github or download it from here.
See the link below for the vm-configure folder configuration.
/host-osx/macOS-Catalena/vm-create.command
This is a script for building macOS Catalina virtual machines.
The location of the script file is in the current directory.
SCRIPT_DIR=$(dirname "$0")
cd "$SCRIPT_DIR"
We determine if there is an iso file in the script execution directory that will be the installation media for macOS Catalena, and if it does not exist, we are creating the iso file.
if [ ! -e "${SCRIPT_DIR}/Catalina.iso" ]; then
...
fi
If there is no macOS Catalena installer from which to create the iso file that will be the installer for macOS Catalena, download it from Apple with the softwareupdate command.
if [ ! -e "/Applications/Install macOS Catalina.app" ]; then
softwareupdate --fetch-full-installer --full-installer-version 10.15.6
fi
Creating 8G disk image for writing installer.
hdiutil create -o "${SCRIPT_DIR}/Catalina" -size 8G -layout SPUD -fs HFS+J -type SPARSE -volname Catalina
Mounting the disk image you created.
hdiutil attach "${SCRIPT_DIR}/Catalina.sparseimage" -noverify -mountpoint "/Volumes/Catalina"
Writing the installer to a disk image mounted using the createinstallmedia command included with the macOS Catalina installer.
sudo "/Applications/Install macOS Catalina.app/Contents/Resources/createinstallmedia" --volume "/Volumes/Catalina" --nointeraction
Detaching disk image.
hdiutil detach "/volumes/Install macOS Catalina"
Converting the disk image to an iso file that can be used by the virtual machine.
hdiutil convert "${SCRIPT_DIR}/Catalina.sparseimage" -format UDTO -o "${SCRIPT_DIR}/Catalina.cdr"
I’m changing the file extension and cdr to iso.
mv "${SCRIPT_DIR}/Catalina.cdr" "${SCRIPT_DIR}/Catalina.iso"
Deleting disk images that are no longer needed.
rm "${SCRIPT_DIR}/Catalina.sparseimage"
Defines the name of the macOS Catalina virtual machine on VirtualBox.
VM_NAME="macOS-Catalina"
The virtual VM_NAME virtual machine is defined on VirtualBox to determine if it does not exist, and if it does not exist, it is in the process of building the virtual machine.
if [ ! "`vboxmanage list vms | grep '"'"${VM_NAME}"'"'`" ]; then
...
fi
The virtual machine to be created in VirtualBox is set with the vboxmanage command.
See herefor the parameters that can be set.
vboxmanage createvm -name "${VM_NAME}" -register
VM_DIR=$(dirname "`vboxmanage showvminfo "${VM_NAME}" --machinereadable | grep -e "^CfgFile=" | sed -e 's/^CfgFile="//' -e 's/"$//'`")
vboxmanage createmedium disk -filename "${VM_DIR}/${VM_NAME}.vdi" -size 100000 --format vdi
vboxmanage storagectl "${VM_NAME}" --name "SATA" --add sata --controller IntelAhci
vboxmanage storageattach "${VM_NAME}" --storagectl "SATA" --port 0 --device 0 --type hdd --medium "${VM_DIR}/${VM_NAME}.vdi"
vboxmanage storageattach "${VM_NAME}" --storagectl "SATA" --port 1 --device 0 --type dvddrive --medium "${SCRIPT_DIR}/Catalina.iso"
vboxmanage modifyvm "${VM_NAME}" --ostype MacOS_64
vboxmanage modifyvm "${VM_NAME}" --acpi on
vboxmanage modifyvm "${VM_NAME}" --chipset piix3
vboxmanage modifyvm "${VM_NAME}" --mouse usbtablet
vboxmanage modifyvm "${VM_NAME}" --keyboard usb
vboxmanage modifyvm "${VM_NAME}" --firmware efi
vboxmanage modifyvm "${VM_NAME}" --rtcuseutc on
vboxmanage modifyvm "${VM_NAME}" --cpus 2
vboxmanage modifyvm "${VM_NAME}" --memory 4096
vboxmanage modifyvm "${VM_NAME}" --vram 128
vboxmanage modifyvm "${VM_NAME}" --audiocontroller hda
vboxmanage modifyvm "${VM_NAME}" --audioin on
vboxmanage modifyvm "${VM_NAME}" --audioout on
vboxmanage modifyvm "${VM_NAME}" --usbxhci on
vboxmanage modifyvm "${VM_NAME}" --nic1 nat
vboxmanage modifyvm "${VM_NAME}" --nictype1 virtio
vboxmanage modifyvm "${VM_NAME}" --clipboard bidirectional
vboxmanage modifyvm "${VM_NAME}" --draganddrop bidirectional
vboxmanage setextradata "${VM_NAME}" GUI/ScaleFactor 2.00
VBoxManage startvm "${VM_NAME}"
/host-osx/macOS-Catalena/vm-destroy.command
This is a script to destroy the macOS Catalina virtual machine.
The location of the script file is in the current directory.
SCRIPT_DIR=$(dirname "$0")
cd "$SCRIPT_DIR"
Defines the name of the macOS Catalina virtual machine on VirtualBox.
VM_NAME="macOS-Catalina"
If it is VM_NAME virtual machine is defined on the virtualBox to determine if it exists, and if so, it is performing a delete operation.
if [ "`vboxmanage list vms | grep '"'"${VM_NAME}"'"'`" ]; then
...
fi
VM_NAME is stopping the virtual machine defined in the list.
vboxmanage controlvm "${VM_NAME}" poweroff
VM_NAME destroying the virtual machine defined in the list.
vboxmanage unregistervm "${VM_NAME}" --delete
Comment