Create Windows 7/8/10 bootable USB drive in macOS with command line (MBR partitioning scheme)

In the following procedure we will create a Microsoft Windows bootable USB flash drive in macOS, from scratch with command line. Root privileges are required.
Note: This works only with BIOS or UEFI CSM (supports old BIOS style booting). Not compatible with native UEFI.

Test environment: macOS 10.13.1
Requirements: syslinux 4.03 and port of syslinux 4.03 to macOS

Warning: All the data on the USB flash drive will be destroyed without warning! Make sure you selected the correct drive or you will destroy a wrong disk!

1. Identify the USB flash drive, in my example the device is /dev/disk2.

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

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +121.1 GB   disk1
                                 Physical Store disk0s2
   1:                APFS Volume SSD 128GB               34.8 GB    disk1s1
   2:                APFS Volume Preboot                 18.5 MB    disk1s2
   3:                APFS Volume Recovery                520.8 MB   disk1s3
   4:                APFS Volume VM                      1.1 GB     disk1s4









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

2. Erase the /dev/disk2, create one big partition /dev/disk2s1 and format as FAT32 with the label “WINDOWS”. All data on /dev/disk2 will be destroyed!

diskutil partitionDisk /dev/disk2 1 MBR FAT32 WINDOWS R
Started partitioning on disk2
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Formatting disk2s1 as MS-DOS (FAT32) with name WINDOWS
512 bytes per physical sector
/dev/rdisk2s1: 30248048 sectors in 1890503 FAT32 clusters (8192 bytes/cluster)
bps=512 spc=16 res=32 nft=2 mid=0xf8 spt=32 hds=255 hid=2 drv=0x80 bsec=30277630 bspf=14770 rdcl=2 infs=1 bkbs=6
Mounting disk
Finished partitioning on disk2
/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *15.5 GB    disk2
   1:                 DOS_FAT_32 WINDOWS                 15.5 GB    disk2s1

3. Set bootable flag on, start fdisk and enter the commands with red text.

fdisk -e /dev/disk2
Enter ‘help’ for information
fdisk: 1> flag 1
Partition 1 marked active.
fdisk:*1> write
Device could not be accessed exclusively.
A reboot will be needed for changes to take effect. OK? [n] y
Writing MBR at offset 0.
fdisk: 1> exit

4. Download and unpack syslinux 4.03 source code.

curl https://www.oueta.com/wp-content/uploads/2018/10/syslinux-4.03.tar.gz -o syslinux-4.03.tar.gz
tar -zxvf syslinux-4.03.tar.gz

5. Download syslinux macOS port and make it executable.

curl https://www.oueta.com/wp-content/uploads/2018/10/syslinux-mac.tar.gz -o syslinux-mac.tar.gz
tar -zxvf syslinux-mac.tar.gz
chmod +x syslinux

6. Unmount and write the bootstrap code (mbr.bin) to the MBR of /dev/disk2.

diskutil unmountDisk /dev/disk2
Unmount of all volumes on disk2 was successful
dd if=syslinux-4.03/mbr/mbr.bin of=/dev/disk2 bs=440 count=1
1+0 records in
1+0 records out
440 bytes transferred in 0.000908 secs (484509 bytes/sec)

7. Install syslinux, this will alter the boot sector and copy ldlinux.sys into the root directory.

./syslinux -i /dev/disk2s1
syslinux for Mac OS X; created by Geza Kovacs for UNetbootin unetbootin.sf.net
"/dev/disk2s1" unmounted successfully.
/dev/disk2s1            DOS_FAT_32                      /Volumes/WINDOWS
mountpoint is /Volumes/WINDOWS
checkpoint1
checkpoint1.5
checkpoint1.6
/Volumes/WINDOWS/ldlinux.sys ldlinuxname
checkpoint2
checkpoint3
"/dev/disk2s1" unmounted successfully.
checkpoint4
checkpoint5
checkpoint6
checkpoint7
checkpoint8
/dev/disk2s1            DOS_FAT_32                      /Volumes/WINDOWS

8. Copy syslinux BIOS modules and create syslinux.cfg.

mkdir /Volumes/WINDOWS/syslinux
cp syslinux-4.03/com32/modules/*.c32 /Volumes/WINDOWS/syslinux

9. Create with a text editor /Volumes/WINDOWS/syslinux/syslinux.cfg and add the following:

default boot
LABEL boot
MENU LABEL boot
COM32 chain.c32
APPEND fs ntldr=/bootmgr

10. Mount the Microsoft Windows ISO image, please replace /example/windows.iso with the path of your Microsoft Windows image.

hdiutil mount /example/windows.iso -mountpoint /Volumes/WINSETUP

11. Copy the Windows installation files to the USB flash drive, it might take a few minutes.

cp -Rv /Volumes/WINSETUP/ /Volumes/WINDOWS/

12. Unmount the USB flash drive.

diskutil unmountDisk /dev/disk2

Update: In case that you are encountering the error “zsh: bad CPU type in executable: ./syslinux” most probably you need to use the 64 bit version of syslinux, you can download it from github the tip is belonging to Thanh. Thanks!

20 Replies to “Create Windows 7/8/10 bootable USB drive in macOS with command line (MBR partitioning scheme)”

  1. Please delete this post. It doesn’t work at all and I am tired of all these non working guides that wastes my time.

  2. Hi le-snake and Henrik,

    You were right there was some errors in this tutorial, I corrected them.

    1. Because the link for syslinux-4.03.tar.gz now it’s redirected, the curl command was not working because I did not used the -L parameter to follow the redirect, now I uploaded the files to oueta.com.
    2. Bootable flag was not set, I added step three.
    3. There was also an error on step eight, I removed the -e parameter from the echo.
    4. Make sure you try to boot with legacy BIOS or UEFI CSM (supports old BIOS style booting).

    Please let me know if you still have problems, thanks.

  3. Thank you for this. This *almost* works. However, I had to edit /Volumes/WINDOWS/syslinux/syslinux.cfg and replace literal \n’s with line breaks lest you get a “Could not find kernel image” error.
    Nevertheless, these are the most complete instructions for creating a Windows bootable USB key from a Mac.

    1. Thank you for your feedback, I corrected the echo command and added the text, which needs to be added to syslinux.cfg.
      Thank you all.

  4. Hey thanks for taking the time to make the guide. This worked perfectly for me except I’m using a windows 10 iso that includes a file that is larger than 4gb. When I tried to follow the guide using the exfat filesystem, I got the error “invalid media signature (not a FAT filesystem?)” when running ./syslinux

    1. I am also trying to install Windows 10 iso and hitting the same error. How were you able to proceed with installing Win10 using the above steps?

  5. This did not work for me, attempting to create a bootable Win 8.1 install. Yeilds “Error Non-System disk or disk error” from HP Z600 Bios

  6. That is a really wonderful guide. Thank-you very much. It worked perfectly.

    Now I suppose I need to read more about Syslinux. I tried to use a FreeDOS image for the OS, but the bootloader fails. I was hoping to make a bootable USB for updating firmware.

    It would also be amazing if this could work with both native UEFI and also BIOS / BIOS CSM. It takes me a while to figure out whether the machine I am working on supports one or the other. The goal: a truly universal USB boot that would also tell you which boot method it was using.

  7. Hi.
    This command doesn’t work in MacOs Catalina (v.10.15.7)
    ./syslinux -i /dev/disk2s1

    says:
    zsh: bad CPU type in executable: ./syslinux

  8. Everything works like a charm but I’m getting an error while copying the files

    cp: /Volumes/WINDOWS/sources/install.wim: File too large

  9. Wow, thank you so much! It is really workable solution.
    @Joan You can use wimlib to split install.wim in chunks (< 4GB each) like:
    # brew install wimlib
    # wimlib-imagex split /Volumes/WINDOWS/sources/install.wim /Volumes//sources/install.swm 3800

Leave a Reply

Your email address will not be published.