Skip to content

Instantly share code, notes, and snippets.

@PeqNP
Last active January 15, 2021 18:52
Show Gist options
  • Save PeqNP/051e110d085928411d41783b1e5838bc to your computer and use it in GitHub Desktop.
Save PeqNP/051e110d085928411d41783b1e5838bc to your computer and use it in GitHub Desktop.
Create a bootable USB drive for Windows 10
#!/usr/bin/bash
#
# Create a bootable USB drive for Windows 10.
#
# This script is designed to be instructional and NOT to be ran. You may replace
# `diskN` and volume name for the Windows 10 ISO and it _should_ work. But I
# haven't tested this script.
#
# Download the respective Windows 10 ISO.
# Current location: https://www.microsoft.com/en-us/software-download/windows10ISO
#
# I had to download the latest version of the Windows 10 ISO in order for
# this to work. An ISO I had downloaded a few months prior did not work and
# failed during installation saying that the setup files were corrupted.
#
# If you are on Apple silicon, prepend 'arch -x86_64 ' in front of the `brew install`
# and `wimlib-imagex` commands.
#
# Copyright: 2020 Bithead LLC (http://www.bitheadstudios.com)
# LICENSE: MIT
#
# Install required tools to split the install.wim file
brew install wimlib
# Mount the Windows 10 ISO. This can be done by double tapping the IOS
# from within Finder.
# Find the USB's respective disk
diskutil list
# Format the USB disk where `diskN` is the respective disk (e.g. /dev/disk4)
# This formats the USB drive as FAT32 with the name 'Windows 10'.
diskutil eraseDisk MS-DOS "WINDOWS10" MBR diskN
# Copy all files except the install.wim. You may need to change the name of the
# Windows 10 ISO volume.
rsync -vha --exclude=sources/install.wim /Volumes/CCCOMA_X64FRE_EN-US_DV9/* /Volumes/WINDOWS10
# Split the install.wim file. Per Microsoft's official instructions, having
# the extension of 'swm' is OK.
wimlib-imagex split /Volumes/CCCOMA_X64FRE_EN-US_DV9/sources/install.wim /Volumes/WIN10/sources/install.swm 3800
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment