Monday, October 18, 2021

How to create a Windows bootable USB drive on Linux

This error gave me some headache:

Cannot find C:\sources\install.wim

That was the error I got after I inserting a freshly created USB stick with a Windows 10 disk image for installation on a new (empty) PC that my son just assembled.

  • What went wrong?
    The file "install.wim" has a size of 4.6 GB, which is too large for a USB drive formatted in FAT32.
  • The solution:
    Format your USB drive in exFAT.
Whether this was your problem or not, here are the instructions, how to create a USB drive on a Linux computer for installing Windows. I did this for Windows 10, but it should work for any other version. I used a Kubuntu 21.04 system, but it should also work on any other Ubuntu-based Linux distribution.


Step-by-Step Guide

There are two tasks to be done: First, format the USB drive to exFAT, and, second, install the Windows .iso file.


Formatting a USB drive to exFAT 

These simple steps are all done on the command line.
  1. Download the Windows .iso file from Microsoft
  2. The following procedure require the"exfat-utils" which were not installed by default on my Kubuntu 21.04. You can install these from your software center (Discover, Muon, or whatever you prefer) or from the command line:         sudo apt install exfat-utils
  3. Insert the USB stick (at least 8GB) in your Linux system and mount it (e.g. from the file manager).
  4. Find the device ID of the USB stick. There are many ways how to do this. I use
    df -m
    from the command line. It displays all available filesystems, their status and their IDs  If you compare the output of this command before and after mounting the USB stick, you can identify the USB stick. For me it is: 
    /dev/sdb1   14798   5574  9224  38% /media/username/9B62-A3DF
    So, the device ID is "/dev/sdb1".  Sometimes my USB drives are also mounted as "/dev/sdc1". Remember this device ID!
  5. Unmount the USB drive, either from the filemanager (right click, "safely remove") or from the command line (replace "/dev/sdb1" with your device ID, if different):
    umount /dev/sdb1 
  6. Format the USB drive to ExFat (again, replace "/dev/sdb1" with your device ID, if different):
    sudo mkfs.exfat /dev/sdb1
  7. Mount the freshly formatted USB drive (you may have to remove and re-insert it).


Install the Windows .iso File

Now, there are different options, how to install the Windows .iso file on the USB drive, either using the File Manager, or the "unetbootin" app. (Of course, you only need to do one of the two).
  1. I prefer using the File Manager, which does not require to install any additional software. For this, open the Folder in which you stored the Windows .iso file that you got from Microsoft. Right-click on the .iso file and select "Mount ISO". A new entry will show up on the left bar in the File Manager (with a weird name). Click on this, and the File Manager will display the content of the .iso file
     

    In a second instance of the File Manager, open the (empty, freshly formatted) USB drive. Then, using the mouse, select all the files from the .iso and copy them over to the USB drive. This will take a few minutes (after all these are >5 GB).
    The following  is not necessary, but as a cross check you may want to enter the folder "sources", hover the mouse over the file "install.wim" and confirm that its size is 4.6 GB.


  2. Alternatively, you can get "unetbootin" from here: https://unetbootin.github.io/. Download the version for your OS (for me it was "Linux", "64 bit binary"). In my case, the downloaded file has the name "unetbootin-linux64-702.bin" (which may differ for future releases) and it's stored in the directory "~/Download". After mounting your USB drive, you run:
    sudo ~/Downloads/unetbootin-linux64-702.bin
    During startup, I get some error messages mentioning "Arch Linux" and "mtools" which I just ignore (just press "ok"). This opens the following window.
    Here, you select (1.) "DiskImage", (2.) select the Windows .iso file, select (3.) "USB Drive" and (4.) your drive ID ("/dev/sdb1" or correspondingly), and (5.) press "OK".
This worked for me, and my son is now happily running Windows on his new PC.
Please let me know in the comments, if it helped you or if you ran into any problems.

No comments: