Create a bootable Windows USB on Linux | ||
---|---|---|
Prev | Created by Bayou. | Index |
At least, I was able to produce a second Windows USB stick following the article below. Insead of using gdisk, the article now uses fdisk to create GPT partitions. I've toggeled the boot flag for the first partition and made sure that the BIOS is able to boot from EFI devices.
This took long enough, but I finally did it. Here it goes.
First locate your usb drive. Usually this is /dev/sdb.
$ fdisk -l
Disk /dev/sda: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5042cd84
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 479801343 479799296 228.8G 83 Linux
/dev/sda2 479803390 500117503 20314114 9.7G 5 Extended
/dev/sda5 479803392 500117503 20314112 9.7G 82 Linux swap / Solaris
Disk /dev/loop0: 5.1 GiB, 5421459456 bytes, 10588788 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdb: 7.5 GiB, 8053063680 bytes, 15728640 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: DFBFD068-A891-494C-9F3B-8BC9A2F28D7
Then create a GUID partition table (GTP). Delete any partitions if their present.
# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.33.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): m
Help:
GPT
M enter protective/hybrid MBR
Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
i print information about a partition
Misc
m print this menu
x extra functionality (experts only)
Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file
Save & Exit
w write table to disk and exit
q quit without saving changes
Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table
Command (m for help): g
Created a new GPT disklabel (GUID: DE302DFB-2DD0-DB42-A647-A4CEC9C379DD).
Command (m for help): n
Partition number (1-128, default 1):
First sector (2048-15728606, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-15728606, default 15728606):
Created a new partition 1 of type 'Linux filesystem' and of size 7.5 GiB.
Command (m for help): M
Entering protective/hybrid MBR disklabel.
Command (m for help): a
Selected partition 1
The bootable flag on partition 1 is enabled now.
Command (m for help): M
Leaving nested disklabel.
Command (m for help): p
Disk /dev/sdb: 7.5 GiB, 8053063680 bytes, 15728640 sectors
Disk model: Flash Disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: DE302DFB-2DD0-DB42-A647-A4CEC9C379DD
Device Start End Sectors Size Type
/dev/sdb1 2048 15728606 15726559 7.5G Linux filesystem
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Now formwat the partition to FAT32.
mkdosfs -F 32 -I /dev/sdb1
Nice. Now download a Windows ISO from their website. I used Windows 10. After this, shrink some data in the ISO.
$ mkdir tmp iso
$ mount Win10_20H2_v2_EnglishInternational_x64.iso tmp
$ cp -rT tmp/ iso/
$ cd iso/sources
$ wimlib-imagex optimize install.wim --solid # 4 cores i7-5600U CPU @ 2.60GHz around 35 min.
$ cd -
$ mount /dev/sdb1 /mnt/usb
$ cp -rT iso/ /mnt/usb && sync
$ umount /mnt/usb
The USB is ready. If this doesn't work for you, try to toggle the boot flag on the USB.
Prev | Home | Next |
Index | Up | Index |