Skip to content

Instantly share code, notes, and snippets.

@tap52384
Last active Nov 19, 2021
Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@iripuga iripuga commented May 1, 2021

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

@PapiDragon99

This comment has been minimized.

Copy link

@PapiDragon99 PapiDragon99 commented May 27, 2021

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

This comment has been minimized.

Copy link

@WisdomSky WisdomSky commented Jun 18, 2021

Works great! Thank you!

@grmon

This comment has been minimized.

Copy link

@grmon 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?

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