Skip to content

Instantly share code, notes, and snippets.

@hitorilabs
Forked from hungneox/WIN10.MD
Last active June 26, 2024 03:34
Show Gist options
  • Save hitorilabs/9c18b1a4fa8f561399db91f2b974eba8 to your computer and use it in GitHub Desktop.
Save hitorilabs/9c18b1a4fa8f561399db91f2b974eba8 to your computer and use it in GitHub Desktop.
Install Windows 11 From A Bootable USB (macos)

Personally, I prefer installing operating systems from a USB stick, so here's a tutorial

TL;DR

If you already have some idea of what's going on:

  1. Download the ISO from Microsoft - https://www.microsoft.com/en-ca/software-download/windows11
  2. Erase USB device and format in MS-DOS/FAT32
diskutil eraseDisk MS-DOS "WINDOWS11" MBR /dev/diskX
  1. Copy all files over to the USB device except install.wim
rsync -vha --exclude=sources/install.wim /Volumes/CCCOMA_X64FRE_EN-US_DV9/* /Volumes/WINDOWS11
  1. Split up the install.wim file into FAT32 sized chunks (try wimlib)
wimlib-imagex split /Volumes/CCCOMA_X64FRE_EN-US_DV9/sources/install.wim /Volumes/WINDOWS11/sources/install.swm 3800

Spelled-out Guide

Step 1: Download the Windows 11 ISO file

You can download the official ISO file from Microsoft directly

currently found here - https://www.microsoft.com/en-ca/software-download/windows11

As a brief primer - the .iso extension represents a disk image. In this case, it contains a collection of data/files that are required to "boot" the Windows 11 OS.

Once you've downloaded the file (probably looks something like this - Win11_22H2_English_x64v2.iso) you want to open it up. If you take a look inside (using du - Disk Usage), you'll see that the largest file is under /Volumes/CCCOMA_X64FRE_EN-US_DV9/sources

bocchi@hitorilabs ~ $ du -hs /Volumes/CCCOMA_X64FRE_EN-US_DV9/*
2.0K	/Volumes/CCCOMA_X64FRE_EN-US_DV9/autorun.inf
 18M	/Volumes/CCCOMA_X64FRE_EN-US_DV9/boot
432K	/Volumes/CCCOMA_X64FRE_EN-US_DV9/bootmgr
2.4M	/Volumes/CCCOMA_X64FRE_EN-US_DV9/bootmgr.efi
 23M	/Volumes/CCCOMA_X64FRE_EN-US_DV9/efi
 94K	/Volumes/CCCOMA_X64FRE_EN-US_DV9/setup.exe
5.4G	/Volumes/CCCOMA_X64FRE_EN-US_DV9/sources
448K	/Volumes/CCCOMA_X64FRE_EN-US_DV9/support

Look inside that sources directory and see that there's a huge file install.wim that contains the main contents of Windows 11.

bocchi@hitorilabs ~ $ du -hs /Volumes/CCCOMA_X64FRE_EN-US_DV9/sources/* | grep install.wim
4.7G	/Volumes/CCCOMA_X64FRE_EN-US_DV9/sources/install.wim

Note: .wim is an extension representing a "Windows Image" file which is some compressed representation of the data.

Step 2: Insert your USB storage drive into your Mac

First, check for the location of the USB we plugged in using diskutil.

You will see something like this:

bocchi@hitorilabs ~ $ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   ...

/dev/disk3 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +994.7 GB   disk3
   ...

/dev/disk4 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *30.8 GB    disk4
   1:                 DOS_FAT_32 WINDOWS11               30.8 GB    disk4s1

/dev/disk5 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            CCCOMA_X64FRE_EN-US... +5.8 GB     disk5

It's obvious here that /dev/disk4 ended up being my USB device since I already have Windows 11 installed and formatted, but you want to make sure you know which device is actually your USB so that you don't accidentally wipe your own system.

You can pretty much expect that devices /dev/disk{1..3} are all internal and the next ones are external disks - otherwise, it's usually easy to tell just by the SIZE of your USB storage. (i.e. /dev/disk5 is the .iso file or "disk image" you opened up earlier now visible under/Volumes/CCCOMA_X64FRE_EN-US_DV9)

Step 3: Erase and Reformat Your USB Device

In order to make a bootable drive, the USB device should be formatted in FAT32/MS-DOS by running the following command:

bocchi@hitorilabs ~ $ diskutil eraseDisk MS-DOS "WINDOWS11" MBR /dev/disk4

For some definitions of options we're specifying:

Step 4: Copy All Files Over To The Device

From the wiki page about FAT32, you'll see

The maximal possible size for a file on a FAT32 volume is 4 GB minus 1 byte, or 4,294,967,295 (232 − 1) bytes.

Unfortunately, we can't just dump the contents of the .iso file directly into this device yet because of the 4.7GB install.wim file. (no idea why they would ship the files over like this if they knew this would happen)

For now, we're going to copy every file from the ISO file /Volumes/CCCOMA_X64FRE_EN-US_DV9 over to /Volumes/WINDOWS11 except for install.wim (I prefer to use rsync)

bocchi@hitorilabs ~ $ rsync -vha --exclude=sources/install.wim /Volumes/CCCOMA_X64FRE_EN-US_DV9/* /Volumes/WINDOWS11

Step 5: Split install.wim Into FAT32 Chunks

It's pretty standard on macos to have homebrew installed. If you don't already have it, install it at https://brew.sh.

Since most people probably never looked into the .wim Windows Image file format, we're going to use a tool off the shelf called wimlib to do the splitting.

brew install wimlib

Here we're splitting the file from /Volumes/CCCOMA_X64FRE_EN-US_DV9/sources/install.wim into 3.8GB chunks (to fit comfortably under MS-DOS/FAT32 limits) into the device location /Volumes/WINDOWS11/sources/install.swm

bocchi@hitorilabs ~ $ wimlib-imagex split /Volumes/CCCOMA_X64FRE_EN-US_DV9/sources/install.wim /Volumes/WINDOWS11/sources/install.swm 3800

Now you're actually done - that's all there is to it. Unmount the USB device and it should be detected as a bootable device in the UEFI/BIOS of your PC.

Author's Note

Normally, I wouldn't make a tutorial like this because anyone who's clicking on gists and knows their way around a shell environment probably doesn't need that much hand-holding - but I found it surprisingly difficult for someone who has some technical understanding.

Creating a bootable USB for a linux operating system is trivial if you've ever gone through the arch wiki (https://wiki.archlinux.org/title/USB_flash_installation_medium), but the same cannot be said for this.

@hitorilabs
Copy link
Author

hitorilabs commented Sep 4, 2023

I forked the original guide because:

  1. It doesn't actually work because install.wim goes over the FAT32 limit - ExFAT is usually not bootable
  2. Any audience using the terminal is already somewhat technical, but probably never looked into macos utilties
  3. No one should be running random commands without understanding the risks and how data/devices are laid out in memory

@TechUnRestricted
Copy link

TechUnRestricted commented Apr 13, 2024

It's a really good guide. Thanks for it!
But can I present my own utility that automates this process? It's completely free and open source.

It uses wimlib library directly under the hood if required (e.g. if install.wim is over ~4GB).
It's called WinDiskWriter.

WinDiskWriter supports a variety of Windows versions like:

  • Windows 11
  • Windows 10
  • Windows 8.1
  • Windows 8
  • Windows 7
  • Windows Vista

— Both UEFI and Legacy boot modes.
(Legacy boot mode support is available thank to grub4dos)

— 64-bit and 32-bit images.

Also it has some cool features such as patching Windows 11 installer for removing the TPM & Secure Boot requirements.

So, it's like Rufus, but for macOS.

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