Skip to content

Instantly share code, notes, and snippets.

@leoherzog
Last active March 28, 2017 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leoherzog/bcf03a4c16bc51aefa86d0956801f13a to your computer and use it in GitHub Desktop.
Save leoherzog/bcf03a4c16bc51aefa86d0956801f13a to your computer and use it in GitHub Desktop.
Prepare Virtualbox VM to host guest MacOS
#!/bin/bash
read -p "Case-sensitive name of the VM: " vmname
if [[ -z $vmname ]]; then
echo "$(tput setaf 1)Please enter a valid VM Name$(tput sgr0)"
exit 1
fi
if [[ $vmname =~ \ |\' ]]; then
echo "$(tput setaf 3)Be warned, there have been reports that this may not work with VM Names that contain spaces$(tput sgr0)"
fi
echo "What resolution would you like the VM guest to be?"
echo "0 = 640x480"
echo "1 = 800x600"
echo "2 = 1024x768"
echo "3 = 1280x1024"
echo "4 = 1440x900"
echo "5 = 1920x1200"
read -p "Number of selection: " resolutioncode
if ! [[ $resolutioncode =~ ^[0-5]$ ]]; then
echo "$(tput setaf 1)Please enter a valid resolution code (0-5)$(tput sgr0)"
exit 1
fi
command -v VBoxManage >/dev/null 2>&1 || { echo "$(tput setaf 1)It looks like the command $(tput bold)VBoxManage$(tput sgr0)$(tput setaf 1) may not work properly. Check your installation of Virtualbox. Exiting...$(tput sgr0)" >&2; exit 1; }
VBoxManage modifyvm "$vmname" --cpuidset 00000001 000306a9 00020800 80000201 178bfbff
VBoxManage modifyvm "$vmname" --cpus 2
VBoxManage modifyvm "$vmname" --memory 8192
VBoxManage modifyvm "$vmname" --vram 128
VBoxManage setextradata "$vmname" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "MacBook9,1"
VBoxManage setextradata "$vmname" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "$vmname" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "$vmname" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "$vmname" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
VBoxManage setextradata "$vmname" "VBoxInternal2/EfiGopMode" "$resolutioncode"
VBoxManage setextradata "$vmname" "VBoxInternal2/EfiBootArgs" " "
echo "$(tput setaf 2)The VM named $vmname successfully prepared$(tput sgr0)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment