Wednesday, March 10, 2021

Windows 10 installation using USB stick won't install, fix formatting USB with MBR using a Mac (error 0x80300002)

It's been some years since I have had to do anything with a Windows installer, but this last week I spent the better part of four hours wrestling with installing Windows 10 on a brand new gaming machine.

Now I know that this should be really straight forward as it's just a normal disk in a desktop machine, but it really seems to be a tricky problem due to the lack of clear error messages you get when it fails to start the installation.

The basis is getting a valid copy of Windows 10 in an ISO download, putting it on a bootable USB stick, putting that in a port on the new machine, booting the machine to start the USB installer, clicking a few times to get your new disk formatted, partitioned, and finally watching the installation start copying files onto your new machine.

You would think it's that easy, right?

My journey was a bit harder than that... but I want to share the solution for others.


Note the below examples are all done from an OSX machine where I download, create, and use the Windows ISO file for a USB stick to install Windows 10.

Installing Win10

The easy part was to obtain a valid Windows 10 download for my 64-bit machine, which gave me and ISO file is renamed to Win10x64.iso in a directory called windows:

$ ls windows/

-rw-r--r--@ 1 eschabel  staff   5.8G Mar  5 09:35 Win10x64.iso 

 The USB stick I used was 32 GB, but as long as you can get one big enough to hold this file it's fine. The rest was done from the terminal using the following steps. 

First using DiskUtility app, I formatted the USB to FAT 32 and named it WIN10. This is where the problem started, I just didn't know it yet as this uses GPT (GUID Partition Table) which is a format used to define the hard disk partitions in computers with UEFI startup firmware. The GUID Partition Table (GPT) replaces the previous master boot record (MBR) method. 

If you did this from the terminal you would have to type the following command (after checking that your USB stick was indeed listed as disk2 using diskutil list command:

$ diskutil eraseDisk MS-DOS "WIN10" GPT /dev/disk2    <<<< don't do this!

Later, in the next section you'll see why you don't want to do this. You need to replace GPT with MBR so that you get a master boot record format.

$ diskutil eraseDisk MS-DOS "WIN10" MBR /dev/disk2  

Once this completes you just need to mount the ISO file, copy the files to the USB, perform a trick for one file that's too big (splitting it), and done, right?

$ hdiutil mount Win10x64.iso

Note one file is too large, install.wim, so we skip that one initially: 

$ rsync -vha --exclude=sources/install.wim /Volumes/CCCOMA_X64FRE_EN-GB_DV9/* /Volumes/WIN10

Once this completes, make sure you have installed wimlib with Homebrew and you can split the copy of install.wim as follows:

$ wimlib-imagex split /Volumes/CCCOMA_X64FRE_EN-GB_DV9/sources/install.wim /Volumes/WIN10/sources/install.swm 3800

This takes awhile and once finished remove USB properly and insert in your new machine, boot (ensure the boot process picks up your USB) and it will start the installer for Windows 10.

At this point it's just a few steps to pick the language, click INSTALL NOW button, enter the product code to activate your windows version, accept the agreement presented, then choose the CUSTOM installer option, and now it got interesting for me when I used GPT formatting on the USB stick.

USB stick formatting GPT or MBR

At this point in the install, you're presented with a disk partitioning tool and your unallocated disk, select it and click on the NEW option to have windows installer format 3 partitions for you automatically. All good here, but if using the GPT formatted USB installer at this point I got the following error message:

"We Couldn't Create a New Partition or Locate an Existing One" 

I dropped into the windows utility DISKPART using SHIFT + F10 dropping into a console. From there you can reformat the created primary partition by hand just to be sure that it's NTFS as follows:

> DISKPART

> LIST DISK

> SELECT DISK 0

> SELECT PARTITION 3

> FORMAT FS=NTFS QUICK

Then exit out and back to graphical interface, select partition 3 but then when I click NEXT it fails with this cryptic message:

"We couldn’t install Windows in the location you choose, error 0x80300002" 

That's nice... so went back and formatted the USB installer with MBR as stated above at which point the graphical installer partitioned and installs as advertised. 

Go figure.