timsutton/osx-vm-templates

VirtualBox VM freezes periodically

mattieb opened this issue · 3 comments

This is a strange one, and I'm trying to figure it out, but I'm coming up somewhat empty-handed.

A new El Capitan VM built using the Packer template for VirtualBox will freeze for ~5 seconds every ~10 seconds, making interactive use somewhat troublesome. However, VirtualBox's OS X support is not necessarily broken outright.

Here's what I've observed:

  • If I build a straight DMG using these steps and VirtualBox's default OS X 10.11 configuration, the resulting VM does not freeze at all.
  • If I modify the Packer template to build a machine that more closely resembles VirtualBox's default configuration, the resulting box still freezes. (I've diffed the .vbox files—they're pretty much identical save UUIDs and names of things.)
  • The VM does not appear to freeze during the initial installation from the installation media. You can see the freezing if you swirl your mouse around inside the VM's console window for >10 seconds.
  • I noticed that shrink.sh is failing due to System Integrity Protection not allowing dynamic_pager to be unloaded, but if I attempt to build a box with these lines commented out, the resulting box still freezes.

It seems that something installed in the prepare_iso process is responsible, since the freezing is in play even before Packer starts running the scripts in scripts. But I've gone over what prepare_iso adds and I'm not sure what could be causing it.

Has anyone seen this or does anyone have any ideas what might be at fault? I'm currently looking over pkg-postinstall to see if anything looks suspicious.

Just to confirm, you're not crazy. I can reproduce the freezing issue with a Packer build. Didn't try doing a "regular" build like you did - I'm a mostly-happy VMware Fusion user, so I rarely test the Vbox support except for major new releases.

My machine is an iMac14,3 i7 (Haswell).

I also noticed that SIP issue with the dynamic pager and will correct that with an if statement soon.

Hard to see what in the postinstall would be doing anything. My first thought was perhaps ARD or SSH support, but disabling those in the sysprefs doesn't seem to have any effect.

I'd tried disabling ARD too, didn't fix it on this end either. I'm on a MacBookPro11,3, also Haswell I believe?

Today I've been trying to use the disk image from prepare_iso.sh to install. Results:

  • Running the standard disk image through VirtualBox installs fine, but the result freezes much like it did during the Packer run. So it seems Packer isn't our problem here.
  • Building a new disk image with pkg-postinstall replaced with a shell script that does nothing makes me stare at all the setup assistants, but the result is not freezing. On this box, I've tried enabling Screen Sharing and Remote Login as well as enabling crash submission—no freezing. Hm.

I'll keep at it…

Progress.

--- a/prepare_iso/support/pkg-postinstall
+++ b/prepare_iso/support/pkg-postinstall
@@ -19,7 +19,7 @@ else
     $PlistBuddy -c 'Add :com.apple.screensharing:Disabled bool False' "$OVERRIDES_PLIST"
 fi
 # Placeholder for Remote Management
-echo "enabled" > "$3/private/etc/RemoteManagement.launchd"
+#echo "enabled" > "$3/private/etc/RemoteManagement.launchd"

 # Add user to sudoers
 cp "$3/etc/sudoers" "$3/etc/sudoers.orig"

I'm doing the full Packer run now, but I didn't get a freeze on the manual build using this.

How to roll this in is another question. Maybe add some flags to prepare_iso that make it possible to avoid this step?

And, of course, I have no idea why this is a problem in the first place.