Create a bootable Windows 10 USB drive (UEFI) from Linux

23

11

How can I create a bootable Windows 10 USB drive from Linux ?

Please note:

  • WinUSB doesn't work with Windows 10.
  • UNetbootin doesn't work either.
  • dd method didn't work as well.

Beside this, I've tried creating a GPT partition table and one partition of type ef00 and formatted as fat32, and then copied all ISO contents to it. It boots OK, but when I go to start installation it shows the prompt for media dialog.

Update

Another try:

  1. Created a GPT
  2. Created a FAT32 at end of drive of 50 MB
  3. Created NTFS at remaining space
  4. Put UEFI:NTFS on FAT32
  5. Copied ISO content to NTFS

The installation starts ok, but at start of progress shows error 0xc0000005 (if i remember correctly).

Victor Aurélio

Posted 2015-12-24T21:57:47.507

Reputation: 473

I think it should be formatted NTFS... (are you the guy who asked this on reddit too btw?) – Alex – 2015-12-25T00:32:13.817

@Alex, not, wasn't me... and not, UEFI can boot only from FAT32! – Victor Aurélio – 2015-12-25T01:26:16.983

Did you fix up the BCD store? – fpmurphy – 2015-12-26T01:28:43.670

@fpmurphy1 not, how to do that ? – Victor Aurélio – 2015-12-26T14:54:53.653

1What does "Put UEFI:NTFS on FAT32" mean? – Philipp Ludwig – 2018-08-08T15:22:52.873

Put this on FAT32 partition.

– Victor Aurélio – 2018-08-10T17:04:12.663

Answers

8

You did all right. Make gpt table with fat32 and copy all data from iso on it. But you also need to set flag "msftdata"(not "boot") on this partition with e.g. parted.

Feretj

Posted 2015-12-24T21:57:47.507

Reputation: 96

1For those using gdisk: instead of creating a ef00 create a 0700 partition. – Victor Aurélio – 2016-05-25T00:52:20.777

1set flag "msftdata"(not "boot"), thank you @Feretj, you save my life – gpanda – 2018-07-31T12:58:09.527

You cannot put all data onto a FAT32 drive as of June 2019. The latest update contains a windows.wim which is larger than 4.1 GiB. – Ben – 2019-06-24T19:42:04.770

@Ben You can when you compress the install.wim file using dism or wimtools, see https://tqdev.com/2019-cannot-copy-windows-10-install-wim.

– mevdschee – 2020-02-15T16:51:22.747

8

Guide to prepare Windows 10 October 2018 release UEFI bootable USB drive on any Linux distribution.

Notice, that Windows 10 October 2018 release has an installation file sources/install.wim larger than the maximum FAT32 file size, so we will format USB drive to NTFS. Windows installer also cannot work with an EFI partition (code ef00), so we will use Microsoft basic data partition type (code 0700).

Steps for creating USB drive with name /dev/sdc (Replace all commands with YOUR device name!):

  1. Insert USB drive to computer and make sure it is unmounted. Some distributions like to automount USB drives, so make sure you unmount them. Mounted partitions can be found with mount -l | grep '/dev/sdc', then unmount with sudo umount /dev/sdcX (X is partition number).
  2. Open USB block device using gdisk /dev/sdc, configure it as GPT and create Microsoft basic data partition (code 0700), then write changes and quit (Next steps will destroy partition table in your USB drive!!!).
sudo gdisk /dev/sdc
o
> This option deletes all partitions and creates a new protective MBR.
> Proceed? (Y/N): y
n
> Partition number ... > hit Enter
> First sector ... : > hit Enter
> Last sector ... : > hit Enter
> Current type is 'Linux filesystem'
> Hex code or GUID (L to show codes, Enter = 8300): 0700
p
> Should print something like:
> Disk /dev/sdc: 15646720 sectors, 7.5 GiB
> Model: DataTraveler 160
> Sector size (logical/physical): 512/512 bytes
> Disk identifier (GUID): ...
> Partition table holds up to 128 entries
> Main partition table begins at sector 2 and ends at sector 33
> First usable sector is 34, last usable sector is 15646686
> Partitions will be aligned on 2048-sector boundaries
> Total free space is 2014 sectors (1007.0 KiB)
> Number  Start (sector)    End (sector)  Size       Code  Name
>    1            2048        15646686   7.5 GiB     0700  Microsoft basic data
w
> Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!!
> Do you want to proceed? (Y/N): y
q
  1. Format new partition as NTFS:
sudo mkfs.ntfs /dev/sdc1
  1. Mount new USB partition to temporary directory in your home:
mkdir ~/tmp-win10-usb-drive
sudo mount /dev/sdc1 ~/tmp-win10-usb-drive
  1. Download Windows installation ISO, create new temporary directory in your home and mount it there:
mkdir ~/tmp-win10-iso-mnt
sudo mount Win10_1809Oct_English_x64.iso ~/tmp-win10-iso-mnt
  1. Copy all files from mounted ISO to USB drive (you can use rsync to see progress):
sudo cp -rT ~/tmp-win10-iso-mnt/ ~/tmp-win10-usb-drive/
  1. Unmount Windows ISO and USB drive and remove temporary directories:
sudo umount ~/tmp-win10-iso-mnt/ ~/tmp-win10-usb-drive/
rmdir ~/tmp-win10-iso-mnt/ ~/tmp-win10-usb-drive/
  1. Insert USB drive to new computer and boot from it.

Lirt

Posted 2015-12-24T21:57:47.507

Reputation: 81

4Some firmwares doesn't check for boot files in a NTFS partition, someone correct me if m i wrong. – Victor Aurélio – 2019-01-24T16:35:35.773

1

You can compress install.wim to be smaller than 4GB using "wimtools" and "solid" compression level. This way you can simply use FAT32, see https://tqdev.com/2019-cannot-copy-windows-10-install-wim

– mevdschee – 2019-03-20T18:13:03.153

1You can significantly speed up the formatting of the stick when you skip filling it with zeros first: sudo mkfs.ntfs -Q /dev/sdc1 – Robert – 2019-11-23T16:26:23.370

I came here to say that I too was experiencing the issue described by @VictorAurélio - my laptop would not boot an NTFS partition correctly formatted and flagged with gdisk. I resolved the issue by using FAT32 and the command wimlib-imagex optimize install.wim --solid described in the article linked by @mevdschee – testUser12 – 2020-01-03T02:38:57.660

3

I've used woeusb on Ubuntu the following way (Warning: this will overwrite your whole partition table!):

sudo woeusb --tgt-fs NTFS --device Win10_1809Oct_Hungarian_x64.iso /dev/sdc

If you encounter this error message:

Partition is still detected after wiping all signatures, this indicates that the drive might be locked into readonly mode due to end of lifespan.

do the following: sudo fdisk /dev/sdc, and choose d and then finally w.

(Source: https://github.com/slacka/WoeUSB/issues/219.)  After this, try again to run the above command.

Anyway, with this method woeusb created a gpt partition table with two partitions:

partition      file system    label          size          flags
----------------------------------------------------------------
/dev/sdc1      nfts           Windows USB     57.00 GiB
/dev/sdc2      fat16          UEFI_NTFS      512.00 KiB    lba
unallocated                                    4.00 MiB

Finally, all I had to do is to put the boot flag with gparted for the /dev/sdc2 partition (alongside lba).

This way, I could sucessfully boot in UEFI mode and install Windows 10 from my USB stick.

Varga

Posted 2015-12-24T21:57:47.507

Reputation: 31

Commenting just to remind myself to upvote if it works. – That Brazilian Guy – 2019-07-11T19:44:17.203

2

Try using Rufus with Wine.

Regards.

aalf1987

Posted 2015-12-24T21:57:47.507

Reputation: 41

2This isn't a "linux" solution. – Victor Aurélio – 2016-05-25T00:50:52.833

1But it works OK. – aalf1987 – 2016-05-25T13:24:49.700

Rufus is open source. Quick, efficient, works on Linux. Thanks! – akhmed – 2017-07-05T22:18:04.343

0

The EFI partition must be Fat32. It is in the EFI spec. Your system will never boot if you put the installer files onto an NTFS partition.

You don't even need any special software. GPT / FAT32 for the installer, extract all files from the iso (I assume you have the latest iso using media creation tool, as it includes the November update), and set the "boot flag" using gparted. It will then boot into the installer in EFI mode assuming you select EFI USB from the boot options when your computer starts.

Pingers.

Pingers

Posted 2015-12-24T21:57:47.507

Reputation: 337

The problem is that soon as the installer begin the process it throws an error, described in the question. – Victor Aurélio – 2016-01-15T21:12:27.163

you've tried with a different iso? I would suspect my source. Grab the latest one as described in my answer. If you boot with that on your usb, and you still get an error, I would start to question hardware... – Pingers – 2016-01-15T22:52:25.993

yes I've tried it too... – Victor Aurélio – 2016-01-16T02:02:08.787