Skip to content

Instantly share code, notes, and snippets.

@acarril
Created November 18, 2022 17:49
Show Gist options
  • Save acarril/8c15f600cf0397dd61161a470f50f669 to your computer and use it in GitHub Desktop.
Save acarril/8c15f600cf0397dd61161a470f50f669 to your computer and use it in GitHub Desktop.
Create a bootable Windows USB using macOS

For some reason, it is surprisingly hard to create a bootable Windows USB using macOS. These are my steps for doing so, which have worked for me in macOS Monterey (12.6.1) for Windows 10 and 11. After following these steps, you should have a bootable Windows USB drive.

1. Download a Windows disc image (i.e. ISO file)

You can download Windows 10 or Windows 11 directly from Microsoft.

2. Identify your USB drive

After plugging the drive to your machine, identify the name of the USB device using diskutil list, which should return an output like the one below. In my case, the correct disk name is disk2.

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.3 GB   disk0
   1:                        EFI EFI                     314.6 MB   disk0s1
   2:                 Apple_APFS Container disk1         500.0 GB   disk0s2

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +500.0 GB   disk1
                                 Physical Store disk0s2
   1:                APFS Volume MacHDD - Data           180.3 GB   disk1s1
   2:                APFS Volume MacHDD                  15.4 GB    disk1s2
   3:              APFS Snapshot com.apple.os.update-... 15.4 GB    disk1s2s1
   4:                APFS Volume Preboot                 481.8 MB   disk1s3
   5:                APFS Volume Recovery                1.1 GB     disk1s4
   6:                APFS Volume VM                      1.1 GB     disk1s5

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *15.5 GB    disk2
   1:                 DOS_FAT_32 WINDOWS10               15.5 GB    disk2s1

3. Format USB drive

Format the drive with the following command, substituting disk2 with whatever is the one that corresponds in your machine.

diskutil eraseDisk MS-DOS "WINDOWS10" MBR disk2

4. Mount the Windows ISO and check its size

Mount the ISO file in your system (usually by simply double-clicking it), and verify it's listed in /Volumes—the disk name usually starts with CCCOMA_. With the disk mounted, check the size of the sources/install.wim file with the following command:

ls -lh /Volumes/CCCOMA_X64FRE_EN-US_DV9/sources/install.wim

5. Copy (almost) all files to USB drive

If sources/install.wim is less than 4GB in size, you can copy all the files from the mounted disk image onto the USB drive with the following command (notice the trailing slash in the first path!):

rsync -avh --progress /Volumes/CCCOMA_X64FRE_EN-US_DV9/ /Volumes/WINDOWS10

If sources/install.wim is more than 4GB, then we'll need to split the file before copying it. In the meantime, we can copy all the other files from the mounted image onto the USB drive with the following command (again, notice the trailing slash in the first path!):

rsync -avh --progress --exclude=sources/install.wim /Volumes/CCCOMA_X64FRE_EN-US_DV9/ /Volumes/WINDOWS10

6. Use wimlib to split and copy sources/install.wim

If sources/install.wim is more than 4GB, it is too large to copy onto a FAT32-formatted drive. Microsoft's official solution is to split the file, and there is a free utility available in macOS and Linux to do so—wimlib. The tool can be installed with Homebrew:

brew install wimlib

After installing wimlib, split and copy sources/install.wim using the following command:

wimlib-imagex split /Volumes/CCCOMA_X64FRE_EN-US_DV9/sources/install.wim /Volumes/WINDOWS10/sources/install.swm 3800

Here, 3800 means that the file should be split in 3,800MB chunks.

@karthike72
Copy link

Actually worked for me just following above commands.. good job.. and beware of wonder iso and any other spammers there... they just cheat right infront of you

@maanisim
Copy link

$ wimlib-imagex split /Volumes/CCCOMA_X64FRE_EN-GB_DV9/sources/install.wim /Volumes/WINDOWS10/sources/install.swm 3800
[ERROR] Failed to open "/Volumes/WINDOWS10/sources/install.swm" for writing: No such file or directory
ERROR: Exiting with error code 47:
       Failed to open a file.
(base) 

$ ls /Volumes/WINDOWS10/sources
ls: /Volumes/WINDOWS10/sources: No such file or directory
(base)

The magical command for when using a split:

$ mkdir /Volumes/WINDOWS10/sources

@elliolir
Copy link

@masonduug it's not flagged by apple, that's the default warning you get when the app isn't signed with apple dev keys.
@TechUnRestricted thanks, worked perfect for me ✨✨✨

I find you are a scam, slandering your competitors everywhere, how rude! WonderISO is a good software, why do you want to discredit it?

Sorry you felt that way, a freshly-registered github member with no other online presence 😢

@j-j-j-jim
Copy link

@TechUnRestricted I wanted to drop a comment and thank you for this utility. I spent an entire day trying anything and everything on Mac and Linux trying to get a Win 10 PC going, and this was the only thing that worked.

@r2axz
Copy link

r2axz commented Jul 25, 2024

In today's world, it's probably better to use GPT instead of MBR when partitioning USB drives. At least, this option should be mentioned. Newer PCs tend to use UEFI by default and while it's usually possible to enable the legacy boot mode, it's just easier to create a GUID Partition Table in the first place. So

diskutil eraseDisk MS-DOS "WINDOWS10" GPT disk2

might be a preferable way to go.

@amka66
Copy link

amka66 commented Aug 5, 2024

Thanks, worked for me when installing Win 11 (including wimlib split part)

@lxnk
Copy link

lxnk commented Aug 6, 2024

Important remark concerning installing wimlib with brew. On Mojave 10.14.X onwards it throws an error Permission denied @ apply2files and suggests to use sudo. It is generally a bad idea, while Error: Running Homebrew as root is extremely dangerous and no longer supported.

The fix is sudo chown -R $(whoami):admin /usr/local/* && sudo chmod -R g+rwx /usr/local/*.

It solved the problem in my case.

Source: https://stackoverflow.com/questions/61899041/macos-permission-denied-apply2files-usr-local-lib-node-modules-expo-cli-n

@anhtuank7c
Copy link

Thank you so much @acarril

@BlakeGardner
Copy link

works great thanks @acarril

@vprimin
Copy link

vprimin commented Aug 11, 2024

Working for me as well. Thanks for the author!

@mcfedr
Copy link

mcfedr commented Aug 14, 2024

I found i need to use the export command to make the wim file not 'solid'

wimlib-imagex export /Volumes/CCCOMA_X64FRE_EN-US_DV9/sources/install.wim all tmp-install.wim --compress=LZX:1

and the use tmp-install.wim as the source to split command

@tanaymondal
Copy link

It worked. Thanks for the author!

@Chalayyy
Copy link

Chalayyy commented Aug 31, 2024

Works perfectly, even for older versions of Windows! Thank you!
This is the archived iso I used for this process (Windows 8.1).

@matyax
Copy link

matyax commented Sep 7, 2024

Not the hero we deserve, but the hero we need.

@JoeyEJones
Copy link

JoeyEJones commented Sep 24, 2024

Hello,

When I try this the SWM files are not visible in cmd.exe when I boot up the USB. I'm attempting to repair an existing installation with this USB and I can see the SWM files in Finder on my Macbook but they aren't visible on the windows machine. I followed every step in the tutorial. What am I missing after step 6 please to make these files show up?

@matyax
Copy link

matyax commented Oct 1, 2024

It doesn't work. I had to create one from an actual Windows machine, otherwise it doesnt boot.

@mikbor
Copy link

mikbor commented Oct 4, 2024

Thank you! Unfortunately my PC is really old and doesn't support UEFI. The USB won't boot. Any ideas how to adjust the steps to make it compatible with older PCs?

@gregorioosorio
Copy link

Thanks! It makes sense. I think there is a typo in the last command, it should be install.wim instead of install.swm, anyway thanks for your help!

@gregorioosorio
Copy link

OK, I see the extension swm is needed when split the files...

@recrof
Copy link

recrof commented Oct 11, 2024

@masonduug nope, that's not "flagged by apple", it just means developer did not pay apple app certificate.

@fuzulus
Copy link

fuzulus commented Oct 11, 2024

As mentioned in the earlier comments, you have to run mkdir -p /Volumes/WINDOWS10/sources.

I also had to do a mv /Volumes/WINDOWS10/CCCOMA_X64FRE_EN-GB_DV9/* . because the files were copied inside the dir instead of the root of the USB.

Also had to use legacy boot to get this to work.

Thank you author, this one saved the day for me! 😁

@nielsdevos19
Copy link

nielsdevos19 commented Oct 13, 2024

After a wasting a whole Sunday trying to make a bootable windows usb with all kinds of methods without success I found this method. It worked like a charm for me. I was worried that my usb flash 128gb 150m/s (15 euro) would not be good enough and need to buy a more expensive SSD. I use it only for 1 program (solidworks) and it works fine! Altough if I would have known it would take this much time I would have invested mor bucks for a real extern ssd with 500m/s speed.

Thank you so much for taking the effort to share these steps.

My system is iMac 2012.

@diafour
Copy link

diafour commented Oct 26, 2024

Thanks! Everything works on UEFI mb. Even without bootsector!

@bluegroper
Copy link


The magical command for when using a split:

$ mkdir /Volumes/WINDOWS10/sources

It seems the .../sources directory is already created by rsync command in Step 5 above.
Is that correct, or did I miss something important ?

@emanuelcosta-dev
Copy link

Just followed the instructions from start to finish and It worked perfectly. Thanks for making this!

@keedhost
Copy link

WinDiskWriter might be a malware and flagged by Apple.

093347

This will fix the issue:

sudo xattr -r -c  /Applications/WinDiskWriter.app

@nzjc
Copy link

nzjc commented Oct 28, 2024

this gist is the only thing that worked for me for win11. thanks!

@caiodv
Copy link

caiodv commented Nov 2, 2024

This saved my life, I spent a whole saturday trying to get windows installed thinking the issue was some bios setting (all I've found through google said so) and this was it, can't believe it was the way I set up the bootable usb

@diafour
Copy link

diafour commented Nov 3, 2024

@bluegroper Missing "sources" directory may be one of 2 things: either split performed before rsync, or a missing slash in the rsync command.

@Alexwi1son
Copy link

Alexwi1son commented Nov 14, 2024

This trick worked on my Intel MacBook Pro (i7 and 16GB RAM) on year ago. However, unable to get the splitting process finished on my new MacBook Air M3. Not sure what the problem is. Fortunately, I managed to create a Windows 11 bootable USB with the top ranked reply from Apple tech community:

https://discussions.apple.com/thread/255200443?sortBy=rank

If you had the same issue as me, I suggest giving it a try. No command prompt and less waiting time (~20 mins).

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