Skip to content

Instantly share code, notes, and snippets.

@tap52384
Last active August 1, 2023 10:10
Show Gist options
  • Save tap52384/f1377ad49975afc83b7387d510da1d76 to your computer and use it in GitHub Desktop.
Save tap52384/f1377ad49975afc83b7387d510da1d76 to your computer and use it in GitHub Desktop.
Install Windows on External Drive for macOS

Install Windows via Boot Camp on External Drive

Directions for getting windows 10 to work with virtualbox 6.0.12.

References

Tools Used

Procedure

Install Windows 10 via Boot Camp Assistant

  • Go to Applications --> Utilities --> Boot Camp Assistant (or use Spotlight)
  • In the Finder menu, go to Action --> Download Windows Support Software
  • You can save this WindowsSupport folder locally to the Downloads folder
  • This folder contains the Apple drivers to be installed after Windows is installed
  • You will need this folder copied to a separate USB flash drive; in order for installation to be successful, the Windows Support Software assumes it is located on the D: drive, not the same drive to which Windows was installed.

Install VirtualBox on macOS

# Install Virtualbox and the extension pack via Homebrew
brew cask install virtualbox virtualbox-extension-pack

Prepare your external drive

In order to use your external drive with VirtualBox it will need to be formatted first.

  1. Open Disk Utility (Applications --> Utilities --> Disk Utility, or use Spotlight)

  2. Go to View --> Show All Devices

  3. Erase the external drive (the entire drive, not just a partition) using the following settings:

    • Name: BOOTCAMP
    • Format: MS-DOS (FAT)
    • Scheme: GUID Partition Map

If you do not see Scheme, go to View --> Show All Devices and make sure to select the device instead of a single partition.

After you have formatted the external drive, open Terminal/iTerm2 and find the identifier for your external drive using the commands below:

# Lists all connected disks, their names, and identifiers
# Mine appeared as "disk2"; you will need this later
diskutil list
# This is the same as ejecting the external drive from Finder
diskutil unmount /Volumes/BOOTCAMP <--- this is the name of the BOOTCAMP volume

If your external drive volume doesn't have a name for some reason, use /Volumes/Untitled.

Create a VirtualBox raw disk image for the BOOTCAMP partition

To create an image that represents an entire physical hard disk (which will not contain any actual data, as this will all be stored on the physical BOOTCAMP partition). You will need the previous information from diskutil list for the external drive:

  • /dev/disk2 (external, physical):
mkdir ~/virtualbox
# Elevated privileges are required for access to the external drive (/dev/disk2)
# The external drive may need to be ejected/unmounted for this to work
sudo vboxmanage internalcommands createrawvmdk -rawdisk /dev/disk2 -filename ~/virtualbox/bootcamp.vmdk
# The $(whoami) should input your username for the command
sudo chown $(whoami) ~/virtualbox/*.vmdk

Please note that vboxmanage internalcommands is an internal tool and is completely unsupported and may change in compatible ways without warning.

This command will create an image that will reference the EFI and BOOTCAMP partitions on our internal hard drive. If this command fails, then you may need to disable System Integrity Protection. This requires you to boot into Recovery Mode and execute the following command csrutil disable:

-bash-3.2# csrutil status
System Integrity Protection status: enabled.
-bash-3.2# csrutil disable
Successfully disabled System Integrity Protection. Please restart the machine for the changes to take effect.

Documentation on configuring System Integrity Protection can be found here and here.

While you are in Recovery mode, you may also need to configure the Startup Security Utility to allow booting from external removable devices.

Create a VirtualBox VM for Windows

Because sudo is required to create the VirtualBox raw disk image (*.vmdk), you have to open VirtualBox using sudo as well in order to create a virtual machine that have the permissions necessary to access the image:

# Open Virtualbox with sudo
sudo /Applications/VirtualBox.app/Contents/MacOS/VirtualBox
  • In the Finder menu for Virtualbox, go to Machine --> New.
  • Click Expert Mode to continue.

In the Name and operating system window:

  • Name: WIN10
  • Machine Folder: /Users/UserName/virtualbox
  • Type: Microsoft Windows
  • Version: Windows 10 (64-bit)
  • Memory Size: 4096 MB
  • Use an existing virtual hard disk file: ~/virtualbox/bootcamp.vmdk

Click Create.

If you cannot successfully choose bootcamp.vmdk as your virtual hard disk file, make sure you successfully opened VirtualBox using sudo. If you did, eject the external drive using Disk Utility but leave it connected to your computer, and try again.

In the main application window, select the WIN10 VM and click Settings.

In the System --> Motherboard settings

  • Boot Order: Only check Hard Disk and Optical; move Hard Disk up before Optical
  • Enable EFI (special OSes only): checked
  • Enable I/O APIC: checked

In the System --> Processor settings

  • Processors: 4
  • Execution Cap: 100%
  • Enable PAE/NX: Checked

In Storage settings

  • Controller: SATA: Check the Use Host I/O Cache option

Attached to this SATA controller should be two devices: bootcamp.vmdk and an optical drive that may appear as "Empty". Select the optical drive to then click the CD icon and choose your Windows 10 ISO.

Click OK to save these settings. Your virtual machine should now be ready so that you can install Windows 10 onto your external drive.

Installing Windows 10 on the External Drive via VirtualBox

  1. If you start VirtualBox normally, you won't see the VM that you created when running under sudo
  2. If you attempt to run the VM and it fails to run, try unmounting/ejecting the drive and then starting the VM again.
  3. Before starting the VM, double-check that Enable EFI (special OSes only) is checked! The EFI partition on your external drive is required for macOS to select your external drive as a startup disk. Do NOT format the EFI partition!
  4. Start the WIN10 VM. When the Windows 10 installer begins and you are asked Which type of installation do you want? choose Custom: Install Windows only (advanced)
  5. You will see two partitions, EFI and BOOTCAMP. Delete the BOOTCAMP partition. Once you have just the EFI and unallocated space, click the unallocated space (without making a partition) and then you should be able to click Next to start installing Windows. If you still cannot click Next, double-check that Enable EFI (special OSes only) is checked in the VM settings. The Windows installer will automatically create the needed NTFS partition. This method is used to avoid the issue where some external drives hang when attempting to format the BOOTCAMP partition as NTFS.
  6. You may get the error: Windows cannot be installed to this disk. The selected disk is of the GPT partition style. If so, try reformatting the external drive using the instructions for Disk Utility before and try again.
  7. Pay attention to the installation! Before the installation reboots to continue, quickly power off the VM by clicking the red X on the VM window and choosing Power off the machine.
  8. Close VirtualBox and restart your Mac. Hold the right Option key once the screen goes black until the Apple logo appears to see the list of available bootable drives. If you do not see your drive, you may have a newer Mac and may need to use the Startup Security Utility to allow booting from external devices.
  9. You will need a standard USB keyboard and mouse to complete the installation process as the Boot Camp drivers are required for Apple's hardware to be recognized by Windows.
  10. Use the WindowsSupport on the USB flash drive to install the drivers for Windows and restart the computer.
@iripuga
Copy link

iripuga commented May 1, 2021

Best tutorial ever, clear and straigthforward. Thank you so much 🙌

@PapiDragon99
Copy link

Problem!
It shows the windows screen then restarts the PC I have successfully done this previously without this problems but one day it wouldnt let me log in so now im redoing it had it doesnt work help!

@WisdomSky
Copy link

Works great! Thank you!

@grmon
Copy link

grmon commented Nov 19, 2021

I used this awesome read me to start my external Windows again in Box, but now I get following error messages:
Kernel driver not installed (rc=-1908)
Can anyone help?

@leonardola
Copy link

If you are getting a GPT type error when trying to install just check the UEFI option under setting > System. Then start the vm again. When the shell shows up type exit. Select boot manager > DVD/CD and there you go

@evilsneer
Copy link

Completely uninstall Intel Power Gadget, how described here https://forums.virtualbox.org/viewtopic.php?f=8&t=97482&p=473865#p474964, helps me to start windows install at least

@ryee-dev
Copy link

Hey guys sorry, quick question. Is an external hard drive mandatory or is this possible to do on a separate partition on the internal ssd?

@robotman3000
Copy link

@grmon I also had this issue. I fixed it by updating to the latest version of VirtualBox (6.1.28 -> 6.1.32) and by allowing the VirtualBox system extension in System Preferences > Security & Privacy > General. I think the extension/kernel driver was disabled after my update to macOS 12 from 11.

@mwy912
Copy link

mwy912 commented Apr 16, 2022

Thank you so much for this tutorial! I was nervous about trying to make an external boot camp drive after reading some other how-tos on the web, but your guide is very straightforward and made it (dare I say?) easy! You saved me $50 from buying an app to do this as well, so double thanks! :-)

@dariusakafest
Copy link

@tap52384 Hello! After installing i have error a blue screen with error INACCESSIBLE_BOOT_DEVICE. Don't understand that, can you help me please solve it?

@Nikdro
Copy link

Nikdro commented Aug 23, 2022

@tap52384 Thank you very much! After some other tutorials, which where not working as expected, you gave me the perfect guide for a quick success and saved my night! <3

Hint for everybody getting a Blue-Screen with Error-Code "BUGCODE_USB3_DRIVER". This happend to me, because I connected my SSD-Drive via USB-C. Switching cabel to a USB-A -> USB-C Adapter solved my problem. Seems that the Bios of my iMac isn't able to boot on USB-C.

@tap52384
Copy link
Author

@tap52384 Thank you very much! After some other tutorials, which where not working as expected, you gave me the perfect guide for a quick success and saved my night! <3

Hint for everybody getting a Blue-Screen with Error-Code "BUGCODE_USB3_DRIVER". This happend to me, because I connected my SSD-Drive via USB-C. Switching cabel to a USB-A -> USB-C Adapter solved my problem. Seems that the Bios of my iMac isn't able to boot on USB-C.

Wow, thank you very much! I haven’t had a chance to update this guide in a while because I don’t have a mac at the moment. Waiting for the M2 MacBook Pro. Glad this helped.

@xukai92
Copy link

xukai92 commented Sep 20, 2022

Best guide ever.
I managed to do this on my MacBook Pro (15-inch, 2018) with macOS version 12.5.1.
The only difference I made is that, in addition to use the Startup Security Utility to allow booting from external devices, I also had to allow it boot from undetected OS.
Otherwise everything is consistent with this guide.

@mr-mister-bit
Copy link

Help After I start - Start the virtual machine, I get: - bootcamp.vmdk' in read-write mode (VERR_RESOURCE_BUSY).

@pauljcg
Copy link

pauljcg commented Mar 24, 2023

Help After I start - Start the virtual machine, I get: - bootcamp.vmdk' in read-write mode (VERR_RESOURCE_BUSY).

Try diskutil unmountDisk /dev/disk2 before starting Virtual Box.

@DorisPerfect
Copy link

DorisPerfect commented Apr 8, 2023

I'm stuck. Running VBox 7.0.6 on Ventura 13.3.1 on 2018 Mac mini. Setting up the VM goes smoothly, but when I start the VBox (using SUDO) I get the "WIN10 [Running]" window, but nothing happens. The window is black and the Windows installer just doesn't start. There are no error messages. Note the BOOTCAMP drive is unmounted. Have deleted the VM and its files and started over again several times, but always the same result. Have tried Windows 10 21H2 and 22H2 ISOs with same result.

In Terminal, after starting the VM, the last line shown is: "2023-04-08 16:23:32.336 VirtualBox[1059:16617] +[CATransaction synchronize] called within transaction"

UPDATE: Finally got the installation to start by using all the default settings in VBox except for storage (the iso and the vmdk file).

UPDATE: After installation the external drive is Untitled, and it does not boot. There is an NTSF system reserved partition and the main partition where the windows files are installed:

Screenshot 2023-04-08 at 6 35 15 pm

What happens is that to install windows I have to delete all partitions - including the EFI/GPT partition - and the installer then creates a MBR partition from which the Mac cannot boot.

Using another Windows PC and MBR2GPT (https://learn.microsoft.com/en-us/windows/deployment/mbr-to-gpt) I converted the MBR to GPT and ext HDD then booted but only on a 2015 MacBook Pro, not the 2018 Mac mini.

@DorisPerfect
Copy link

For others struggling with this:

After more research I stumbled on this method which requires no third party tools at all, but simply uses Windows command line tools (diskpart). I used this method to install Windows 10 in a new partition on an external SSD which also had a bootable macOS partition (Mojave).

The details are given in the Answer here: https://apple.stackexchange.com/questions/384355/drivers-not-working-on-windows-10-installed-cli-process-on-external-ssd-runnin

A word of caution though: DO NOT blindly follow the steps in using diskpart. You must adapt that to the partitions that exist (if any) on your target volume.

It's a bit tedious to type all the long cmd text - but it works like a charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment