Skip to content

Instantly share code, notes, and snippets.

@JOduMonT
Created November 15, 2022 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JOduMonT/8ecc0c97fe869f16a9516761bb8fbb80 to your computer and use it in GitHub Desktop.
Save JOduMonT/8ecc0c97fe869f16a9516761bb8fbb80 to your computer and use it in GitHub Desktop.
Creating a bootable Windows 10/11 USB flash drive in CLI Linux/Mac

How to create a bootable Windows 10/11 USB flash drive in Linux/Mac.

1. Download Windows image (iso)

2. Plug your USB flash drive

Linux detected /dev/sde as the USB stick, in your case it will most likely take a different name.

3. Format your USB flash drive

Work as root account and make sure to replace /dev/sde with your USB flash drive! Use lsblk and dmesg | tail -50 commands to locate your USB flash drive.

wipefs -a /dev/sde

parted /dev/sde
(parted) mklabel gpt                                                      
(parted) mkpart BOOT fat32 0% 1GiB
(parted) mkpart INSTALL ntfs 1GiB 10GiB
(parted) quit

Check the drive layout now:

In my case I've used 100% instead of 10GiB when created the "INSTALL" ntfs partition - mkpart INSTALL ntfs 1GiB 100%. But you can use anything that should be larger than 6 GiB to fit the data from Windows ISO image. parted /dev/sde unit B print

Model: SanDisk Extreme (scsi)
Disk /dev/sde: 62742792192B
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 1048576B 1073741823B 1072693248B BOOT msftdata
2 1073741824B 62742593535B 61668851712B INSTALL msftdata

4. Mount Windows ISO somewhere

I mounted it to /mnt/iso directory:

mkdir /mnt/iso
mount /home/<your user>/Downloads/Win11_English_x64v1.iso /mnt/iso/

5. Format 1st partition of your USB flash drive as FAT32

mkfs.vfat -n BOOT /dev/sde1
mkdir /mnt/vfat
mount /dev/sde1 /mnt/vfat/

6. Copy everything from Windows ISO image except for the sources directory there

rsync -r --progress --exclude sources --delete-before /mnt/iso/ /mnt/vfat/

7. Copy only boot.wim file from the sources directory, while keeping the same path layout

mkdir /mnt/vfat/sources
cp /mnt/iso/sources/boot.wim /mnt/vfat/sources/

8. Format 2nd partition of your USB flash drive as NTFS

mkfs.ntfs --quick -L INSTALL /dev/sde2 
mkdir /mnt/ntfs
mount /dev/sde2 /mnt/ntfs

9. Copy everything from Windows ISO image there

rsync -r --progress --delete-before /mnt/iso/ /mnt/ntfs/

10. Unmount the USB flash drive and Windows ISO image

umount /mnt/ntfs
umount /mnt/vfat
umount /mnt/iso
sync

11. Power off your USB flash drive

udisksctl power-off -b /dev/sde

Done Now you are ready to boot off of your USB flash drive to install Windows 11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment