Posted on

Manjaro – create Windows USB

Creating a bootable USB from a Windows ISO

The reason for needing this could be e.g. reinstalling Windows but it could also be to update your system firmware – because the vendor only provided Windows binaries – you need a Windows system.

Don’t reinstall Windows – use an ISO with a Windows PE environment like Hiren’s BootCD https://www.hirensbootcd.org/

Only the manual approach described below was viable – until af few years ago when the github user slacka forked the WinUSB project. Thanks to his work the Linux community have an app to do abstract the CLI work.

WoeUSB

Use the package woeusb available from AUR

pamac build woeusb

If you get a loop device error using WoeUSB – check this comment below

Manual using CLI

Remove all removable devices (USB), open a terminal and list known disk devices

lsblk -la

Insert your USB stick and list your devices one more time

lsblk -la

Make a note of the extra device listed. If you only have one disk then it probably will be /dev/sdb.

Please do double check the device id

In the terminal clear the disk of any partition info, using this command (replace X with device letter from above).

sudo dd if=/dev/zero of=/dev/sdX bs=1M count=10 oflag=sync

Then use fdisk to create the filesystem needed for the Windows ISO (replace X with device letter from above).

sudo fdisk /dev/sdX

The commands in fdisk is as follows

The partitioning may need rework due to single file inside Windows ISO is larger than 4G.

  1. o – create a new empty DOS partition table
  2. n – add a new partition
  3. Enter – accept default partition type primary
  4. Enter – accept default partition number 1
  5. Enter – accept default first sector 2048
  6. Enter – accept default last sector
  7. t – change partition type
  8. c – select W95 FAT32 (LBA)
  9. a – set bootable flag for partition 1
  10. w – write changes to disk

Newer versions of Windows 10 ISO contains a file bigger than 4G. Format the device using exfat (replace X with device letter from above) to overcome the size limitation of FAT32.

sudo mkfs.exfat /dev/sdX1

Create a folder to mount your ISO

mkdir ~/winiso

Mount your ISO

sudo mount -o loop /path/to/windows/iso/filename.iso ~/winiso

Create a folder to mount your USB

mkdir ~/winusb

Mount the partition (replace X with device letter from above)

sudo mount /dev/sdX1 ~/winusb

Copy all files from ISO to USB

cd ~/winiso
cp -r * ~/winusb

The copy operation is going to take a long time depending on your USB port speed and your USB device.

When the copy is done ensure all data is flushed to the device using the sync command

sync

When all data is flushed to the device you will be returned to the prompt.
Next thing is to move back to your home

cd ~

Then unmount the devices

sudo umount ~/winiso ~/winusb

Remove the folders

rm -rf ~/winiso ~/winusb