Make a bootable Windows USB from Linux

 Posted by:   Posted on:   Updated on:  2019-10-25T19:24:59Z

Here is how to create a bootable USB flash drive to install Windows Vista, Windows 7, Windows 8, Windows 8.1 and Windows 10 on any computer. Legacy BIOS and UEFI are supported.

Ubuntu has already an application called Startup Disk Creator, but this can only be used to make Linux bootable USB drives. To make a Windows bootable USB there was an application called WinUSB but it is no longer under active development. The following guide has been updated and works on any Linux distribution as long as it has GRUB and GParted installed and can make bootable USB for any Windows version newer than Vista: Windows Vista, Windows 7, Windows 8, Windows 8.1 and Windows 10. UEFI boot is only supported for Windows 7 x64 and newer.

Before starting, let's mention that there are two types of boot methods. There is the MBR code type where the bootable executable is stored in a reserved section at the beginning of the storage device. And there is the EFI type, where the boot loader executable file is stored at a standard path in an FAT32 filesystem. You must decide in advance what you will use. There are some variables for each boot type. If you have no idea what to use, the most common setup that works with unmodified Windows sources, is msdos partition table with fat32 filesystem and flag the partition with boot. In this way you will get both an MBR and UEFI bootable drive.

The latest Windows release can be downloaded from Microsoft as an ISO image. The ISO download page is available to non-Windows users. Otherwise, you are directed to download Media Creation Tool, which is Windows only software.

Make a bootable Windows USB from Linux (Ubuntu)

Partition table Filesystem Partition flag
MBR bootable msdos ntfs / fat32 boot
UEFI bootable msdos / gpt fat32 boot / msftdata *
* msdos should be flagged with boot and gpt should be flagged with msftdata.

UEFI can only boot FAT32 drives! If you need to make an NTFS UEFI bootable flashdrive to remove the 4 GB maximum file size restriction of FAT32 see this: UEFI NTFS: Bootable Windows USB from Linux. There is also a video version of what is about to follow.

Format USB drive

This is the first step. GParted has a nice GUI and it is easy to use for this. So, plug in your USB flashdrive and start GParted (root permissions required). Select the USB drive and unmount it, otherwise you won't be able to format it. Richt click on the mounted partition from the selected device and select Unmount in the context menu.

Warning! Selecting the wrong device will result in data loss!
GParted main window screenshot emphasizing device

GParted main window. The first thing to do is select the USB drive and unmount it.

You must re-create the partition table by going to the Device menu then select Create Partition Table. Choose msdos (or gpt if you want an UEFI only bootable drive) and click Apply.

GParted - Write a new partition table on the device

Write a new partition table on the device

Right click the unallocated space and select New. Make a primary NTFS or FAT32 partition and give it a label too. The label must be as strange as possible because the bootloader will identify the bootable partition by this and you should not use windows (like I did in the video)! If the filesystem is FAT32 use only uppercase letters. For example: WUSB1840 would be a good label (W for Windows, USB for USB flash drive and 18:40 is the time I was writing this). Remember the label as you will need it later.

If you have a customized Windows with install.wim larger than 4 GB you should definitely go for NTFS. Otherwise, if you choose FAT32, you could get the flashdrive bootable from UEFI too.

GParted new partition dialog

New partition dialog

Apply all pending operation from Edit menu - Apply all operations or click the button on the main window. Right click the partition and choose Manage flags. If you chose the msdos partition table tick boot. If you chose the gpt partition table, msftdata should already be checked and you don't have to do anything.

GParted main window - Apply button emphasized screenshot

The Apply button from the main window of GParted

Copy Windows files

Quit GParted and use the file manager to copy all files from Windows ISO to USB stick. Mount the ISO using Open with - Disk Image Mounter (if you use Nautilus as a file manager). If that fails you can use Furius ISO Mount and loop-mount the ISO. Select all files Ctrl+A and Copy to USB drive which will be automatically mounted when you click on it at /media/<username>/<drive_label>. After the copy process is finished, look in the USB root folder for the boot directory. If it is uppercase, rename it to lowercase.

Make it bootable

If you used NTFS filesystem and MSDOS table, only method A is available. If you used FAT32 and MSDOS table, you can apply method A, B or both. If you used GPT partition table, only method B should be followed.

Method A: MBR bootable

GRUB will be used for that. Open a Terminal and run:

sudo grub-install --target=i386-pc --boot-directory="/media/<username>/<drive_label>/boot" /dev/sdX

Replace:

  • /media/<username>/<drive_label> with the path where USB drive is mounted;
  • /dev/sdX with the USB drive, not the partition (e.g. /dev/sdb)
Warning! Selecting the wrong device (/dev/sdX) may result in bootloader corruption of the running operating system!

Wait for it to finish. If everything is OK, you should see:

Installing for i386-pc platform.  
Installation finished. No error reported.

Now, create a text file and write the following in it:

default=1  
timeout=15
color_normal=light-cyan/dark-gray
menu_color_normal=black/light-cyan
menu_color_highlight=white/black
 
menuentry "Start Windows Installation" {
    insmod ntfs
    insmod search_label
    search --no-floppy --set=root --label <USB_drive_label> --hint hd0,msdos1
    ntldr /bootmgr
    boot
}

menuentry "Boot from the first hard drive" {
    insmod ntfs
    insmod chain
    insmod part_msdos
    insmod part_gpt
    set root=(hd1)
    chainloader +1
    boot
}

Replace <USB_drive_label> with the label you gave it when you formatted the drive (you can place it between quotes if it contains a space, although it is not recommended to use spaces in drive label). Save the file as grub.cfg and put it on the USB drive in the boot/grub folder. That's it. The USB drive is now bootable from BIOS and can be used to install Windows on your PC. The first time you boot from it in MBR BIOS or CSM mode select Start Windows Installation.

Method B: UEFI bootable

Not all Windows versions are supported. Windows 7 on 64 bits, Windows 8 and newer versions should work. After the copy process is finished, look in the USB root folder for the efi/boot directory. If there's a bootx64.efi or bootia32.efi file there, then you're done. You can boot from your USB in UEFI mode.

If the OS you are making a bootable USB for is Windows 7, browse the efi/microsoft folder and copy the entire boot folder from this path one level up in the efi folder. Merge folders if boot already exists. Here is what to do if you don't have the bootx64.efi file in efi/boot folder. Browse the mounted Windows ISO image into the sources folder. Open install.wim (or install.esd) with your archive manager (you will need 7z installed). Go to the path ./1/Windows/Boot/EFI and extract the file bootmgfw.efi anywhere you want. Rename it to bootx64.efi and put it on the USB drive, in the efi/boot folder. If you can't find bootmgfw.efi in install.wim then you probably have a 32 bit Windows ISO or other types of images (recovery disks, upgrade versions).

You can now boot from your USB in UEFI mode.

Errors

1. modinfo.sh doesn't exist

grub-install: error: /usr/lib/grub/i386-pc/modinfo.sh doesn't exist. Please specify --target or --directory.

Install the grub-pc-bin package with sudo apt install grub-pc-bin and run the grub-install command again.

2. Embedding errors

If you get embedding errors (something like filesystem 'x' does not support embedding or Embedding is not possible), be sure you are installing GRUB to USB device and not USB partition. Most likely you typed /dev/sdb1 instead of /dev/sdb (sdb is just an example here). If it still doesn't work, try zeroing the USB drive (at least some sectors at beggining) or use a different USB flash drive.

3. Blocklists

Sometimes, GRUB will not install on some flash drives. Try to force it by adding --force argument to the grub-install command.

4. Alternate root partition selection

The root partition selection may fail if your USB flash drive partition has the same label as one of the partitions on the target computer. The best way of setting the root partition is by UUID. Launch again GParted and select the USB flashdrive. Right click the partition and select Information. Note the UUID field.

GParted partition information UUID

Partition UUID

In grub.cfg, replace the line:

search --no-floppy --set=root --label <USB_drive_label> --hint hd0,msdos1

with:

insmod search_fs_uuid
search --no-floppy --fs-uuid --set root <drive_UUID>

where you will replace <drive_UUID> with the UUID you got from GParted.

Still getting errors? If you want an useful answer, please post a comment with the complete grub-install command and the error message.

Links

77 comments :

  1. Amazing! I used Etcher and it didn't work, but with your steps it was extremely straightforward. Thanks!

    ReplyDelete
  2. Thanks for your tutorial, after so many reattempts, finally got clear instructions.

    ReplyDelete
  3. Prasanth MadhurapantulaMarch 7, 2018 at 7:16 PM

    Great Tutorial! Thank You. For people who want to install Windows 7 on a PC that came with Windows 8 or 10 change the BIOS Settings to allow the installation of older Operating Systems.

    ReplyDelete
  4. I'm getting two errors. /bootmgr not found and "You need to load the kernel first"

    ReplyDelete
    Replies
    1. Grub can't find bootmgr in the root of the USB drive. Have you copied Windows files correctly?

      Delete
    2. Did you figure out what was wrong with yours? I am also getting the grub cant find bootmgr message.

      Delete
    3. Never mind I figured it out

      Delete
    4. I'm getting these same errors as well as "one argument expected" help anyone?

      Delete
  5. I try to install a bootable windows 7 install usb from my live knoppix 8.1

    Grub doesn't offer the "target" and "boot-directory" options, the knoppix install only supports i386 though and has the option "root-directory"

    Running the altered code i get following error:

    sudo grub-install --root-directory="/media/sdc1" /dev/sdc

    Unknown partition table signature
    Unknown partition table signature
    Unknown partition table signature
    Unknown partition table signature
    Unknown partition table signature
    The file /media/sdc1/boot/grub/stage1 not read correctly.

    I hope you can help me out here.

    ReplyDelete
    Replies
    1. I once tried this from a live Ubuntu. It gave me some errors too. I don't think this works from live medium.

      Delete
  6. I followed the steps and got "Installing for i386-pc platform.
    Installation finished. No error reported." at the last step.But when I boot using the flash drive I get a grub command line instead of the "Start Windows Installation"

    ReplyDelete
    Replies
    1. GRUB doesn't find the grub.cfg file or it has incorrect syntax. Check if the file is placed in the right folder and if its name is written correctly (some copied "grub.cfg " - with a space at the end - and had similar issues).

      Delete
    2. I have tried this but still get the grub command line.

      When I copied over the iso contents there was no "grub" folder within "boot" so I made one, and then placed the "grub.cfg" file inside it but to no avail. I also copied the file into the "boot" folder and tried, but no luck there either

      Delete
    3. The grub folder appears after you run grub-install.

      Delete
    4. I do not see any additional files nor directories after successful install
      "Installing for i386-pc platform.
      Installation finished. No error reported."
      I've added /grub/grub.cfg file manually into boot.
      My usb drive is mounted on /dev/sda. Any attempt to boot from it terminates by grub rescue.

      Delete
    5. If I could delete my previous post I would do it !
      Right after posting my problem I checked once again the whole procedure (very well done, I love it!) and I found the cause. When I typed the drive label I mismatch uppercase/lowercase :-( My fault and I thank again for this tutorial which saved my other laptop. The windows installation is running there (and it will take some time as windows is not ubuntu :-)

      Delete
    6. No worries. It's great you figured it out!

      Delete
  7. I have gotten past the empty grub menu but now I juat get a blank screen when it loads. I have tried this with both a windows 7 and 10 install but get the same problem

    ReplyDelete
  8. I followed all of the instructions and got no errors, but it just boots to a black screen and nothing happens. Bad ISO?

    ReplyDelete
  9. Works like a charm. Thank you so much.

    ReplyDelete
  10. Dude ! Thatnk a lot !! I struggled a lot but finally found solution here ! And itsi working

    ReplyDelete
  11. Bless you, sir. Bless you

    ReplyDelete
  12. I got a black screen with a flashing underscore :(

    ReplyDelete
  13. I've tried the usual stuff with dd and cp, which works for every Linux and also worked with windows years ago. But now only this method seems to work, so many thanks!

    I may suggest, just to help you no offense meant, to design this blogpost more clear. It is very complete and covers almost all possibilities, but usually one is not looking for that. You even handle 32 bit for every step. Its a lot to read between the parts that i was interested in, which was basically:

    1. Format your drive msdos and create a fat32 partition.
    2. your step 2

    your step 3 wasnt neccessary at all. May explain how formatting is done on demand though, though folding text e.g.

    ReplyDelete
  14. i am getting error while installing as
    error: file '/boot/grub/i386-pc/normal.mod' not found

    i am trying to install win 10 on a legacy boot pc which only had windows 7 before .

    can you help

    ReplyDelete
  15. Thank you,Thank you,Thank you, you saved my day

    ReplyDelete
  16. Hi, the grub-install seems to be failing...any idea of the error below:

    grub-install: warning: File system `ntfs' doesn't support embedding.
    grub-install: warning: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and their use is discouraged..
    grub-install: error: will not proceed with blocklists.

    THanks for your help

    ReplyDelete
    Replies
    1. "You are getting the warning because you are installing grub to a partition instead of the MBR. This means grub can not be embedded in the unused space between the MBR and the first partition." See https://unix.stackexchange.com/questions/174206/warning-file-system-ext2-doesnt-support-embedding-but-my-system-isnt-emb.

      Delete
  17. For anyone who is having an error "install.wim file too large" you need to split the install.wim file in the sources folder from the disk image. For linux users, install wimtools and use wimsplit from the terminal.

    ReplyDelete
    Replies
    1. I followed the steps outlined here to shrink the install.wim file:
      https://tqdev.com/2019-cannot-copy-windows-10-install-wim

      Delete
  18. My boots back into linux mint on selecting the usb help pls

    ReplyDelete
  19. I just can't put the changed bootx64.efi file back onto the boot usb stick since it thinks it's a CD_ROM. Would there be any chance for help for me?

    ReplyDelete
  20. I've got the modinfo error. The problem is that grub-pc-bin isn't in the repos...

    ReplyDelete
    Replies
    1. I don't know what Linux distribution you are using. The package is available in Ubuntu.

      apt search grub-pc-bin
      Sorting... Terminat
      Full Text Search... Terminat
      grub-pc-bin/eoan,now 2.04-1ubuntu12 amd64 [installed]
      GRand Unified Bootloader, version 2 (PC/BIOS modules)

      Delete
  21. FINALLY! a web page that explains a way of doing this without a windows box or ubuntu-only tools... good ol' GRUB! Followed instructions and it worked first time, Thank you!

    ReplyDelete
  22. This was great, extremely useful!! Much appreciated.

    I tried to be rad and use fdisk instead of gparted but I don't know how to set the drive label in fdisk. Either way, you nailed it!

    ReplyDelete
  23. Thanks a lot. I have a question. Can I use these intructions to boot ReactOS (that free, opensource reimplementation of windows) on my ubuntu laptop?

    ReplyDelete
    Replies
    1. I have never tried this with ReactOS, although I guess GRUB can boot it.

      Delete
    2. Grub installation finishes with no error in ReactOS USB, but grub folder it's not created in any part of the it. I think this is because, form the beggining, the /USB/boot directory does not exist. Shall I create it manually or something like that? Thanks again

      Delete
    3. Yes, make that folder and repeat grub-install.

      Delete
  24. hi need some help
    i keep getting this error, what can i do to fix it?
    rub-install: error: cannot open `/media/famojeda/windows/boot/grub/i386-pc/terminal.mod': Input/output error.

    ReplyDelete
  25. It worked perfectly. Thanks.

    ReplyDelete
  26. Everything works great, but when I select "Start Windows Installation" in grub, my pc restarts to the same screen and nothing happens. Do you know what's going on?

    ReplyDelete
  27. This error pops up.. help!!

    Installing for i386-pc platform.
    grub-install: error: cannot find a GRUB drive for /dev/sdX. Check your device.map.

    ReplyDelete
  28. When i tried to create new document in boot file its says error in ubuntu and icant configure grub please reply sir please please

    ReplyDelete
    Replies
    1. You can't create a "new document in boot file". You are probably in the wrong boot folder.

      Delete
  29. grub-install: error: install device isn't specified. HELP PLEASE.

    ReplyDelete
  30. Thank you soo much. Works like a charm. When I load into windows setup menu I get the driver error, I googled it an it seems that windows 7 doesn't have native usb 3.0 support. I've watched videos for fixing this but they all use windows only softwares to fix it. Can you tell me how can I do it?

    ReplyDelete
    Replies
    1. That is a Windows issue. Plug USB drive in USB 2.0 port for installation and provide necessary drivers on an additional USB drive (if required).

      Delete
  31. Выполняется установка для платформы i386-pc.
    grub-install: предупреждение: Файловая система «udf» не поддерживает встраивание.
    grub-install: ошибка: встраивание невозможно, но оно необходимо для междисковой установки.

    ReplyDelete
  32. I cannot copy the sources file into my USB drive because it keeps saying that install.wim is too large. It is a 16gb USB drive with nothing else on it, so I can't figure out why it is saying that or how to fix it. What can I do?

    ReplyDelete
    Replies
    1. Probably you are trying to use a fat32 partition, in the text beginning he shows a link to solve this problem.

      Delete
  33. Bro, you saved my life. God bless you!

    ReplyDelete
  34. Great tutorial, man! It made my day!

    ReplyDelete
  35. TheMegaPirate77 about half of what you said was correct but that means the other half is wrong,haha ofc hacking is illegal but opening up ISO's is only illegal if you pirate them, what most people would do and this is legal is if they have the game disc they would take the ISO's and do this so they wont have to put in the disc to play on the other hand the illegal part is if you go to a site and download the isos and do this that is pirating same thing as downloading mp3s and puting on ipod.
    Joseph Donahue

    ReplyDelete
  36. Great Tutorial! Thanks for sharing. It was written in simple word which is easy to understand. Thanks again. Abhishek Panwar

    ReplyDelete
  37. thanks i wanted to install poweriso but it contained adware and chromium browser needs to be installed to install poweriso so i found you and you helped me allot thanks .

    CrazyAsk


    ReplyDelete
  38. I followed all the steps, but can't see the USB in the bootable window. Any advice?

    ReplyDelete
  39. I followed all the steps, but can't see the USB in the boot menu. Any advice?

    ReplyDelete
  40. Man you're a f**cking legend. I spent like more than 50 hours to find out answers on this topic. Tried a lot of stuff like UNetbooting and WoeUSB, and the only thing that worked was Rufus ran from Windows. Now , with the help of your blog, I can finally make bootable USBs with Windows. From this blog I've tried MBR+FAT32+WIN7+Grub and it worked, and also GPT+FAT32+UEFI worked. Thanks a lot for this information man! You saved men tens of hours ))

    ReplyDelete
  41. What an amazing blog post you have written and I was in search of such kind of post for a long time, Thank You!

    ReplyDelete
  42. Man whoever you are, you are a genius. Just mind blowing. I have never come across such a tutorial where someone cam write .cfg files himself. So much of deep knowledge you have. You just saved me here. You have my respect. You are my idol.. ❤️❤️❤️

    ReplyDelete
    Replies
    1. Thank you! I am surprised to see this still works after some years.

      Delete
  43. I went to the comments thinking that you didn't answer the comments anymore, but you still help the people in here after all these years, you got some real dedication haha.
    I used the method B, i followed every step and didn't ran into much problems in following them, but when i tried to boot it just didn't work, it just got stuck in a black screen with a flashing underscore, i thought that it just need some time, but i let this going for almost two hours and nothing happened. I really don't know where it went wrong :(

    ReplyDelete
    Replies
    1. I'm back, after some hours, i tried some more times the method B but it just refused to work, i almost gave up, i didn't used the method A first because i thought that it wouldn't work in my computer, but as my last hope i did the method A and it worked in my first try, i am so happy, when the windows installation screen popped up in the screen i almost jumped in happiness. Thank you so much for making that guide, i searched for days looking for a way to install windows on a uefi using linux and found just nothing, you saved me from just throwing my whole pc in the wall hahaha.

      Delete
    2. Method B sometimes does not work, I don't know why... However, it is good to know you got the job done with A.

      Delete
  44. Unfortunately it does not work for WinXP. bootmgr is missing

    ReplyDelete
    Replies
    1. Sorry, it doesn't work with 20 years old operating systems.

      Delete

Please read the comments policy before publishing your comment.