A simple Go script to automate creating a bootable Windows 11 USB drive on macOS (Apple Silicon).
-
What it does
- Prompts for a Windows 11 ISO file on your machine.
- Lists and validates the target USB device.
- Formats the USB as FAT32 with a GPT partition scheme.
- Mounts the ISO and copies all files except
install.wim
. - Splits
install.wim
into multiple.swm
files so it fits on a FAT32 volume. - Unmounts/ejects both the ISO and USB.
-
Why use it
- Automates common manual steps (
diskutil
,hdiutil
,rsync
,wimlib-imagex
) - Ensures proper splitting of the large Windows install image for FAT32
- Reduces mistakes—fewer copy-&-paste shell commands
- Automates common manual steps (
- macOS running on Apple Silicon (M1, M2, etc.)
- Homebrew installed
- Install required tools:
brew install wimlib
-
Build the binary
go build -o win11-usb
-
Run the script
./win11-usb
-
Follow prompts
- Enter the full path to your Windows 11 ISO (e.g.,
~/Downloads/Win11.iso
) - Choose the USB device identifier (e.g.,
/dev/disk2
) - Confirm formatting (all data on the USB will be erased)
- Enter the full path to your Windows 11 ISO (e.g.,
-
Boot
- After “Success!”, eject and insert the USB into your target PC
- In BIOS/UEFI, select your USB in UEFI mode and install Windows 11
- The script assumes the formatted USB volume will be named
WINUSB
. - If your USB device name differs, adjust the
usbName
variable in the code. - Always back up any important data before formatting a drive.