site  contact  subhomenews

How to boot Win10 from a USB stick

June 08, 2020 — BarryK

Over the years, I have not had good experiences with Windows 10. There were a couple of posts to the "ethos" tag in this blog:

https://bkhome.org/news/201903/microsoft-fails-on-new-laptop.html

A few days ago, I accidentally wiped the Windows 10 installation on my Lenovo desktop PC, purchased early 2020. Here are some posts:

https://bkhome.org/news/202003/documentation-for-lenovo-ideacentre-510s-07icb.html

I was developing EasyDD, and accidentally wrote a EasyOS image file to the NVME drive, destroying the Win10 installation, as reported here:

https://bkhome.org/news/202006/enhancements-for-easydd-script.html

The NVME drive had four partitions. partition-1 was the fat32 esp boot partition, partition-2 was only 16MB don't know what for, partition-3 is the actual installation (ntfs C: drive), and partition-4 was a ntfs 1GB "recovery drive".

Writing the 1.3GB image file to the NVME drive destroyed the GPT (GUID Partition Table) and the first three partitions. However, partition-4 was still intact, and I thought that I could use it to reinstall Win10.

There is a secondary, backup, GPT at the end of the drive, so running "gdisk nvme0n1" I was able to use the secondary GPT and restore the first GPT.

But no way could I figure out how to use partition-4 to recover Windows!!!

I downloaded Win10 ISO from an official Microsoft website ...and then the fun and games started.

The ISO is about 5GB, too big for a 4.7GB DVD. After some searching, the only solution is to use a double-layer DVD. There was lots of advice, including on official MS sites, to write the ISO to a USB-stick.

Boot the ISO from a USB-stick, reasonable yes? No!!! I tried and tried, googled, heaps of other frustrated people reported the same problem, it won't boot. After some hours, I discovered that MS has used the udf filesystem for the ISO, which the UEFI-firmware on my desktop PC doesn't recognise. And, it seems, same situation for everyone else.

Why use udf, why not iso9660? There is a file, "install.wim", that is 4.2GB, however, iso9660 only supports files up to 4GB. hence, one or two years ago, MS changed to udf. Note, fat32 also has the 4GB file-size limitation.

Can't boot from a USB-stick, that is bad news. What to do?

Well, we can make a Win10 bootable USB-stick, with some ingenuity. What I did was use a EasyOS USB-stick, and gutted it.

EasyOS on a USB flash drive has two partitions, a 640MB fat32 esp boot partition, with reFind boot manager, and a second ext4 partition that fills the drive.

I reformatted the second partition as ntfs, and copied the contents of the ISO file to it. Like this, where sdb2 is the mounted USB-stick second partition:

# mkdir mntpt
# mount -t ntfs /dev/sdb2 /mnt/sdb2 (or in Easy just click on the partition)
# mount -t udf Win10_2004_EnglishInternational_x64.iso mntpt
# cp -a mntpt/* /mnt/sdb2/
# sync
# umount mntpt
# umount /mnt/sdb2 (or in Easy just click the close-box)

In the first partition, I deleted everything except the "EFI" folder, and in /mnt/sdb1/EFI/BOOT/drivers, deleted 'ext4_x64.efi' and copied /usr/share/refind/drivers_x64/ntfs_x64.efi to /mnt/sdb1/EFI/BOOT/drivers (you will need reFind package installed).

/mnt/sdb1/EFI/BOOT only needs 'BOOTX64.EFI' and 'refind.conf', and I edited the latter to only have this:

timeout 10
textonly on
textmode 0
scanfor manual
menuentry "Windows 10 USB" {
volume usbwin10ntfs
loader \efi\boot\bootx64.efi
}

Where "usbwin10ntfs" is the label that I assigned to the second partition:

# blkid /dev/sdb2
/dev/sdb2: LABEL="usbwin10ntfs" UUID="47360BD96837F0BC" TYPE="ntfs"

...I used Gparted to set that label, but whatever it was before would be OK, no need to change it.

Rebooted the PC, holding down the <F12> key to get the UEFI boot menu, and there was the USB-stick, and was able to boot Win10. However, no way could I find out how to use that partition-4 to perform a recovery, had to do a fresh install to partition-3. The install wrote appropriate stuff into the partition-1 fat32 boot partition also.

I was able to jump through these hoops in Linux, but Windows users, well, maybe their only solution is to use a double-layer DVD, and reinstall Win10.   

Tags: tech