Please read and understand each command to minimize the risk for data loss. The risky commands are sgdisk, parted, mkfs.vfat and mkfs.ext4, so just be careful 🙂
lsblk -o +TRAN | grep -i usb
-> sdc 8:32 1 14.9G 0 disk usb
# DANGER ZONE #
sgdisk -Z /dev/sdc
parted -s /dev/sdc mklabel gpt mkpart ESP fat32 0% 1GiB mkpart fedora ext4 1GiB 100%
parted -s /dev/sdc set 1 esp on set 1 boot on
fdisk -l /dev/sdc | grep "^/dev"
-> /dev/sdc1 2048 2097151 2095104 1023M EFI System
-> /dev/sdc2 2097152 31348735 29251584 13.9G Linux filesystem
mkdir -p /mnt/usb_esp
mkfs.vfat /dev/sdc1
blkid /dev/sdc1 # the UUID= will be used later in the new grub.cfg
-> /dev/sdc1: UUID="975E-C325" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="ESP" PARTUUID="adc88af7-fcdb-4cfa-8b13-712eea5a6529"
mount /dev/sdc1 /mnt/usb_esp
mkdir -p /mnt/usb_fedora
mkfs.ext4 -F -b 4096 /dev/sdc2
tune2fs -L Fedora-WS-Live-3 /dev/sdc2
(i had to truncate the original label 'Fedora-WS-Live-37-1-7' to 'Fedora-WS-Live-3' because of ext4 label maximum length)
mount /dev/sdc2 /mnt/usb_fedora
mkdir -p /mnt/fedora_iso_mount
mount -t iso9660 -o ro,loop /home/username/Downloads/Fedora-Workstation-Live-x86_64-37-1.7.iso /mnt/fedora_iso_mount
cd /mnt/fedora_iso_mount
cp -R EFI boot images /mnt/usb_esp; sync
cp -R Fedora-Legal-README.txt LICENSE LiveOS /mnt/usb_fedora; sync
cd /
ls -al /mnt/usb_esp
total 16
drwxr-xr-x 5 root root 4096 Jan 1 1970 .
drwxr-xr-x 1 root root 66 Apr 3 22:31 ..
drwxr-xr-x 3 root root 4096 Apr 3 22:53 EFI
drwxr-xr-x 3 root root 4096 Apr 3 22:53 boot
drwxr-xr-x 3 root root 4096 Apr 3 22:53 images
ls -al /mnt/usb_fedora
total 32
drwxr-xr-x 4 root root 4096 Apr 3 22:55 .
drwxr-xr-x 1 root root 66 Apr 3 22:31 ..
-rw-r--r-- 1 root root 2574 Apr 3 22:55 Fedora-Legal-README.txt
-rw-r--r-- 1 root root 1063 Apr 3 22:55 LICENSE
drwxr-xr-x 2 root root 4096 Apr 3 22:55 LiveOS
drwx------ 2 root root 16384 Apr 3 22:51 lost+found
replace the following config in /mnt/usb_esp/EFI/BOOT/grub.cfg:
set default="1"
function load_video {
insmod efi_gop
insmod efi_uga
insmod video_bochs
insmod video_cirrus
insmod all_video
}
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
set timeout=60
### END /etc/grub.d/00_header ###
search --no-floppy --set=root -l 'Fedora-WS-Live-37-1-7'
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Start Fedora-Workstation-Live 37' --class fedora --class gnu-linux --class gnu --class os {
linuxefi /images/pxeboot/vmlinuz root=live:CDLABEL=Fedora-WS-Live-37-1-7 rd.live.image quiet rhgb
initrdefi /images/pxeboot/initrd.img
}
with:
set default="0"
function load_video {
insmod efi_gop
insmod efi_uga
insmod video_bochs
insmod video_cirrus
insmod all_video
}
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
insmod fat
set timeout=60
### END /etc/grub.d/00_header ###
search --fs-uuid --set usb_esp --no-floppy 975E-C325 # from blkid /dev/sdc1
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Start Fedora-Workstation-Live 37' --class fedora --class gnu-linux --class gnu --class os {
linuxefi ($usb_esp)/images/pxeboot/vmlinuz root=live:CDLABEL=Fedora-WS-Live-3 rd.live.image
initrdefi ($usb_esp)/images/pxeboot/initrd.img
}
cp /mnt/usb_esp/EFI/BOOT/grub.cfg /mnt/usb_esp/EFI/BOOT/BOOT.conf
cp /mnt/usb_esp/EFI/BOOT/grub.cfg /mnt/usb_esp/boot/grub2/grub.cfg
umount /mnt/usb_esp /mnt/usb_fedora /mnt/fedora_iso_mount
restart the computer and boot the usb stick in uefi mode
Leave a Reply