Make a bootable Windows USB from Linux in 2022
April 9, 2022
April 9, 2022
In the Linux world weāre used to dd if=some-image.iso of=/dev/some-usb-key bs=4M
and it Just Worksā¢.
It is because most Linux ISO are hybrid in a way where the same ISO can be used on a DVD, USB or SD card. Itās not the case for the Windows ISO.
From Windows, Rufus is the easiest solution, but if Iām making a bootable Windows USB, maybe itās because I donāt have a Windows installation handy at the moment. š¬
Before Windows shipped ISOs with files larger than 4 GB, making a bootable Windows USB for EFI was as simple as format the key as FAT32, and just copying over the contents of the ISO to it. Example:
fdisk /dev/sdX # Make a single partition for the whole drive
mkfs.fat -F32 /dev/sdX1 # Format as FAT32
mkdir usb windows # Make some mount points
mount /dev/sdX1 usb
mount windows.iso windows
cp -rv windows/* usb # Copy contents
umount windows
umount usb
If your motherboardās EFI somehow supports exFAT out of the box, you can
replace mkfs.fat
by mkfs.exfat
in the above script and that should
work for you with files larger than 4 GB.
This didnāt work on any of the PCs I tried this on, but according to this post, some firmware have native UEFI boot support for exFAT, and this video is full of comments of people booting the Windows installer from an exFAT drive using this method, so it might work for you!
Otherwise, nowadays WoeUSB seems like a good solution to prepare Windows USB drives, but if you want to keep it low-level, thereās an even easier solution!
I found this quite unique solution in this blog post.
It consists in making a 1 GB FAT32 partition on the USB, and using the
rest as NTFS, then copying everything from the ISO but the sources
directory to the FAT32 partition (only including sources/boot.wim
),
and copying the whole ISO contents to the NTFS partition.
Iām not sure why this works, but it looks like Windows is able to handle
such a USB layout seamlessly, and itās by far the easiest solution out
there, because it doesnāt require splitting the install.wim
file, or
installing and configuring
another bootloader
to boot from a second partition (after all Windows installerās
bootloader is already capable of doing that by itself!).
Hereās how to do it:
fdisk /dev/sdX # Make a 1 GB partition and another partition with the rest
mkfs.fat -F32 /dev/sdX1 # Format as FAT32
mkfs.ntfs --fast /dev/sdX2 # Format as NTFS
mkdir boot usb windows # Make some mount points
mount /dev/sdX1 boot
mount /dev/sdX2 usb
mount windows.iso windows
# Copy everything but the `sources` directory
find iso -mindepth 1 -maxdepth 1 -not -name sources -exec cp -rv {} boot \;
# Add `sources/boot.wim`
mkdir boot/sources
cp iso/sources/boot.wim boot/sources
cp -rv iso/* usb # Copy everything to the NTFS partition
umount windows
umount usb
umount boot
I hope you found this trick useful! And I wish you a smooth Windows installation. š