Skip to content

Instantly share code, notes, and snippets.

@mikaelvesavuori
Last active April 24, 2024 09:11
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mikaelvesavuori/649e04abac45d4ecd5a063f53c304615 to your computer and use it in GitHub Desktop.
Save mikaelvesavuori/649e04abac45d4ecd5a063f53c304615 to your computer and use it in GitHub Desktop.
Create a bootable Windows 10 USB stick from Mac Terminal (Bash)

Create a bootable Windows 10 USB stick from Mac Terminal (Bash)

Disclosure: These steps (at least for me) worked until it was time to actually install the files, in the Windows installer. This may be a configuration or hardware issue, but I am not totally sure.

This will help you set up a boot drive to install Windows 10, using a Mac. If you have a PC, this should be easier, using instructions at: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/install-windows-from-a-usb-flash-drive

Assumptions

  • You will use a US version of Windows 10 (if not, then you may need to change the variables a bit)
  • You have a detachable USB device (minimum 5GB)

Prerequisites

  1. Get a Windows 10 ISO file from: https://www.microsoft.com/en-gb/software-download/windows10ISO
  2. Install Homebrew if you don't have it: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  3. Install wimlib (which allows splitting the big WIM file, included in ISO): brew install wimlib
  4. Get a key; there is a grey market for OEM keys, for example Kinguin: https://www.kinguin.net/category/19429/windows-10-professional-oem-key
  5. Plug in your USB device (minimum 5GB)
  6. Ensure the below variables are correct; you can of course export them as you go, and as you get to see the values
export DISK_NAME=/dev/disk2
export ISO_NAME=Win10_2004_V1_English_x64.iso
export VOLUME_NAME=CCCOMA_X64FRE_EN-US_DV9

Steps in Terminal (do these manually in order!)

  • List devices: diskutil list
  • diskutil eraseDisk MS-DOS "WIN10" GPT $DISK_NAME; Absolutely ensure this is correct from your diskutil list command!
  • hdiutil mount ~/Downloads/$ISO_NAME
  • rsync -vha --exclude=sources/install.wim /Volumes/$VOLUME_NAME/ /Volumes/WIN10
  • mkdir /Volumes/WIN10/sources
  • wimlib-imagex split /Volumes/$VOLUME_NAME/sources/install.wim /Volumes/WIN10/sources/install.swm 4000

References

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