This gives you the flexibility to partition the USB stick as you wish.

download debian-live-12.0.0-amd64-gnome.iso from https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/

see your usb stick device name:

lsblk -o +TRAN | grep -i usb
sdb       8:16   1 119.5G  0 disk                 usb

clear partitions off your usb stick and re-partition it:

sgdisk -Z /dev/sdb
parted -s /dev/sdb mklabel gpt mkpart ESP fat32 0% 1GiB mkpart ISO9660 ext4 1GiB 5GiB mkpart PERSISTENCE ext4 5GiB 64GiB
parted -s /dev/sdb set 1 esp on set 1 boot on

fdisk -l /dev/sdb | grep "^/dev"
/dev/sdb1      2048   2097151   2095104 1023M EFI System
/dev/sdb2   2097152  10485759   8388608    4G Linux filesystem
/dev/sdb3  10485760 134217727 123731968   59G Linux filesystem

create the EFI system partition on the USB stick:

mkdir -p /mnt/usb_esp

mkfs.vfat /dev/sdb1

blkid /dev/sdb1
/dev/sdb1: UUID="CF86-1966" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="ESP" PARTUUID="26ed60b8-db94-43e4-8cfb-d0c6a5f9e93c"
(the UUID= will be used in grub.cfg later on)

mount /dev/sdb1 /mnt/usb_esp

write the debian live iso to /dev/sdb2:

dd if=/home/username/Downloads/debian-live-12.0.0-amd64-gnome.iso of=/dev/sdb2 bs=1M status=progress; sync

initialize /dev/sdb3 as an empty persistence partition:

mkdir -p /mnt/usb_persistence
mkfs.ext4 -F -b 4096 /dev/sdb3
mount /dev/sdb3 /mnt/usb_persistence

copy the boot files from debian live iso image to /mnt/usb_esp:

mkdir -p /mnt/debian_iso_mount

mount -t iso9660 -o ro,loop /home/username/Downloads/debian-live-12.0.0-amd64-gnome.iso /mnt/debian_iso_mount

cd /mnt/debian_iso_mount/

cp -Rv boot EFI install install.amd isolinux /mnt/usb_esp; sync
cp -v isolinux/splash.png /mnt/usb_esp/boot/grub; sync
mkdir /mnt/usb_esp/live
cp -v live/initrd* live/vmlinuz* /mnt/usb_esp/live; sync

modify grub.cfg on the usb stick:

vi /mnt/usb_esp/boot/grub/grub.cfg

from:
---
menuentry "Live system (amd64)" --hotkey=l {
        linux   /live/vmlinuz-6.1.0-9-amd64 boot=live components quiet splash findiso=${iso_path}
        initrd  /live/initrd.img-6.1.0-9-amd64
}
---

to:
---
menuentry "Live system (amd64)" --hotkey=l {
        insmod part_gpt
        insmod fat
        search --fs-uuid --set usb_esp --no-floppy CF86-1966
        linux   ($usb_esp)/live/vmlinuz-6.1.0-9-amd64 boot=live components findiso=${iso_path}
        initrd  ($usb_esp)/live/initrd.img-6.1.0-9-amd64
}
---

vi /mnt/usb_esp/boot/grub/install_start.cfg

from:
---
menuentry 'Start installer' --hotkey=i {
        linux   /install/gtk/vmlinuz vga=788  --- quiet
        initrd  /install/gtk/initrd.gz
}
---

to:
---
menuentry 'Start installer' --hotkey=i {
        insmod part_gpt
        insmod fat
        search --fs-uuid --set usb_esp --no-floppy CF86-1966
        linux   ($usb_esp)/install/gtk/vmlinuz vga=788  ---
        initrd  ($usb_esp)/install/gtk/initrd.gz
}
---

umount the filesystems that were mounted off the USB stick:

sync
cd /
umount /mnt/usb_esp /mnt/usb_persistence /mnt/debian_iso_mount

boot your computer with the USB stick in UEFI mode

Advertisement
Privacy Settings