-
-
Save ryanmaclean/13ed63bf5e56a8af7786ba03da5f927c to your computer and use it in GitHub Desktop.
Create a Bootable UEFI Windows USB stick from an ISO on Apple macOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Just a quick update for GPT and to use `rsync` instead of `cp`! | |
# That means this applies to UEFI boot, though for legacy BIOD boot, feel free to swap | |
# GPT to MBR below. | |
# Requires https://homebrew.sh to split the install.wim file | |
brew install wimlib | |
# First, we need to find our device. BEFORE inserting your USB drive, run the | |
# following: | |
diskutil list | |
# This will output a bunch of info about all of the disk drives connected to | |
# your Mac. Each entry will have a header in the form "/dev/diskX", where X is | |
# some number starting at 0. Now, insert your USB drive and run the command | |
# again. You should see a new entry. Make note of the name (ie, /dev/diskX). | |
echo "TIME TO PLUG IN YOUR USB STICK! YOU HAVE 30 SECONDS!" | |
sleep 30 | |
diskutil list | |
# Now we need to format the drive for MS-DOS and include a Master Boot Record. | |
# In the command below, replace "diskX" with the identifier of your USB drive. | |
# WARNING: this will delete everything on the USB! If you've got nothing else inserted | |
# it's probably disk2... but you've been warned! | |
diskutil eraseDisk MS-DOS WIN10 GPT diskX | |
# In the command above, MS-DOS is the format of the partition that will be | |
# created on the USB. WIN10 is the name of that partition (it'll appear in | |
# Finder as the name of your USB). MBR tells diskutil to create a Master Boot | |
# Record, which is necessary for the USB to be bootable. | |
# | |
# Now, "open" the Windows ISO (assumes you've only got one downloaded :P ): | |
open ~/Downloads/Win10*.iso | |
# Your Mac will "mount" the ISO as if it was a drive. A Finder window will open | |
# to show the contents of the ISO. Close the Finder window; you don't need it. | |
# You should see a new entry. This time, we're looking for what's in the NAME | |
# column. You should see something funny like CCCOMA_X64FRE_EN-US_DV9 (free download from Micrososft.com. | |
# The name may differ depending on which ISO you downloaded. | |
# And copy all the files other than `install.wim` over to our USB drive: | |
sudo rsync -avh \ | |
--progress \ | |
--exclude=sources/install.wim /Volumes/CCCOMA_X64FRE_EN-US_DV9/ /Volumes/WIN10 | |
# This will take a while; there's a lot of data. Grab a drink; relax. | |
# Split the WIM to an SWM file in the destination | |
wimlib-imagex split /Volumes/CCCOMA_X64FRE_EN-US_DV9/sources/install.wim /Volumes/WIN10/sources/install.swm 3800 | |
# Once it's done, you can eject both the USB and the ISO. First, cd to another | |
# directory otherwise OSX will not allow you to unmount the ISO (since being in | |
# the directory means the ISO is "in use"): | |
cd ~ | |
# Eject the USB using the diskX (probably disk4 at this point): | |
diskutil list | grep CCC | |
diskutil eject /dev/disk4 | |
# Eject the ISO using the diskX identifier from the fifth step above: | |
diskutil eject WIN10 --force | |
# Now insert the USB into your computer, (re)boot, and select the USB from the | |
# boot device menu (you may need to press some key to show the boot device menu | |
# - on my machine it's F12). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment