Whether you want to occasionally test a website in Safari, or try out a little bit of software in the Mac environment, having access to the latest version of macOS in a virtual machine is useful. Unfortunately, you’re not really supposed to do this—so getting macOS running in VirtualBox is, to say the least, tricky.
It’s not impossible, however. Some of the folks at the InsanelyMac forums have figured out a process that works. The only thing not working is sound, which for some reason is highly distorted or nonexistent. Other than that, though, this is macOS Sierra, running smoothly in VirtualBox.
To make things a little easier for people, we’ve combined methods from a few different forum threads into a single, step-by-step tutorial, complete with screenshots. Let’s dive in.
NOTE: In order to get this working, you will need access to a real Mac in order to download Sierra. You could, we suppose, obtain a Sierra ISO by other means, but we don’t recommend it. Borrow a friend’s Mac for an hour if you don’t have one, and you should be fine—everything beyond step one of this tutorial can be done on your Windows PC.
Step One: Create a macOS Sierra ISO File
To start, we’ll need to create an ISO file of macOS Sierra’s installer, so we can load it in VirtualBox on our Windows machine. Grab your borrowed Mac, head to the Mac App Store, search for Sierra, and click “Download.”
When the process is done, the installer will launch—that’s okay, just close it. We don’t want to upgrade your friend’s Mac; we just need the downloaded files.
To convert those files to an ISO, we’ll need to use the Terminal, which you can find in Applications > Utilities.
First, paste this command into the Terminal and press Enter:
hdiutil attach /Applications/Install\ macOS\ Sierra.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
This will mount the bootable part of the installer you just downloaded as a virtual disk on the Mac.
Next, run the following command to create a blank disk image:
hdiutil create -o /tmp/Sierra.cdr -size 7316m -layout SPUD -fs HFS+J
Then, mount your blank image:
hdiutil attach /tmp/Sierra.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/install_build
Now we’re going to restore BaseSystem.dmg from our mounted installer over to our now-mounted image:
asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
Note that, after doing this, the name of our destination mount point has changed to “OS\ X\ Base\ System/System,” which we’ll see as we remove some unnecessary files from this newly-restored drive:
rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
Next, let’s copy over a few more files we need:
cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/
cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist
cp -rp /Volumes/install_app/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/BaseSystem.dmg
You’re almost done! Unmount the two images:
hdiutil detach /Volumes/install_app
hdiutil detach /Volumes/OS\ X\ Base\ System
And, finally, convert the image you created into an ISO file:
hdiutil convert /tmp/Sierra.cdr.dmg -format UDTO -o /tmp/Sierra.iso
Move the ISO to the desktop:
mv /tmp/Sierra.iso.cdr ~/Desktop/Sierra.iso
And you’ve got a bootable Sierra ISO file!
Copy it to your Windows machine using a large flash drive, an external hard drive, or over your local network.
Step Two: Create Your Virtual Machine in VirtualBox
Next, head to your Windows machine, and install Virtualbox if you haven’t already, making sure you have the latest version.
Open it up and click the “New” button. Name your Virtual Machine “macOS Sierra,” and choose “Mac OS X” for the operating system and “Mac OS X (64-bit)” for the version (as of this writing, “macOS Sierra” is not offered, but that’s fine.)
Continue through the process. For memory, we recommend you use at least 4096MB, though you can opt for more if you have enough RAM to spare on your Windows machine.
Next, you’ll be asked about your hard drive. Choose “Create a Virtual Hard Disk Now” and click Create.
Choose VDI for hard disk type and click Next. You’ll be asked if you want a dynamically sized drive or fixed. We recommend Fixed Size, since it’s a bit faster, though it’ll take up a bit more hard drive space on your Windows machine.
Click Next. You’ll be asked how big a drive you want; we recommend at least 25GB, which is big enough for the OS and a few applications. Depending on your storage situation, you could offer more, but we don’t think you can really use much less than that.
Click through the prompts, and you’ve created an entry for your virtual machine! Now it’s time to do a little configuration.
Step Three: Configure Your Virtual Machine in VirtualBox
You should see your virtual machine in VirtualBox’s main window.
Select it, then click the big yellow “Settings” button. First, head to “System” in the left sidebar. On the Motherboard tab, make sure that “Floppy” is unchecked.
Next head to the “Processor” tab, and make sure you have at least two CPUs allocated to the virtual machine.
Next, click “Display” in the left sidebar, and make sure Video Memory is set to 128MB.
Next, click “Storage” in the left sidebar, then click the “Empty” CD drive. Click the CD icon at the top right, then browse to the ISO file you created before.
Be sure to click “OK” to finalize all the changes you’ve made, then close VirtualBox. No, seriously: close VirtualBox now, or the next steps won’t work.
Step Four: Configure Your Virtual Machine From The Command Prompt
We’ve done a few tweaks, but we need to make a few more more in order to convince the operating system it’s running on a real Mac. Sadly, there are no options for this from VirtualBox’s interface, so you’ll need to open the Command Prompt.
Right-click on the Start menu and choose “Command Prompt (Admin).”
You need to run a number commands, in order. Paste the following commands, pressing Enter after each one and waiting for it to complete:
cd "C:\Program Files\Oracle\VirtualBox\"
VBoxManage.exe modifyvm "macOS Sierra" --cpuidset 00000001 000306a9 04100800 7fbae3ff bfebfbff
VBoxManage setextradata "macOS Sierra" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "MacBookPro11,3"
VBoxManage setextradata "macOS Sierra" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "macOS Sierra" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Mac-2BD1B31983FE1663"
VBoxManage setextradata "macOS Sierra" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "macOS Sierra" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
That’s it! If everything worked, you shouldn’t see any feedback; the commands will simply run. Go ahead and close the Command Prompt. We’re heading back to VirtualBox now.
Step Five: Install macOS Sierra in Your Virtual Machine
Re-open VirtualBox, click your Sierra machine, then click “Start.” Your machine will start to boot. You will see a lot of superfluous information as this happens—and I mean a lot—but don’t worry about it. It’s normal, even some of the things that look like errors.
You should only worry if a specific error hangs for five minutes or more. Just walk away and let it run for a bit. If you’ve done everything right, it’ll boot.
Eventually, you’ll see the installer asking you to pick a language:
Pick “English,” or whatever language you prefer, then click “Next.” Before you do anything else, however, click “Utilities” in the menu bar, then click “Disk Utility.”
Click the drive labeled “VBOX HARDDISK,” then click “Erase.”
Name the drive “Macintosh HD,” and leave the other two settings as-is (“Mac OS Extended Journaled” and “GUID Partition Map”.) Click “Erase,” then close Disk Utility when the process is complete.
Back in the installer, click “Next”, then click “Macintosh HD” when asked which drive you want to use.
The installation will begin! This might take a while, so be patient. Eventually you’ll be re-booted into macOS. If that doesn’t happen, try ejecting the ISO from the Virtual Machine. When Sierra does boot, you’ll need to go through choosing your country, time zone, and the rest of the initial setup process.
Eventually, you’ll make it to the Mac desktop. Yay!
You can now try out any Mac software, though some functions, like FaceTime and Messages, won’t work because Apple won’t recognize your computer as a real Mac. But a lot of the basic stuff should work. Have fun!
Step Six (Optional): Change Your Resolution
By default, your virtual machine will have a resolution of 1024×768, which is not a lot of room to work with. If you try to change the resolution from within macOS, however, you will see no option to do so. Instead, you need to enter a few commands.
Shut down your Virtual Machine by shutting down macOS: click the Apple in the menu bar, then click “Shut Down.” Next, close VirtualBox entirely (seriously, this step will not work if VirtualBox is still open!) and head back to Windows’ Command Prompt as an admin. You need to run the following two commands:
cd "C:\Program Files\Oracle\VirtualBox\"
VBoxManage setextradata "macOS Sierra" "VBoxInternal2/EfiGopMode" N
In the second command, you need to replace the “N” with a number from one to five, depending on what resolution you want:
- 1 gives you a resolution of 800×600
- 2 gives you a resolution of 1024×768
- 3 gives you a resolution of 1280×1024
- 4 gives you a resolution of 1440×900
- 5 gives you a resolution of 1920×1200
Start up VirtualBox, load up your virtual machine, and it should boot to your preferred resolution!
From now on, you can open VirtualBox for any Mac-related testing you want to do. Again, you’ll see a lot of errors pop up during boot, but they’re fine; ignore them. Also, remember that audio won’t work, nor will things like FaceTime that require a real Mac. This isn’t going to be perfect, which is to be expected from an entirely unsupported setup. But it’s macOS, in a virtual machine, and that’s not bad! Be sure to check out our guide to VirtualBox’s advanced features to get the most out of your machine, too.
0 comments:
Post a Comment