How-to create bootable Windows usb flash on MacOS

How-to create bootable Windows usb flash on MacOS

First see what disks you have on your MacOS

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

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +500.1 GB   disk1
                                 Physical Store disk0s2
   1:                APFS Volume Macintosh HD - Data     208.3 GB   disk1s1
   2:                APFS Volume Preboot                 1.5 GB     disk1s2
   3:                APFS Volume Recovery                1.1 GB     disk1s3
   4:                APFS Volume VM                      2.1 GB     disk1s4
   5:                APFS Volume Macintosh HD            15.4 GB    disk1s5
   6:              APFS Snapshot com.apple.os.update-... 15.4 GB    disk1s5s1

Then insert your USB flash disk and see what is changed executing above command again:

diskutil list

Imagine that new disk is received device named disk2. Now it's time to format the usb flash drive - my recommendations is your target windows computer is older machine to use mbr partitions. To do this use command:

 % sudo diskutil eraseDisk FAT32 "WIN10" MBRFormat /dev/disk2
Started erase on disk2 (CCCOMA_X64FRE_BG-BG_DV9)
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Formatting disk2s1 as MS-DOS (FAT32) with name WIN10
512 bytes per physical sector
/dev/rdisk2s1: 60597312 sectors in 1893666 FAT32 clusters (16384 bytes/cluster)
bps=512 spc=32 res=32 nft=2 mid=0xf8 spt=32 hds=255 hid=2048 drv=0x80 bsec=60626944 bspf=14795 rdcl=2 infs=1 bkbs=6
Mounting disk
Finished erase on disk2

Then you must download and install on your computer unetbootin. Using it we will write *.iso file to the USB disk.

Here is the trickiest part, because on FAT32 filesystem maximum file size is 4G but actually file named install.wim which typically is biggest. So you must split it in pieces. Because this is special Microsoft archive file format, you need special application to do this. Download source of wimlib and uncompress it. Then build and install it using this:

% ./configure --without-ntfs-3g
% make
% sudo make install

Now you can do the following:

% wimlib-imagex split /Volumes/CCCOMA_X64FRE_BG-BG_DV9/sources/install.wim  /Volumes/WIN10/sources/install.swm 4000
Splitting WIM: 4614 MiB of 4614 MiB (100%) written, part 2 of 2
Finished splitting "/Volumes/CCCOMA_X64FRE_BG-BG_DV9/sources/install.wim"

% rm /Volumes/WIN10/sources/install.wim

That's all!

Share with Me via Nextcloud