Create a bootable windows 10 USB stick from linux

From www.ReeltoReel.nl Wiki
Revision as of 12:37, 15 June 2017 by Pvdm (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Creating a bootable Windows 10 USB on linux

10 Aug 2016 - by 'Maurits van der Schee'

Whenever I have to help somebody with Windows 10 I find myself making a bootable Windows 10 USB drive. If you are on Windows this is provided via a menu option, but on Ubuntu Linux this requires some commands. This post will explain in detail how to do this.

GPT partition table with FAT32 partition

Modern systems support UEFI booting and this differs from traditional BIOS in that it does not read the boot sector. Instead it will look in the /efi/ directory in a FAT32 partition of a drive with GPT partitioning. There are no partition flags (like 'boot') necessary either.

Getting the official Windows 10 ISO image

You can download the official Windows 10 ISO image from Microsoft by visiting:

https://www.microsoft.com/en-us/software-download/windows10ISO

But you must be on Linux (or pretend to be using user agent switcher) to download the file.

Writing to the USB drive

Your USB drive has a drive letter in Linux typically something like 'b', which leads to a path to the device of /dev/sdb and a partition path for the first partition of /dev/sdb1. To avoid you screwing up your computer I use 'h', which you should replace in the commands below. You can use the 'gparted' graphical tool to find the drive letter of your USB drive.

If your USB drive is behaving weird, then you can reset it by issuing the following command:

# dd if=/dev/zero of=/dev/sdh bs=512 count=1

Normally this is not nessecary. Then to create a new layout on the drive:

# fdisk /dev/sdh

This is what you should enter in fdisk:

Press 'g' to create a new GPT, Press 'n' to create a new partition and accept the defaults, Press 't' to choose the partition type, Enter '11' for the 'Microsoft basic data' type. Press 'w' to write the changes to disk.

The following command will format the first partition with FAT32.

# mkdosfs -F32 /dev/sdh1

Now we need to mount the downloaded ISO file:

# mount Downloads/Win10_1607_Dutch_x64.iso /mnt

And copy all contents to the USB drive (this takes up to 15 minutes and shows no progress):

# cp -R /mnt/* /media/maurits/39F5-8B34/

Now unmount the ISO...

# umount /mnt

and the USB drive before removing it:

# umount /media/maurits/39F5-8B34/

To ensure the drive is OK, print the contents using 'fdisk':

# fdisk /dev/sdh
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): p
Disk /dev/sdh: 7.2 GiB, 7735541760 bytes, 15108480 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 1F574274-2552-4728-831F-90D768723297

Device     Start      End  Sectors  Size Type
/dev/sdh1   2048 15108095 15106048  7.2G Microsoft basic data

Command (m for help): q

Note that the drive should say 'Disklabel type: gpt' and 'Microsoft basic data'.