Skip to content

Instantly share code, notes, and snippets.

@b23prodtm
Last active November 1, 2021 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b23prodtm/e528752310304f083e4ecd62083a4ba5 to your computer and use it in GitHub Desktop.
Save b23prodtm/e528752310304f083e4ecd62083a4ba5 to your computer and use it in GitHub Desktop.
Creating a Windows 10 USB Installer using macOS in 2020 - How to Make a Windows 10 USB Using Your Mac - Build a Bootable ISO From Your Mac's Terminal
#!/usr/bin/env bash
set -u
WIN_VOLUME=
DRIVE_NAME=
echo "
_.-;;-._
'-..-'| || |
'-..-'|_.-;;-._|
'-..-'| || |
jgs '-..-'|_.-''-._|"
printf "\n"
printf " Create a Windows 10 USB Installer\n"
printf " using macOS \n"
printf "===================================\n"
printf "(source: https://evanshortiss.com/create-a-windows-install-usb-via-macos)\n"
printf "\n"
sleep 3
if [ -z $(command -v wimlib-imagex) ]; then printf "Please run command brew install wimlib\n"; exit 0; fi
while [ -z $WIN_VOLUME ]; do
read -rp "What's name of the USB Drive Volume? " READ_TMP
if [ ! -d "/Volumes/$READ_TMP" ]; then printf "Drive not found\n"; else
WIN_VOLUME="$READ_TMP"
fi
done
while [ -z $DRIVE_NAME ]; do
read -rp "What's name of the image ISO Volume? " READ_TMP
if [ ! -d "/Volumes/$READ_TMP" ]; then printf "Drive not found\n"; else
DRIVE_NAME="$READ_TMP"
fi
done
printf "Now copying from %s to /Volumes/%s...\n" $WIN_VOLUME $DRIVE_NAME
sleep 2
#rsync -vha --exclude=sources/install.wim "/Volumes/$WIN_VOLUME"/* "/Volumes/$DRIVE_NAME"
printf "Adding install.wim...\n"
sleep 2
# FIXME wimlib failed but that's incompatible with FAT32 storage format
if [ ! $(wimlib-imagex split "/Volumes/$WIN_VOLUME/sources/install.wim" "/Volumes/$DRIVE_NAME/sources/install.swm" 4000) ]; then
rsync -vha "/Volumes/$WIN_VOLUME/sources/install.wim" "/Volumes/$DRIVE_NAME/sources/install.wim"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment