Skip to content

Instantly share code, notes, and snippets.

@sorrell
Last active January 2, 2024 15:23
Show Gist options
  • Save sorrell/d8b6484185572ab89653bc7dcf68100f to your computer and use it in GitHub Desktop.
Save sorrell/d8b6484185572ab89653bc7dcf68100f to your computer and use it in GitHub Desktop.
Create Windows 11 USB boot disk
# List disks and update DISK_LOCATION to the correct disk
diskutil list
DISK_LOCATION="/dev/diskX"
DEVICE_NAME="WIN11"
ISO_LOCATION="$HOME/Downloads/Win11_23H2_English_x64.iso"
diskutil eraseDisk MS-DOS "$DEVICE_NAME" GPT $DISK_LOCATION
# Mount the ISO and copy the files to the USB
MOUNT_INFO=$(hdiutil mount $ISO_LOCATION)
VOL_NAME=$(echo "$MOUNT_INFO" | grep -o '/Volumes/[^ ]*' | awk -F'/Volumes/' '{print $2}')
rsync -vha --exclude=sources/install.wim /Volumes/$VOL_NAME/ /Volumes/$DEVICE_NAME
wimlib-imagex split /Volumes/$VOL_NAME/sources/install.wim /Volumes/$DEVICE_NAME/sources/install.swm 3800
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment