39

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
  • 653
  • 1
  • 9
  • 13

7 Answers7

27

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

Notice, that since Windows 10 October 2018 release the installation file sources/install.wim is 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).

Variant A (For PCs with NTFS support)

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 (where 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 (thx @Alex for -Q idea):
sudo mkfs.ntfs -Q /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.

Variant B (For PCs without NTFS support)

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 (where X is partition number).
  2. Open USB block device using gdisk /dev/sdc
  3. Configure it as GPT
  4. Create first partition of 1GB size and type Microsoft basic data (code 0700).
  5. Create second partition of rest of the size and type Microsoft basic data (code 0700).
  6. 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: Enter
> First sector: Enter
> Last sector: 1G
> Type: 0700
> n
> Partition Number: Enter
> First sector: Enter
> Last sector: Enter
> Type: 0700
> p
# Should print something like:
> Disk /dev/sdc: 30031250 sectors, 14.3 GiB
> Model: Ultra USB 3.0   
> Sector size (logical/physical): 512/512 bytes
> Disk identifier (GUID): C657C0AF-3FE2-4152-8BF1-CE3CCA9F3541
> 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 30031216
> Partitions will be aligned on 2048-sector boundaries
> Total free space is 4061 sectors (2.0 MiB)

> Number  Start (sector)    End (sector)  Size       Code  Name
>    1            2048         2048000   999.0 MiB   0700  Microsoft basic data
>    2         2050048        30031216   13.3 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 first partition as FAT32 and second as NTFS:
sudo mkfs.fat -F32 /dev/sdc1
sudo mkfs.ntfs -Q  /dev/sdc2
  1. Mount new USB partitions to temporary directories in your home:
mkdir ~/tmp-win10-fat-usb-drive
mkdir ~/tmp-win10-ntfs-usb-drive
sudo mount /dev/sdc1 ~/tmp-win10-fat-usb-drive
sudo mount /dev/sdc2 ~/tmp-win10-ntfs-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 following files with from mounted ISO to FAT32 formatted USB drive (basically copy everything besides sources/ but include sources/boot.wim):
sudo cp ~/tmp-win10-iso-mnt/* ~/tmp-win10-fat-usb-drive/
sudo cp -r ~/tmp-win10-iso-mnt/boot ~/tmp-win10-fat-usb-drive/
sudo cp -r ~/tmp-win10-iso-mnt/efi ~/tmp-win10-fat-usb-drive/
sudo cp -r ~/tmp-win10-iso-mnt/support ~/tmp-win10-fat-usb-drive/
sudo mkdir ~/tmp-win10-iso-mnt/sources ~/tmp-win10-fat-usb-drive/
sudo cp ~/tmp-win10-iso-mnt/sources/boot.wim ~/tmp-win10-fat-usb-drive/sources
  1. Copy everything from mounted ISO to NTFS formatted USB drive:
sudo cp -rT ~/tmp-win10-iso-mnt/ ~/tmp-win10-ntfs-usb-drive/
  1. Unmount Windows ISO and both USB partitions and remove temporary directories:
sudo umount ~/tmp-win10-iso-mnt/ ~/tmp-win10-usb-fat-drive/ ~/tmp-win10-usb-ntfs-drive/
rmdir ~/tmp-win10-iso-mnt/ ~/tmp-win10-usb-drive/
  1. Insert USB drive to new computer and boot from it.
Lirt
  • 371
  • 3
  • 5
  • 4
    Some firmwares doesn't check for boot files in a NTFS partition, someone correct me if m i wrong. – Victor Aurélio Jan 24 '19 at 16:35
  • 5
    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 Mar 20 '19 at 18:13
  • 3
    You can significantly speed up the formatting of the stick when you skip filling it with zeros first: *sudo mkfs.ntfs -Q /dev/sdc1* – Rob Nov 23 '19 at 16:26
  • 3
    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 Jan 03 '20 at 02:38
  • 1
    @mevdschee I would warmly encourage you to promote your remark to an answer. It is a sensible option, and it can hardly be spotted tucked under one of several other answers. That could solve the bottleneck of using a **fat32 file system** and deal with recent installation files that are too big for it. – XavierStuvw Mar 24 '20 at 11:35
  • @XavierStuvw thank you for your kind words, but I don't have enough reputation on this site to do that. I hope somebody else will answer it with that content. – mevdschee Apr 02 '20 at 15:26
  • 1
    @mevdschee Please do create a new answer of your own. There is no reputation threshold for that. – XavierStuvw Apr 02 '20 at 15:55
  • @XavierStuvw yes there is.. as this is a "Highly active question" and is protected.. you need 10 rep points. – mevdschee Apr 02 '20 at 16:27
  • 1
    @mevdschee Sorry, I had overlooked this. I encourage you to keep this improvement in mind for when you reach the necessary credentials. Happy hacking on SE! – XavierStuvw Apr 02 '20 at 16:32
  • 1
    Agree @mevdschee, you should add new answer. I want to keep this answer to be doable without any external utilities on any linux distribution. Thanks for idea with `-Q` @Alex, I included it in answer. – Lirt Apr 03 '20 at 16:21
  • 1
    @Lirt, you may add that if this method does not work (many EFI firmwares do not support NTFS), then you may create two partitions (one FAT32 and one NTFS) as described here: https://tqdev.com/2019-cannot-copy-windows-10-install-wim (no external tools needed) – mevdschee Apr 04 '20 at 06:28
  • variant B worked for me :) (tried soooo many other methods first... :O ) – Hugh Perkins Jan 09 '22 at 14:59
12

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
  • 121
  • 1
  • 2
  • Commenting just to remind myself to upvote if it works. – That Brazilian Guy Jul 11 '19 at 19:44
  • It does work. The target-filesystem option `--tgt-fs NTFS` is necessary because the files in the new Windows installations are larger than 4GB and cannot be supported by a fat32 file systems. fat32 file systems are essential for UEFI boot loading. However, woeusb works around this under hood and produces a USB immediately recognized with Secure Boot disabled (and provided the device's boot loader has the USB drive suitably high of its priority list). I did not need to add the boot flag to any partition. – XavierStuvw Mar 24 '20 at 15:48
  • for anyone that lands on this in the future, be aware you need to unmont the partitions but not the disk, e.g /dev/sdb1 , /dev/sdb2 once thats done the application will work, /dev/sdb doesn't need to be umounted. If one uses the gnome file manager it will unmount the entire disk and woeusb won't find it. also you need an active internet connection as the uefi-ntfs.img file is downloaded from github, it depends on the Rufus project for that. – Darragh Mar 28 '20 at 10:26
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
  • 96
  • 1
  • 2
  • 1
    For those using gdisk: instead of creating a `ef00` create a `0700` partition. – Victor Aurélio May 25 '16 at 00:52
  • 2
    set flag "msftdata"(not "boot"), thank you @Feretj, you save my life – gpanda Jul 31 '18 at 12:58
  • 1
    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. – Benjamin Marwell Jun 24 '19 at 19:42
  • @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 Feb 15 '20 at 16:51
  • I tried this and didn't work (and a lot of other things like exFat format for newer Windows 10 isos) So in the end I gave up, went to Windows and downloaded their Media Creator Tool. After that I checked and the USB worked. I checked the flags and they are `boot` and `lba` – JorgeeFG Nov 09 '20 at 15:25
3

I did some search, and found a perfect script: windows2usb.

Since woeusb doesn't support UEFI, this tool supports BIOS and UEFI(with rufus driver), FAT32 and NTFS.

Update: If the NTFS driver in windows2usb fails for you, you may also try ventoy. It's easier to use if you have multiple OS images in one USB stick.

recolic
  • 529
  • 4
  • 11
  • 2
    Please do not post the same answer to multiple questions. If the same information really answers both questions, then one question (usually the newer one) should be closed as a duplicate of the other. You can indicate this by [voting to close it as a duplicate](https://superuser.com/help/privileges/close-questions) or, if you don't have enough reputation for that, [raise a flag](https://superuser.com/help/privileges/flag-posts) to indicate that it's a duplicate. Otherwise tailor your answer to this question and don't just paste the same answer in multiple places. – DavidPostill Mar 06 '20 at 19:36
1

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
  • 347
  • 1
  • 8
  • The problem is that soon as the installer begin the process it throws an error, described in the question. – Victor Aurélio Jan 15 '16 at 21:12
  • 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 Jan 15 '16 at 22:52
  • yes I've tried it too... – Victor Aurélio Jan 16 '16 at 02:02
  • 1
    The bottleneck is that the ISO files now contains too large files for fat32 to accept them. This is the case for Wndows10 1909 for example. – XavierStuvw Mar 24 '20 at 11:24
0

Try using Rufus with Wine.

Regards.

-1

I needed to create a bootable win10 USB drive for a UEFI system and this script was amazing: https://github.com/jsamr/bootiso/ try it!

In Summary:

First, install the bootiso by running these command:

git clone --branch latest https://github.com/jsamr/bootiso.git
cd bootiso
make install

Note: Make sure you have dependencies that you need. A list and a description can be found here.
Note 2: You can also install the bootiso from some package managers here.

Then run this to get some information about your *.iso file (Optional):

bootiso -p file.iso

Then run this to get some information about your available USB devices (Optional):

bootiso -l

Run this to format the USB

bootiso -f --device DEVICE_NAME (from the previous step)

Finally run this to install:

bootiso --mrsync file.iso --device DEVICE_NAME (from the previous step)

Done!