Create Windows Installation Media to Boot via USB in UEFI Mode

I’m setting up a HP Server and didn’t configure it with an optical drive. No problem, I thought, just boot it off a USB. Easy. Not so much… This was considerably more difficult than it really should have been.

I’m wanting to install Windows Server 2016. I want to install in UEFI mode, not in BIOS mode. I also want to boot off a USB.

I created the installer USB from an iso I downloaded from Microsoft. Couldn’t boot. I tried many different variations and without exception, I couldn’t boot from them. In desperation I tried to boot off the Windows 10 installer. It booted first go.

I was using my favourite media creation tool, Rufus, to create an install USB. This wanted to create an install USB with an NTFS file system. The installation media for Windows Server 2016 has an install.wim file that’s over 4 GB in size. The installation media for Windows 10 has an install.wim file that’s less than 4 GB. So, therefore I need NTFS to hold the files? Right?

Not so fast. As it turns out, the UEFI firmware can’t boot off a NTFS filesystem.

The Windows 10 installer (created from the Microsoft Media Creation Tool) actually has a FAT32 filesystem on the USB. The Windows Server 2016 installer however needs to be NTFS. But I can’t boot UEFI from NTFS. I tried booting the server in BIOS mode to see if that was the issue and sure enough, it booted up off the Windows Server 2016 USB stick.

After much searching for a solution and trying to boot time after time (and listening to the fans wind up like the server was preparing to take off every time) I found a PowerShell script that Emin had posted on their blog that would create an installer on USB with a FAT32 filesystem and use the Microsoft dism tool to split the install.wim file into less than 4 GB chunks.

How to create UEFI bootable USB media to install Windows Server 2016

I’ve copied the script here just in case the source blog disappears – but basically this did the trick for me.

Later on, I then found out that HP have a USB Key Utility that can make a bootable USB from a CD/DVD or iso, but I haven’t had a chance to test if it does the same thing as the script below.

# minimum size of USB stick 5.29GB

# Set here the path of your ISO file
$iso = ‘C:\Users\Kai Howells\Downloads\SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_English_-3_MLF_X21-30350.iso’

# Clean ! will clear any plugged-in USB stick!!
Get-Disk | Where BusType -eq ‘USB’ |
Clear-Disk -RemoveData -Confirm:$true -PassThru

# Convert GPT
if ((Get-Disk | Where BusType -eq ‘USB’).PartitionStyle -eq ‘RAW’) {
Get-Disk | Where BusType -eq ‘USB’ |
Initialize-Disk -PartitionStyle GPT
} else {
Get-Disk | Where BusType -eq ‘USB’ |
Set-Disk -PartitionStyle GPT
}

# Create partition primary and format to FAT32
$volume = Get-Disk | Where BusType -eq ‘USB’ |
New-Partition -UseMaximumSize -AssignDriveLetter |
Format-Volume -FileSystem FAT32

if (Test-Path -Path “$($volume.DriveLetter):\”) {

# Mount iso
$miso = Mount-DiskImage -ImagePath $iso -StorageType ISO -PassThru

# Driver letter
$dl = ($miso | Get-Volume).DriveLetter
}

if (Test-Path -Path “$($dl):\sources\install.wim”) {

# Copy ISO content to USB except install.wim
& (Get-Command “$($env:systemroot)\system32\robocopy.exe”) @(
“$($dl):\”,
“$($volume.DriveLetter):\”
,’/S’,’/R:0′,’/Z’,’/XF’,’install.wim’,’/NP’
)

# Split install.wim
& (Get-Command “$($env:systemroot)\system32\dism.exe”) @(
‘/split-image’,
“/imagefile:$($dl):\sources\install.wim”,
“/SWMFile:$($volume.DriveLetter):\sources\install.swm”,
‘/FileSize:4096’
)
}

# Eject USB
(New-Object -comObject Shell.Application).NameSpace(17).ParseName(“$($volume.DriveLetter):”).InvokeVerb(‘Eject’)

# Dismount ISO
Dismount-DiskImage -ImagePath $iso

This article was posted by Kai Howells. If you liked this content and have any technical work in the Melbourne area, say hello via my contact form or give me a call on 0419 361 653 - I cover most of the greater Melbourne area and my rates are competitive.

Leave a Reply

Your email address will not be published. Required fields are marked *