geerlingguy / macos-virtualbox-vm

Instructions and script to help you create a VirtualBox VM running macOS.
MIT License
2.55k stars 313 forks source link

Sierra 10.12.4 hangs during boot, stuck at gIOScreenLockState #24

Open dcosson opened 7 years ago

dcosson commented 7 years ago

Hey, I'm trying to get this to boot the first time. After following the README directions it just hangs about 30 seconds into starting up. The last log lines when it hangs are shown below. Any idea what the issue is?

I'm on Virtualbox 5.1.18 r114002 (Qt5.6.2) and MacOS 10.12.4 on an early 2015 Macbook Pro, and in Virtualbox I'm using 4GB RAM, 128MB video memory, 2 CPUs, and I've tried marking the ISO as Live CD/DVD

screen shot 2017-04-01 at 5 37 14 pm
dcosson commented 7 years ago

I downloaded the latest El Capitan installer from the mac store and that works fine. So it seems like there's an issue with the latest macOS Sierra version.

mam8cc commented 7 years ago

Can confirm, latest macOS Sierra stops at gIOScreenLockState

andrewschreiber commented 7 years ago

@dcosson How did you download the El Capitan installer? I get a "the version of macOS is too new" error.

Link: https://itunes.apple.com/us/app/os-x-el-capitan/id1147835434?mt=12

aabdellah commented 7 years ago

Same issue here.

dcosson commented 7 years ago

@andrewschreiber I was able to download from purchases list in my app store. I got this machine in ~ October 2015 so it came with El Capitan originally, is yours newer possibly?

z commented 7 years ago

Here's a tutorial on how to download the El Capitan pkg and trick the App Store into installing it, instead of Sierra, by hosting it locally.

https://7labs.heypub.com/tips-tricks/el-capitan-direct-download.html#El_Capitan8211_Single_Download_Multiple_Installations

pineman commented 7 years ago

I can also reproduce this issue. Why would it be that 10.12.4 raises this issue?

stevenirby commented 7 years ago

I'm also stuck on the gIOScreenLockState error. I've tried everything with tweaking the settings.

plessbd commented 7 years ago

I believe it has something to do with 10.12.4 I was able to install 10.12.3 (had a previous install downloaded already) and upgrade to 10.12.4 without issue.

livelite commented 7 years ago

I can confirm the same issue, stuck on gIOScreenLockState booting OS X Sierra 10.12.4 It worked for OS X El Capitan without issues.

stevenirby commented 7 years ago

So according to this: https://github.com/timsutton/osx-vm-templates#issue-with-10124

The Sierra 10.12.4 installer seems to no longer support including custom packages as part of the installer, unless they are signed by Apple.

I think until a hack is found this will no longer be possible.

skela commented 7 years ago

I've the same issue with 10.12.4.

I'd also like to point out that Parallels lets you create a virtual machine image from the recovery drive that works, also with 10.12.4. Not sure how this is achieved though.

LaloLoop commented 7 years ago

I tried the procedure described in this repo just in the days when 10.12.4 came out, and I can confirm that this is not working with the new version. I did not have the oportunity to try it with 10.12.3, but I checked back in that day for any issues related and could not find anything. I also tried running it in vmware 7 (an old version compared to toady's) on my MacbookPro but it hung up on the Apple Logo screen. So I believe this is related to the latest Installer. Probably Apple made some breaking changes. Probably the only solution would be to install with 10.12.3, and then upgrade? If someone has this kind of setup please report it. Thank you all!

plessbd commented 7 years ago

@LaloLoop as I commented 10 hours ago, I was able to install with 10.12.3 and upgrade to 10.12.4

tcurdt commented 7 years ago

Does anyone know how/where to download 10.12.3? I am also stuck when trying to install 10.12.4

nathanhleung commented 7 years ago

@tcurdt I'm facing this same issue - I don't think there's any way to get the previous installer unless you know someone who already has it. I ended up redownloading El Capitan from the App Store and I'm using it now

tcurdt commented 7 years ago

@nathanhleung I am doing the very same thing. Still need Sierra at some point though.

petemounce commented 7 years ago

Is http://osxdaily.com/2016/09/27/allow-apps-from-anywhere-macos-gatekeeper/ any help?

Sorry, not really a subject matter expert; I'm probably conflating Apps with the pkg, and I've no idea whether it's possible to even run commands before the pkg is used?

nathanhleung commented 7 years ago

@tcurdt I downloaded the Sierra installer on my El Capitan VM and have gone through the install/restart process a few times but it doesn't seem to be working - by any chance have you taken that route in trying to install Sierra?

tcurdt commented 7 years ago

@nathanhleung no, I never tried that as I assume the download will have the same problem. I just found an old Sierra USB stick ready to install though. I might try to turn that into an iso and see if that works. That's about all the options I see at the moment.

I am wondering if this works for vmware/parallels - then switching away virtualbox could be another option.

jonanh commented 7 years ago

I was having the same issue and unfortunately I didn't have any copy of an older installer either, and in my desperate search for a solution I found this thread. I wanted to try AutoDMG + vfuse but I wanted to use virtualbox for now, so I wrote a modified version of Tim Sutton's prepare_iso.sh https://github.com/timsutton/osx-vm-templates/pull/82 which does the same as AutoDMG + vfuse but using Virtualbox's tools, which generates a vdi with a fresh install.

prepare_vdi.sh

The idea more less of what this script is doing is:

IMAGE_SIZE=32
IMAGE_SIZE_BYTES=$(($IMAGE_SIZE * 1024 * 1024 * 1024))
sudo hdiutil attach -noverify -mountpoint /tmp/installesd /Applications/Install\ macOS\ Sierra.app/Contents/SharedSupport/InstallESD.dmg
sudo hdiutil create -size "${IMAGE_SIZE}g" -type SPARSE -fs HFS+J -volname "Macintosh HD" -uid 0 -gid 80 -mode 1775 sierra.dmg
MOUNTOUTPUT=$(sudo hdiutil attach -noverify -mountpoint /tmp/os -owners on sierra.dmg)
sudo installer -verboseR -dumplog -pkg /tmp/installesd/Packages/OSInstall.mpkg -target /tmp/os
DISK_DEV=$(grep GUID_partition_scheme <<< "$MOUNTOUTPUT" | cut -f1 | tr -d '[:space:]')
sudo cat "$DISK_DEV" | VBoxManage convertfromraw stdin ~/Documents/output.vdi "$IMAGE_SIZE_BYTES"
hdiutil detach /tmp/os
hdiutil detach /tmp/installesd

I hope that it helps :-)

fabriziogiordano commented 7 years ago

Will Sierra 10.12.5 fix this? Did some of you tried already?

benmarten commented 7 years ago

Just tried today, same issue with 10.12.5.

tcurdt commented 7 years ago

@jonanh that looked very promising at first - but now it's just doing:

...
May 16 18:38:18  installer[63714] <Alert>: client 0x7f84b6d163d0: phaseName = "OS Installer"
May 16 18:39:18  installer[63714] <Alert>: client 0x7f84b6d163d0: phaseName = "OS Installer"
May 16 18:40:18  installer[63714] <Alert>: client 0x7f84b6d163d0: phaseName = "OS Installer"
May 16 18:41:18  installer[63714] <Alert>: client 0x7f84b6d163d0: phaseName = "OS Installer"
May 16 18:42:18  installer[63714] <Alert>: client 0x7f84b6d163d0: phaseName = "OS Installer"
May 16 18:43:18  installer[63714] <Alert>: client 0x7f84b6d163d0: phaseName = "OS Installer"
May 16 18:44:18  installer[63714] <Alert>: client 0x7f84b6d163d0: phaseName = "OS Installer"
May 16 18:45:18  installer[63714] <Alert>: client 0x7f84b6d163d0: phaseName = "OS Installer"
May 16 18:46:18  installer[63714] <Alert>: client 0x7f84b6d163d0: phaseName = "OS Installer"
May 16 18:48:18  installer[63714] <Alert>: client 0x7f84b6d163d0: phaseName = "OS Installer"
May 16 18:49:18  installer[63714] <Alert>: client 0x7f84b6d163d0: phaseName = "OS Installer"
May 16 18:50:18  installer[63714] <Alert>: client 0x7f84b6d163d0: phaseName = "OS Installer"
May 16 18:51:18  installer[63714] <Alert>: client 0x7f84b6d163d0: phaseName = "OS Installer"
May 16 18:52:18  installer[63714] <Alert>: client 0x7f84b6d163d0: phaseName = "OS Installer"
...
jonanh commented 7 years ago

@tcurdt this is the output I get after running the prepare_vdi.sh from https://github.com/timsutton/osx-vm-templates/pull/82

tcurdt commented 7 years ago

@jonanh oh, I was trying your script from above. Will give that a try.

tcurdt commented 7 years ago

I finally got it working like this:

sudo prepare.sh ~/Desktop/Install\ macOS\ Sierra.app
#!/bin/sh
set -x
set -e

IMAGE_SIZE=32
IMAGE_SIZE_BYTES=$(($IMAGE_SIZE * 1024 * 1024 * 1024))

echo "attaching input OS X installer image"
hdiutil attach \
  -noverify \
  -nobrowse \
  -owners on \
  -mountpoint /tmp/installesd \
  "$1/Contents/SharedSupport/InstallESD.dmg"

echo "creating empty read-write DMG"
hdiutil create \
  -size "${IMAGE_SIZE}g" \
  -type SPARSE \
  -fs HFS+J \
  -volname "Macintosh HD" \
  -uid 0 \
  -gid 80 \
  -mode 1775 \
  /tmp/sierra.dmg

echo "mounting empty read-write DMG"
MOUNTOUTPUT=$(hdiutil attach -noverify -mountpoint /tmp/os -nobrowse -owners on /tmp/sierra.dmg.sparseimage)

echo "installing macOS"
installer \
  -verboseR \
  -dumplog \
  -pkg "/tmp/installesd/Packages/OSInstall.mpkg" \
  -target "/tmp/os"

echo "exporting vdi to /tmp"
DISK_DEV=$(grep GUID_partition_scheme <<< "$MOUNTOUTPUT" | cut -f1 | tr -d '[:space:]')
echo "DISK_DEV=$DISK_DEV"
cat "$DISK_DEV" | pv -s $IMAGE_SIZE_BYTES | VBoxManage convertfromraw stdin /tmp/macos-10.12.vdi "$IMAGE_SIZE_BYTES"

echo "done"
hdiutil detach /tmp/os
hdiutil detach /tmp/installesd

In case you don't have pv installed you have to remove the pv -s $IMAGE_SIZE_BYTES | of course.

But be aware - updating to 10.12.5 after the install broke the booting similar to what I saw on the former install attempts. So it doesn't seem to be the final solution. Maybe I'll try again after increasing the memory of the vm. Or I just cave and shell out the money for an upgrade of the old vmware/parallels license :-/

jonanh commented 7 years ago

@tcurdt these are settings that are working for me

VM="macOS"
HARDDRIVE="macOS.vdi"
VBoxManage createvm --name "$VM" --ostype "MacOS_64" --register

VBoxManage storagectl "$VM" --name "SATA Controller" --add sata --controller IntelAHCI
VBoxManage storageattach "$VM" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "$HARDDRIVE"

VBoxManage modifyvm "$VM" --audiocontroller "hda"
VBoxManage modifyvm "$VM" --chipset "ich9"
VBoxManage modifyvm "$VM" --firmware "efi"
VBoxManage modifyvm "$VM" --cpus "2"
VBoxManage modifyvm "$VM" --hpet "on"
VBoxManage modifyvm "$VM" --keyboard "usb"
VBoxManage modifyvm "$VM" --memory "4096"
VBoxManage modifyvm "$VM" --mouse "usbtablet"
VBoxManage modifyvm "$VM" --vram "128"

Here is the full script :-) https://github.com/jonanh/osx-vm-templates/commit/09787cde8024f88e3c604b16e64dfea4f93407d8#diff-041cfff4cd15513c0a368cbab35aeb1e

jonanh commented 7 years ago

@tcurdt BTW, I would umount and mount again the sparse DMG before exporting it, sometimes it was failing for me. Maybe it doesn't flush everything before the export starts:

https://github.com/jonanh/osx-vm-templates/blob/2097e6cb60ac12a404ff18bb0ebb81ca4ced1e45/prepare_iso/prepare_vdi.sh#L256

tcurdt commented 7 years ago

Pretty much the same setup I have :) Except with only 3GB memory. Will give it a try with 4GB. Thanks for the pointers, @jonanh

brki commented 7 years ago

@jonanh Thanks a million! https://github.com/jonanh/osx-vm-templates/tree/create_prepare_vdi_based_on_autodmg#alternative-method-using-prepare_vdish-prepare_ovfsh-and-packer-virtualbox-ovf works for me with macOS 10.12.5

geerlingguy commented 7 years ago

So with the above... is there any change to this project's instructions or script that can help with that?

fabriziogiordano commented 7 years ago

I was able to follow the steps from @brki comment and run Sierra 10.12.5 on VirtualBox. The downside is that VirtualBox supports 1024x768 screen resolution only.

Right after I saw a tweet from @osxdaily and I follow this post http://osxdaily.com/2017/04/11/run-macos-virtual-machine-easy-parallels/ Parallel Lite is free if you run Linux (and macOS). I was able to run Sierra 10.12.5 in fullscreen mode. Also Parallels interface feels nicer.

Disclaimer, I am not affiliate with Parallels neither @osxdaily

lsh-silpion commented 7 years ago

@tcurdt I tried your approach and after several failed attempts (the installer reported some errors while copying to the sparse image) I finally got my macos-10.12.vdi

But I was not able to boot from this vdi. Upon inspection of the sparseimage from which the vdi was created it looks like /System/Library/CoreServices/boot.efi is not there.

Any idea what could have gone wrong?

Thanks,

Lars

DelphiWorlds commented 7 years ago

@lsh-silpion I suggest using jonanh's solution, mentioned in brki's comment on May 18. Works like a charm for me

jenilkansara commented 7 years ago

Can you tell me how to use jonanh's solution exactly? Do I need to write those commands directly after downloading MacOS Sierra from the app store? I am trying to run MacOS 10.12.5 on VirtualBox on my Windows 10 Laptop but getting an error

"IOConsoleUsers: gIOScreenLockState 3, hs 0, bs 0, now 0, sm 0x0"

after having many "Please Switch to XPC or bootstrap_check_in(): com.apple.*"

jonanh commented 7 years ago

Hi,

I added some documentation prepare_vdi.sh.

I could create also a simplified version and contribute it to this repo as well, since most of the people don't need packer support. :-)

Regards,

jenilkansara commented 7 years ago

Thank you jonanh! I understand the process flow now. I created the dmg using prepare_iso.sh Now Can I use any current method to convert it to ISO? ex. as shown here https://www.howtogeek.com/289594/how-to-install-macos-sierra-in-virtualbox-on-windows-10/

Or is there any other process? As I believe in the documentation, Packer support is not for me.

Update: I did the stated above and used VirtualBox to run the dmg file but getting the same error. 1

DelphiWorlds commented 7 years ago

After an update of macOS, mine stopped working. It would start at the EFI screen, and I have not been able to find a way to fix this. In the meantime, I've abandoned VirtualBox and I'm using VMWare Fusion which, incidentally, supports folder sharing (VirtualBox does not)

jonanh commented 7 years ago

@jenilkansara using the prepare_dmg.sh script and generating an ISO will hit the same bug https://www.virtualbox.org/ticket/16644, since the problem it is somehow connected with the startup of the installation.

The prepare_vdi.sh uses another approach (the same idea as AutoDMG), which avoids the problem by creating a fresh install on a Mac host (without any virtual machine) into a temporary disk image (DMG) and then converting it into a virtual box disk image.

The reason that I am not using AutoDMG and I wrote the prepare_vdi.sh script is because the final generated and compressed DMG fails to be converted into a vdi/vdmk using the VBoxManage convert tools. So once the os is installed into the temporary disk image, I dump the raw /dev/disk device file to VBoxManage convertfromraw. :-)

Once the bug 16644 is fixed, the ISO approach should be used since it is simpler and cleaner. But they will be still useful now that Apple doesn't allow to add custom packages anymore in the installation, for those needing to easily automate the generation of packer images.

Regards.

jenilkansara commented 7 years ago

Hello jonanh, thank you so much for reaching out, I tried prepare_vdi.sh but there is an error -- Installing firstboot installer pkg installer: Package name is installer: Installing at base path /private/tmp/veewee-osx-basesystem.Xe5u installer: The install was successful. -- Exporting macOS_10.12.vdi ../prepare_iso/prepare_vdi.sh: line 261: VBoxManage: command not found macjenil:packer pl106$

Is the problem with the installer?

Thank You.

jonanh commented 7 years ago

Check your VirtualBox installation, VBoxManage is the command-line interface to VirtualBox.

jenilkansara commented 7 years ago

Hey Jonanh, Thank you so much! It works like a charm. By the way, is there a problem in MacOS 10.12.5 running in Virtualbox of not been able to detect USB connections? I wanted to run apps from Xcode on my iPhone. It used to work in MacOS 10.12 but not in this version. Thankx, Jenil Kansara

edit: a pendrive is getting detected but not the iphone

ghost commented 7 years ago

I had the same problem trying with 10.12.6 in Virtualbox 5.1 and Virtualbox 5.0. I've tried with the usual custom vboxmanage setextradata stuff and cpuid and without, tried without USB, with USB1.1, 2 and 3. It gets stuck at gIOScreenLockState regardless.

ynikanchyk commented 7 years ago

With instructions for prepare_vdi.sh provided by @jonanh I was able to obtain a working VirtualBox VM with OS X 10.12.6 on the Mac mini host. I was able to enter my Apple ID and get updates for applications. I didn't use packer, just imported appliance from .ovf-file. All VM options were used as provided by prepare_ovf.sh script, only after successfull update I decided to switch off audio and change network settings according to my needs.

Just for assurance, the boot log contains the same message with gIOScreenLockState mentioned but boot process doesn't stuck after it (IOLockUnlock(gIOConsoleUsersLock);is executed there according to xnu-3789.51.2/iokit/Kernel/IOService.cpp - I have no idea if/why it stucks when installation is started from ISO image).

Once again for guys having the problems: make sure that installation is performed NOT on VM from the .iso-image but on the host to .dmg-file and then VM is created to use the disk with already installed OS X. That's what prepare_vdi.sh/prepare_odf.sh are for.

Thank you very much, @jonanh.

kennethreitz commented 7 years ago

@ynikanchyk you hopefully just saved me. will know soon :)

ashumeet commented 7 years ago

@ynikanchyk ..Thank you ... it worked after 3 hours of searching internet. macOS 10.12.6 @jonanh .. Thank you ... you are a real life saver.

ghost commented 7 years ago

@jonanh This helped me test macOS Sierra 10.12.6 on windows host. I had to set cpuid, DeviceID and SMC of box to make it work on windows.

adrian-keith commented 7 years ago

@soapagent Can you go into more detail about setting the CPUID, DeviceID, SMC? I'm new to this and attempting to run on my desktop.

-Core i5 6500 -16GB RAM -W10 x64

ghost commented 7 years ago

@lXbalanque , Please check this article.

https://www.howtogeek.com/289594/how-to-install-macos-sierra-in-virtualbox-on-windows-10/