Skip to content

Instantly share code, notes, and snippets.

@dragon788
Created November 6, 2019 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dragon788/8e16e62a8ae6899f2a388ea2dcbf1121 to your computer and use it in GitHub Desktop.
Save dragon788/8e16e62a8ae6899f2a388ea2dcbf1121 to your computer and use it in GitHub Desktop.
Create Win10 bootable USB media from macOS without wanting to kill yourself and everyone around you

Kill Me NOW

Because Apple doesn't support NTFS but Linux does and Microsoft has gotten their WIM really fat in newer versions (but don't nicely split it into pieces for you to keep them under 4GB so they could fit on a FAT32 drive), we have do some fun crazy workarounds.

Both of these are close, one isn't optimal because it extracts from the iso rather than loop mounting. The other used to be valid but once the install.wim got over 4GB it started failing.

References

https://techbit.ca/2019/02/creating-a-bootable-windows-10-uefi-usb-drive-using-linux/ https://www.freecodecamp.org/news/how-make-a-windows-10-usb-using-your-mac-build-a-bootable-iso-from-your-macs-terminal/

Extra credit notes about DISM/WIM/ESD

https://answers.microsoft.com/en-us/insider/forum/all/the-problems-between-installwim-and-installesd-and/339846cc-d4e8-4f76-a31c-1d4d7bd21371 JW0914 Replied on March 17, 2016 "Windows 10 TP has both WIM and ESD install.xxx files for their installation. For example my Build 9841 had install.wim the later build,Windows10_TechnicalPreview_x64_EN-GB_10041 has install.esd. This change may be the reason behind some fails.

Not all ESD files can be Decrypted by decrypt.cmd tool. This maybe becuase the ESD doesn't contain a Boot Image, just files. Possibly, I'm not sure. So some ESD updates that have failed to decrypt to ISO may not be Boot type."

ESD images are not encrypted, however it's been repeated so often that ESD's are, most now believe they are encrypted. ESD is an acronym for Electronic Software Download, with ESD using a far better compression algorithm in comparison to WIM.

ESD images are created using the /compress:recovery flag. "ESD file without boot:

Image

With only 1 index, this ESD file will not create a bootable ISO. It will also create an error if used with decrypt"

Boot images have no correlation to WIMs or ESD images, as WIM and ESD images are just a compression container created by Microsoft for Windows, albeit an extremely smart and efficient compression container. Either can be extracted [applied], captured, or exported to the other utilizing DISM.
Bootable WIM/ESD images must be either WinPE/WinRE images or WIMboot images only and must utilize the /bootable or /WIMboot flag during the capture process. Either format [WIM or ESD] can contain multiple images, of which are specified by index number. While the ESD2WIM script shows these indexes in your screenshots, the same can be seen from a command/powershell terminal using DISM.

WIM/ESD image info can be viewed with: dism /get-wiminfo /wimfile: or dism /get-imageinfo /imagefile: One can also specify index # for info about a specified index via adding: /index:X where "x" is the index # It's recommended to utilize the ESD2WIM script because it's written in such a way the export process doesn't consumer 90 - 100% of system resources during the export, however the same can be accomplished using DISM in any admin command/powershell terminal. "ESD file with boot: Image

This ESD file show in the above ESD<>WIM converter shows 4 indexes. This ESD file will create a bootable ISO."

All Windows install ESDs contain 4 images [indexes]: Windows Setup, WinPE, and the base Windows image x2 (x86 & x64). Windows Setup is self explanatory, as is WinPE, with the two base images being the actual OS that's extracted to the system partition depending on the specified architecture.

In order to create a bootable install media, one would need to extract the index for Windows Setup, and if one only needs to update the actual install WIM, the specific base image can be extracted to replace the install.wim in the Sources directory. WIM/ESD images are efficient, as multiple images can be combined into a single image, with same files only being copied once into the the exported WIM. This allows the exported WIM to contain 4 images that all utilize the same files, yet only 1 copy of the file would be copied into the exported WIM, thereby severely reducing the size of the exported WIM.

For example, I have 3 WIM backups of my system partition, a base image of 32GB, an intermediate backup of 41GB, and a final restore image of 52GB. By combining all three into a single exported WIM, the final exported WIM size is just over 52GB and contains all three images as Index 1, Index 2, and Index 3. When exporting WIMs, one must ensure all were created using the same compression flag (none, fast, max, or recovery), as you can only combine WIM/ESD images into an exported image if they are all the same compression type.

Again, ESD's are not encrypted files... if they were, you wouldn't be able to decrypt them.

DISM is what the script uses, and the script's commands can be viewed by opening in a notepad.

To export an ESD to WIM:

dism /Export-Image /SourceImageFile:z:\install.esd /SourceIndex:3 /DestinationImageFile:z:\install.wim /DestinationName:"Windows 10 x64 Install Image" /compress:max /checkintegrity To export a WIM to ESD:

dism /Export-Image /SourceImageFile:z:\install.wim /SourceIndex:1 /DestinationImageFile:z:\install.esd /DestinationName:"Windows 10 x64 Install Image" /compress:recovery /checkintegrity Many of the ESD2WIM or vice versa scripts were written after Windows 8 was released, as imagex was depreciated and few knew it's functionality had been folded into DISM. There's nothing wrong with utilizing one script or another to export the images, however there's a lot of misinformation and mis-conclusions occurring regarding ESDs and WIMs that only make it more difficult for users not familiar with them to garnish the correct info.

If using a script is easier or more convenient to convert the two for a user, they should use the script. I've never utilized the "decrypter" script (I dislike the name because it implies ESDs are encrypted and they're not, thereby feeding the misinformation), however I have used the ESD2WIM script and I do know that script was written in such a way to ensure no more than 50% of system resources are utilized for the export, as exporting to/from ESD is extremely resource intensive. My only point is to ensure the correct info is available.

One can also use the export command to combine multiple WIM files into a single WIM or ESD, with each additional image being assigned an index # in sequential order (1, 2, 3. etc) Due to the efficiency of WIM/ESD, if the same file exists in 2 or more images, it's only copied once into the exported WIM. This allows for significantly smaller image files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment