[recipe]: How to create a Windows 10 (UEFI and BIOS) install drive in Linux
Latests Win10 image released by Microsoft have the install.wim
file way above 4GB and FAT32 formatted devices cannot handle file bigger than 4GB in size. You could use a NTFS partition but that will reduce the number of machines you’ll be able to use the drive on because some (older) systems can’t boot from NTFS drive.
An option is to use a small FAT32 partition that will contains only the NTFS UEFI drivers and bootloader and a bigger NTFS partition that will contains the Win10 image.
Another option is to compress the install.wim
file with wimlib, an open source, cross-platform library for modifying Windows Imaging archives. This is what we’ll be doing:
Mount Win10 ISO and extract install.wim
We need to mount the ISO and copy the install.wim
file somewhere else to be able to shrink it because ISO-9660
is a read-only filesystem
mount -o loop /path/to/win10.iso /iso/mount/point
mkdir /tmp/win10
rsync -av --no-owner --no-group --progress /iso/mount/point/sources/install.wim /tmp/win10
Compress it
Using the wimoptimize
utility with the --solid
option we can achieve remarkable compression rates:
wimoptimize --solid /tmp/win10/install.wim
wimoptimize --solid install.wim
"install.wim" original size: 4266040 KiB
Using LZMS compression with 4 threads
Archiving file data: 9434 MiB of 9434 MiB (100%) done
"install.wim" optimized size: 3170257 KiB
Space saved: 1095782 KiB
Format the drive
Now that the install.wim
file can be fitted in a FAT32 partition we can prepare the drive.
- First we need to create a GPT partition table on the drive:
sudo gdisk /dev/sdXYZ
which will then ask for some commands:
o
to create a new GPT partition tablen
to create a new partitionw
to apply the changes to the drive
- Then we need to FAT32-format the partition:
sudo mkfs.vfat /dev/sdXYZ123
Mount the drive and copy the data
When the drive is ready we can mount it and copy data from the ISO, excluding the old install.wim
:
sudo mount /dev/sdXYZ123 /drive/mount/point
rsync -av --progress /iso/mount/point /drive/mount/point --exclude sources/install.wim
Then we’ll copy the new compressed file:
rsync -av --progress /tmp/win10/install.wim /drive/mount/point
Boot
The drive should now be ready. Go try it and boot!