Create a Windows installer USB from Linux

In this article we’ll cover how to properly prepare a USB thumb drive with Windows installer files.

There are several articles stating to simply copy the ISO to the USB in raw format (using dd), however most of the time this will lead to a “A media driver your computer needs is missing” error in the initial phase of Windows setup.

Here is the proper procedure, and it does not requires any third-party tool.

1. Get the ISO file from Microsoft site.

    2. Install the wimtools package

    sudo apt install wimtools

    3. Plug the USB drive and identity the device name with fdisk -l

    4. Create a GPT partition table in the USB drive with an 8 GB NTFS primary partition starting on sector 2048 (substitute DEV with the device identified in step 3):

    DEV=/dev/sdh
    sudo wipefs -a /dev/$DEV
    sudo parted -s /dev/$DEV -- mklabel gpt \
    mkpart primary ntfs 2048s 8G

    4. Create the filesystem (substitute USBDEVICE with the device identified in step 3):

    sudo mkfs.ntfs -Q /dev/${DEV}1

    5. Mount the filesystems:

    mkdir /tmp/usb
    sudo mount /dev/${DEV}1 /tmp/usb

    6. Mount the ISO and copy the files to the USB:

    sudo mount -o ro,loop Win11_24H2_English_x64.iso /mnt
    rsync -rtdvP --exclude sources/install.wim /mnt/* /tmp/usb

    7. Unmount and cleanup

    sudo umount /tmp/usb
    sudo umount /mnt
    rmdir /tmp/usb

    Now you can plug the USB drive in any computer you want to install Windows into.