Skip to content

Instantly share code, notes, and snippets.

@paulrobu
Last active November 9, 2021 00:11
Show Gist options
  • Save paulrobu/838273110c0721bb3d05622bcd1e3441 to your computer and use it in GitHub Desktop.
Save paulrobu/838273110c0721bb3d05622bcd1e3441 to your computer and use it in GitHub Desktop.
How to Create a Bootable Windows 10 USB in Linux

Use https://github.com/WoeUSB/WoeUSB/releases/tag/v5.1.3 (it fixes the issue with uefi-ntfs image larger than 512kB - ref https://askubuntu.com/questions/1371599/trying-to-create-bootable-windows10-usb-drive-with-woeusb-seems-uefi-ntfs-img-i )

$ sudo ./woeusb-5.1.3.bash -h
ERROR: WoeUSB requires wimlib-imagex command in the executable search path, but it is not found.

Extract wimlib-imagex from http://manpages.ubuntu.com/manpages/focal/man1/wimlib-imagex.1.html and add it to $PATH

$ sudo cp wimlib-imagex /bin
$ sudo ./woeusb-5.1.3.bash -h
WoeUSB 5.1.3 Help Information
======================================
WoeUSB can create a bootable Microsoft Windows(R) USB storage device from an existing Windows optical disk or an ISO disk image.

Currently two creation methods are supported:

    --device, -d

        Completely WIPE the entire USB storage device, then build a bootable Windows USB device from scratch.
        WARNING: All previous data on the device will be gone!

        woeusb-5 --device <source media path> <device>
        Examples:
        - woeusb-5 --device Windows7_x64.iso /dev/sdX
        - woeusb-5 --device /dev/sr0 /dev/sdX

    --partition, -p

        Copy Windows files to an existing partition of a USB storage device and make it bootable.  This allows files to coexist as long as no filename conflict exists.
        WARNING: All files that has the same name will be overwritten!

        woeusb-5 --partition <source media path> <partition>
        Examples:
        - woeusb-5 --partition Windows7_x64.iso /dev/sdX1
        - woeusb-5 --partition /dev/sr0 /dev/sdX1

## Command-line Options ##
    --verbose, -v
        Verbose mode

    --help, -h
        Show this help message and exit

    --version, -V
        Print application version

    --about, -ab
        Show info about this application

    --no-color
        Disable message coloring

    --debug
        Enable script debugging

    --label, -l <filesystem_label>
        Specify label for the newly created file system in --device creation method
        Note that the label is not verified for validity and may be illegal for the filesystem

    --workaround-bios-boot-flag
        Workaround BIOS bug that won't include the device in boot menu if non of the partition's boot flag is toggled

    --debugging-internal-function-call <function name> (function_argument)...
        Development option for developers to test certain function without running the entire build

    --target-filesystem, --tgt-fs <filesystem name>
        Specify the filesystem to use as the target partition's filesystem.
        Currently supported: FAT(default)/NTFS

    --for-gui
        No longer supported, reserved for compatibility with the wrapper programs

Run the script with --target-filesystem NTFS --device parameters. E.g.,

$ sudo ./woeusb-5.1.3.bash --target-filesystem NTFS --device Win10_21H1_English_x64.iso /dev/sdb
WoeUSB v5.1.3
==============================
Info: Mounting source filesystem...
Info: Wiping all existing partition table and filesystem signatures in /dev/sdb...
/dev/sdb: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
/dev/sdb: calling ioctl to re-read partition table: Success
Info: Ensure that /dev/sdb is really wiped...
Info: Creating new partition table on /dev/sdb...
Info: Creating target partition...
Info: Making system realize that partition table has changed...
Info: Wait 3 seconds for block device nodes to populate...
Cluster size has been automatically set to 4096 bytes.
Creating NTFS volume structures.
....
1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.312217 s, 3.4 MB/s
Info: Mounting target filesystem...
Info: Copying files from source media...
Info: Installing GRUB bootloader for legacy PC booting support...
Installing for i386-pc platform.
Installation finished. No error reported.
Info: Installing custom GRUB config for legacy PC booting...
Info: Done :)
Info: The target device should be bootable now
Info: Unmounting and removing "/tmp/woeusb-source-20211109-014253-Tuesday.6VJrWY"...
Info: Unmounting and removing "/tmp/woeusb-target-20211109-014253-Tuesday.BqwvZr"...
Info: You may now safely detach the target device
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment