So it appears macOS 10.14 Mojave (as of beta 1) only installs to APFS regardless if the hard drive is SSD or not.
Unfortunately, this means that VirtualBox doesn't support Mojave.
Is there a workaround for this?
#!/usr/bin/env bash
#
# DESCRIPTION
#
# Run macOS 10.14 Mojave in Virtualbox.
#
###############################################################################
# Core parameters #############################################################
readonly INST_VER="Install macOS 10.14 Beta"
readonly INST_BIN="/Applications/$INST_VER.app/Contents/Resources/createinstallmedia"
readonly DST_DIR="/tmp"
readonly DST_DMG="$DST_DIR/macOS-Mojave.dmg"
readonly DST_VOL="/Volumes/macOS-Mojave"
readonly DST_ISO="$DST_DIR/macOS-Mojave.iso.cdr"
readonly VM="macOS-Mojave"
readonly VM_DIR="${HOME}/VirtualBox VMs/$VM"
readonly VM_SIZE="32768"
###############################################################################
# Define methods ##############################################################
runChecks() {
echo "Running checks..."
if [ ! -x "$INST_BIN" ] ; then echo "ERROR: '$INST_BIN' not found."; exit 1; fi
if ! type VBoxManage >/dev/null 2>&1 ; then echo "ERROR: 'VBoxManage' not installed."; exit 2; fi
}
createImage() {
echo -n "Creating image '$DST_DMG' (will need sudo)..."
if [ ! -e "$DST_DMG" ]; then
echo "."
hdiutil detach "/Volumes/$INST_VER/" 2>/dev/null || true
hdiutil create -o "$DST_DMG" -size 10g -layout SPUD -fs HFS+J && \
hdiutil attach "$DST_DMG" -mountpoint "$DST_VOL" && \
sudo "$INST_BIN" --nointeraction --volume "$DST_VOL" && \
hdiutil detach "/Volumes/$INST_VER/"
else
echo "already exists."
fi
echo -n "Creating iso '$DST_ISO'..."
if [ ! -e "$DST_ISO" ]; then
echo "."
hdiutil convert "$DST_DMG" -format UDTO -o "$DST_ISO"
else
echo "already exists."
fi
}
setupVM() {
if [ ! -e "$VM_DIR" ]; then
mkdir -p "$VM_DIR"
fi
echo -n "Creating VM '$VM_DIR/$VM.vdi'..."
if [ ! -e "$VM_DIR/$VM.vdi" ]; then
echo "."
VBoxManage createhd --filename "$VM_DIR/$VM.vdi" --variant Standard --size "$VM_SIZE"
else
echo "already exists."
fi
echo -n "Creating VM '$VM'..."
if ! VBoxManage showvminfo "$VM" >/dev/null 2>&1 ; then
echo "."
VBoxManage createvm --register --name "$VM" --ostype MacOS_64
VBoxManage modifyvm "$VM" --usbxhci on --memory 4096 --vram 128 --firmware efi --chipset ich9 --mouse usbtablet --keyboard usb
VBoxManage storagectl "$VM" --name "SATA Controller" --add sata --controller IntelAHCI --hostiocache on
VBoxManage storageattach "$VM" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "$VM_DIR/$VM.vdi"
VBoxManage storageattach "$VM" --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium "$DST_ISO"
else
echo "already exists."
fi
}
runVM() {
echo -n "Starting VM '$VM'..."
if ! VBoxManage showvminfo 'macOS-Mojave'|grep "State:"|grep -i running > /dev/null ; then
echo "."
VBoxManage startvm "$VM" --type gui
echo "Next steps:"
echo " 1. Partition the virtual drive"
echo " 2. Install macOS on the virtual drive"
echo " 3. Remove virtual macOS installer CD-ROM"
echo " 4. Todo: Can only boot manually once to continue setup (see this file) as APFS is now enforced"
# Shell> fs1:
# FS1:\> cd "macOS Install Data"
# FS1:\macOS Install Data\> cd "Locked Files"
# FS1:\macOS Install Data\Locked Files\> cd "Boot Files"
# FS1:\macOS Install Data\Locked Files\Boot Files\> boot.efi
else
echo "already running."
fi
}
cleanup() {
local err="${1:-}"
local line="${2:-}"
local linecallfunc="${3:-}"
local command="${4:-}"
local funcstack="${5:-}"
if [[ "$err" -ne "0" ]]; then
echo 2>&1 "ERROR: line $line - command '$command' exited with status: $err."
echo 2>&1 "ERROR: In $funcstack called at line $linecallfunc."
echo 2>&1 "DEBUG: From function ${funcstack[0]} (line $linecallfunc)."
fi
}
main() {
runChecks
createImage
setupVM
runVM
}
###############################################################################
# Run script ##################################################################
[[ "${BASH_SOURCE[0]}" == "${0}" ]] && trap 'cleanup "${?}" "${LINENO}" "${BASH_LINENO}" "${BASH_COMMAND}" $(printf "::%s" ${FUNCNAME[@]:-})' EXIT && main "${@:-}"
###############################################################################
mpack wrote:VirtualBox is a hardware emulator. It doesn't know anything about guest OS filesystems.
socratis wrote:mpack wrote:VirtualBox is a hardware emulator. It doesn't know anything about guest OS filesystems.
I was of the same thinking as well. But I realized that in order to boot in EFI, you'd have to have a rudimentary filesystem parser. The APFS part isn't there yet...
Alex_ wrote:Afaik, the UEFI part resides on a FAT partition provided by VirtualBox
mpack wrote:You have to support whatever filesystem is used by the boot partition (which is separate from the OS main partition)
#if !defined (EFI_REMOVABLE_MEDIA_FILE_NAME)
#if defined (MDE_CPU_EBC)
//
// Uefi specification only defines the default boot file name for IA32, X64
// and IPF processor, so need define boot file name for EBC architecture here.
//
#define EFI_REMOVABLE_MEDIA_FILE_NAME L"\\EFI\\BOOT\\BOOTEBC.EFI"
#else
#error "Can not determine the default boot file name for unknown processor type!"
#endif
#endif
#ifdef VBOX
/**
Apple seems to have a different EFI_REMOVABLE_MEDIA_FILE_NAME value, so it
seems we have to check for both the apple value and for the UEFI value if we
want to support both apple and non-apple systems. (Probably more to this.)
**/
#define VBOX_EFI_APPLE_MEDIA_FILE_NAME L"\\System\\Library\\CoreServices\\boot.efi"
#endif
mpack wrote:Is APFS encumbered by patents? Forget about VirtualBox supporting it if so.
Is APFS open source?
An open source implementation is not available at this time. Apple plans to document and publish the APFS volume format specification.
socratis wrote:Given that there is no easy, reliable way to even mount an EFI partition so that we can make heads or tails out of it, this is going to be an uphill battle
Users browsing this forum: No registered users and 3 guests