Contribute
Register

[Guide] How to create bootable Windows USB install media in macOS and Linux

Status
Not open for further replies.
Joined
Aug 2, 2015
Messages
237
Motherboard
Z97X-UD3H-BK
CPU
i7-4790k
Graphics
R9 270X
Mobile Phone
  1. Android
This guide will detail the procedure to create a bootable Windows installer on a USB flash drive from either platform. The resulting media will be bootable on any UEFI capable system which should be sufficient for the vast majority of computers in use today. It can optionally be made BIOS bootable for legacy systems/installations as detailed below if desired. Windows 10 is described here but these instructions are valid for Windows 7/8. This procedure is intended as a replacement for "How to create a bootable Windows 10 USB in OS X using Terminal" as the technique described there is relevant to Linux hybrid ISO files (see references) but is unlikely to produce bootable Windows media. Read carefully and download/install any required resources before attempting these procedures.

Download the Windows 10 ISO file and have an 8GB or larger USB flash drive ready. Be aware the USB drive will be wiped.

NOTE: Recent releases of Windows 10 contain a file (install.wim) larger than 4GBs requiring it to either be split to accommodate the 4GB maximum file size limitation of FAT32 or the drive to be formatted as exFAT. If using exFAT you will likely need to boot the Windows installer from Clover or OpenCore or use the UEFI_NTFS bootloader from Rufus unless your firmware has native UEFI boot support for exFAT (see last section for details). Legacy/BIOS booting is unaffected by filesystems and can boot directly.

macOS UEFI

Open Terminal and use "diskutil list" to identify your flash drive (example disk3 below) then prepare using one option below (FAT32 or exFAT).

drive list.png


FAT32:

Format as FAT32 with a single partition, mount the Windows ISO and copy all files except install.wim with rsync. Substitute the correct disk and Windows DVD path below.

sudo diskutil eraseDisk FAT32 "WINDOWS 10" MBR disk#
hdiutil attach /Path/to/Windows.iso (or double click the file)
rsync -avh --progress --exclude=sources/install.wim /Volumes/Windows_DVD_Label /Volumes/WINDOWS\ 10/

Now move the extracted files to the root of the flash drive.

Install wimlib with Homebrew or MacPorts and use wimsplit to divide and transfer the install.wim file.
wimsplit /Volumes/Windows_DVD_Label/sources/install.wim /Volumes/WINDOWS\ 10/sources/install.swm 3800

Finally unmount the Windows ISO file.
hdiutil detach disk# (or eject the virtual disk)

exFAT:

Format as exFAT with either a single partition (a) or two partitions if using UEFI_NTFS (b).

a. diskutil eraseDisk ExFAT "Windows 10" MBR disk#
b. diskutil partitionDisk disk# 2 MBR "MS-DOS FAT12" "UEFI_BOOT" 1M ExFAT "Windows 10" R

If using UEFI_NTFS download and mount the uefi-ntfs.img file.
hdiutil attach /path/to/uefi-ntfs.img (or double click the file)

Then copy the contents from UEFI_NTFS to the UEFI_BOOT partition.
cp -R /Volumes/UEFI_NTFS/* /Volumes/UEFI_BOOT/

Unmount the UEFI_NTFS disk image.
hdiutil detach /Volumes/UEFI_NTFS (or eject the virtual disk)

The UEFI_BOOT partition should appear as shown below:

uefibootusb-macos.png


Now copy the contents of the Windows ISO file to the flash drive. Either mount the ISO file and copy everything via Finder or it may be faster and more reliable to use an archive utility such as Keka or p7zip (command line tool from Homebrew or MacPorts) to extract the contents of the image as shown below.

7z x /path/to/Windows.iso -o/Volumes/Windows\ 10 (p7zip example)

Move extracted files to the root of the flash drive if needed.

macOS BIOS

Optional: for legacy/BIOS installation only.

Unmount the target flash drive.
diskutil unmountDisk disk#

Set the partition active with fdisk (exclude the single quotes).
sudo fdisk -e /dev/rdisk#

'p' - view partition table (Single partition #1 is assumed.)
'f 1' - flag partition 1 active
'q' - quit saving changes

Unmount the target drive again.
diskutil unmountDisk disk#

Install ms-sys utility linked below and write the appropriate partition boot record.
sudo ms-sys -8 /dev/disk#s# (FAT32 NT6.0 Partition Boot Record)
sudo ms-sys -x /dev/disk#s# (exFAT NT6.0 Partition Boot Record)

Now write the master boot record.
sudo ms-sys -7 /dev/disk# (Windows 7/8/10 Master Boot Record)

macOS Resources

FAT32 WIM file tools: wimlib
ISO Extraction tool: p7zip
Legacy Support: ms-sys
package managers: Homebrew MacPorts

When done, the install drive should appear as shown below:

win10usb-macos.png


Linux UEFI

Open Terminal and use lsblk to identify your flash drive (example /dev/sdb).
lsblk -f (Look for volume label and mount point)

block devices.png

Substitute the correct disk, flash drive and Windows DVD paths below.

Unmount and wipe the flash drive.
umount /media/username/usbdisk
sudo dd if=/dev/zero of=/dev/sdb bs=1M count=2

Use one partitioning scheme below.

Create one new FAT32 or exFAT partition with cfdisk.
sudo cfdisk /dev/sdb

Make the selections below:
label type: dos
[New] – Use max partition size (Enter).
[primary]
[Type] – W95 FAT32 (LBA) (c) or HPFS/NTFS/exFAT (7)
[Bootable] – Set legacy/BIOS bootable if desired
[Write] – Type "Yes" to save partition table then Enter
[Quit]

When formatted the partition info will resemble this:

cfdisk-partitions.png

If using UEFI_NTFS create two partitions with cfdisk.
sudo cfdisk /dev/sdb

select label type: dos
[New] – Partition size one megabyte (1M)
[Primary]
[Type] – FAT12 (1)
Select remaining free space.
[New] – Use max partition size. (Enter)
[Type] – HPFS/NTFS/exFAT (7)
[Write] – Type "Yes" to save partition table to disk
[Quit]

When formatted the partition info will resemble this:

cfdisk-FAT12-part.png


FAT32:

Format the partition.
sudo mkfs.fat -n "WINDOWS 10" /dev/sdb1

Now click on the flash drive and Windows 10 image file to mount both.

Copy all files except install.wim using rsync.
rsync -avh --progress --exclude=sources/install.wim /media/username/Windows_DVD_Label/ /media/username/Windows\ 10/

Now move the extracted files to the root of the flash drive.

Install wimtools/wimlib from your distribution’s package manager and use wimsplit to divide and transfer the install.wim file.
wimsplit /media/username/Windows_DVD_Label/sources/install.wim /media/username/Windows\ 10/sources/install.swm 3800

exFAT:

For a single partition format as shown below.
sudo mkexfatfs -n "Windows 10" /dev/sdb1 (requires exfat-fuse)

For UEFI_NTFS format as shown below.
sudo mkfs.fat -n "UEFI_BOOT" /dev/sdb1
sudo mkexfatfs -n "Windows 10" /dev/sdb2 (requires exfat-fuse)

Download the uefi-ntfs.img file and double click to mount then copy the contents from UEFI_NTFS to the UEFI_BOOT partition which should then appear as shown below.

uefibootusb-linux.png


Mount the flash drive if needed and Windows ISO file and copy the contents (for example with rsync) .
rsync -avh --progress /media/username/Windows_DVD_Label/ /media/username/Windows\ 10/

Or extract the contents to the flash drive using p7zip as shown below.
7z x /path/to/Windows10.iso -o/media/username/usbdisk (requires p7zip-full)

Move extracted files to the root of the flash drive if needed.

Linux BIOS

Optional: for legacy/BIOS installation only.

Unmount the target flash drive.
umount /Path/to/flash/drive

Install ms-sys utility linked below and write the appropriate partition boot record.
sudo ms-sys -8 -p /dev/sdb1 (FAT32 NT6.0 Partition Boot Record)
sudo ms-sys -x -p /dev/sdb1 (exFAT NT6.0 Partition Boot Record)

Now write the master boot record.
sudo ms-sys -7 /dev/sdb (Windows 7/8/10 Master Boot Record)

Linux Resources

FAT32 WIM file tools: wimtools/libwim
exFAT Support: exfat-fuse
ISO Extraction: p7zip-full
Legacy Support: ms-sys

When done, the install drive should appear as shown below:

win10usb-linux.png

exFAT UEFI Boot Support

If your system does not support UEFI booting from exFAT formatted media (no option on F12 menu) follow the instructions below to add support to Clover or OpenCore. Be aware however that booting Windows through OpenCore requires compatible ACPI patching that is beyond the scope of this guide.

Clover

Open Clover Configurator, mount the EFI partition, click Install Drivers then select GrubEXFAT filesystem driver under "DRIVERS BIOS 64 BIT" and click Download.

Clover Install Drivers.png


Open the EFI partition, browse to the EFI/CLOVER/drivers folder and move the GrubEXFAT.efi file from BIOS to UEFI.

exFAT BIOS.png
exFAT UEFI.png


Reboot and press F3 at the Clover boot menu to show hidden entries. Select "UEFI External from Windows 10" to boot the Windows installer.

Clover Boot Menu.png


OpenCore

Start OpenCore Configurator, mount the EFI partition, click UEFI - Drivers - Download/Update drivers then select ExFatDxe and click Download.

OC ExFatDxe.png


Add driver to the UEFI/Drivers section.

OC UEFI Drivers.png


Reboot and select "Windows (external)" from the text menu

OC Text Menu.png


or the "Windows" external disk icon from the OpenCanopy menu.

OpenCanopy Menu.png


UEFI_NTFS

The UEFI_NTFS bootloader from Rufus provides exFAT boot support (from the F12 menu) and can be downloaded here.

References

Pete Batard, author of the Rufus USB tool for Windows, on why the dd command/hybrid ISO approach only applies to Linux. link

UEFI:NTFS - Boot NTFS or exFAT partitions from UEFI

Additional info on creating Windows 10 media with wimlib: link link link

Windows 10 Install USB Creation - Older Hacks and Newer Hacks

Updates

11/06/2020 - Added instructions and information for using Rufus UEFI_NTFS boot loader.
 
Last edited:
Status
Not open for further replies.
Top