Tuesday, December 24, 2019

Fedora: Create a UEFI Bootable USB Stick to Install Windows or Linux

Creating a bootable stick is actually quite easy and you can do it from he command line. Fedora provides all the tools that are required. This tutorial will use a windows 10 iso image. You can obtain this from Microsoft here. It is free and you can use it forever for free with some minor cosmetic limitations.

This requires root access so the first thing you want to do is to log into a terminal as root:
# sudo -i

You probably already have these:
# dnf install gdisk syslinux syslinux-efi64

Now identify the device:
# lsblk -S

Make sure that the stick is unmounted. We are going to clear everything. This will remove all data from the stick. Replace the “x” with your device letter. Double check that you are zapping the correct device:
# sgdisk -Z /dev/sdx

Now create two directories that are easy to identify. I'll make mine in the current directory:
# mkdir usb win

Create a partition and make it bootable:
# echo ',,c;*' | sfdisk /dev/sdx

Format the partition as FAT32:
# mkfs.vfat -F32 /dev/sdx1 -n "WINDOWS"

Syslinux provides the mbr that you need:
# dd if=/usr/share/syslinux/mbr.bin of=/dev/sdx bs=440 count=1

Now install syslinux to the formatted partition:
# syslinux -i /dev/sdx1

Mount the partition:
# mount /dev/sdx1 usb

Create a syslinux directory:
# mkdir usb/syslinux

Now copy all of the syslinux modules into the new directory. You do not need all of these but it is simpler to just copy them all (1mb total):
# cp /usr/share/syslinux/*.c32 usb/syslinux
# cp /usr/share/syslinux/efi64/*.c32 usb/syslinux

Paste the following into usb/syslinux/syslinux.cfg:
default boot
LABEL boot
MENU LABEL boot
COM32 chain.c32
APPEND fs ntldr=/bootmgr
# nano usb/syslinux/syslinux.cfg

Mount the Windows iso:
# mount -o loop windows.whatever.iso win

Almost done. Copy all of the windows files to the stick:
# cp -r win/* usb

Do not remove the stick until it is unmounted. Unmounting completes the writes:
# umount /dev/sdx1 
# umount win
Follow the same process for a linux distribution. Note: syslinux requires FAT/FAT32. Do not change the format to ext4.

Related content:



No comments:

Post a Comment

Please be civil and do NOT link to anti-gay sites!

Note: Only a member of this blog may post a comment.