Creating a persistent USB drive (for 64bit only - and secure boot enabled)
In some cases installation will hang on "fast boot" on some distros.Consider to change. DO NOT DISABLE SECURE BOOT you can read many about it, but this feature does not hint you from running linux! by mokutil --sb-state
you can see if enabled.
There are rudiments to get secure boot and TPM work. MS has the power to sign. Ubuntu Kernel is ready to load while secure boot. But if you compile kernel eg. with nvidia-drivers on your own, you probably got limits.
If you are a more experienced user then you can
use gentoo instead: LiveUSB GentooWiki <- there is a new livegui image present

234 click to enlarge

184 click to enlarge

186 click to enlarge

187 click to enlarge

229 click to enlarge
improved from : https://wiki.ubuntuusers.de/Archiv/Live-USB_-_persistente_Installation/
It is !mportant to use a desktop version NOT the live dvd for use on your USB: please read on to learn how to configure grub.
kubuntu-22.10-desktop-amd64.iso
does not work with newer GPUs--> finished, ready to use disk image for minimum 4G flash drives only for 64bit systems (4.7G) > all you need to do is: writing image to flash and setup grub to boot from drive.
Follow these few steps strictly to create your own bootable usb kubuntu. Or write my image to your usb drive.
Burn iso, boot from it.
Using gparted (from Kubuntu Live DVD):
My choice was a sandisk cruzer extreme 32 gb usb 3.0 stick (read: up to 260 MB/s, write up to 120MB/s). Plug it in after session login from Live DVD, sometimes perhaps need to replug after partitioning.
It is normal that there is 1M free allocated space before the first partition after using gparted.
In my case it is /dev/sdh.
use ms-dos partition table
create an 4700 Mib fat32 Partition with boot flag, label LIVEUSB (in uppercase)
create an 10000 Mib ext2 Partition, label casper-rw
create an btrfs Partition with rest available space, label home-rw
optionally create swap
It is important to label the names as described: there will be integrated to your system automatically. gparted is able to format the partitions directly.
There are USB devices where booting is a bit more complicated. In my cases, disabling USB Legacy and integrating the stick into UEFI boot manager in the BIOS helped.
example mbr (fdisk -l)
Device Boot Start End Sectors Size Id Type
/dev/sdh1 * 206848 8398847 8192000 3,9G c W95 FAT32 (LBA)
/dev/sdh2 8398848 39995391 31596544 15,1G 83 Linux
/dev/sdh3 39995392 60475391 20480000 9,8G 83 Linux
/dev/sdh4 60475392 62523391 2048000 1000M 82 Linux swap / Solaris
If not, format your partitions like:
mkfs.vfat -F 32 -n LIVEUSB /dev/sdh1
mkfs.ext2 -b 4096 -L casper-rw /dev/sdh2
Copy the entire cd content including hidden dirs to the first partition (fat32) on your usb drive. Ignore symlinks error, it is not supported by fat32.
Configure grub like this. Fine, if this is your output:
grub-install --root-directory=/media/kubuntu/LIVEUSB --no-floppy /dev/sdh
Installing for i386-pc platform.
Installation finished. No error reported.
if this fails you can try from your booted live dvd:
sudo mount /dev/sdh1 /mnt/
sudo mkdir /mnt/boot/efi
sudo grub-install --root-directory=/mnt/boot/ --target=x86_64-efi --efi-directory=/mnt/boot/efi --no-floppy /dev/sdh
Installing for x86_64-efi platform.
Installation finished. No error reported.
Last thing to do is edit your grub.cfg in /media/kubuntu/LIVEUSB/boot/grub/grub.cfg (my mountpoint) (on fat32 partition) with adding the following lines to make menu entry and boot up the drive:
menuentry "Start Kubuntu pers 2 defaults" {
set gfxpayload=keep
linux /casper/vmlinuz file=/cdrom/preseed/kubuntu.seed quiet splash persistent fsck.mode=skip rw ---
ramdisk_size=1048576 cdrom-detect/try-usb=true keyb=de locale=de_DE
bootkbd=de console-setup/layoutcode=de root=/dev/ram
#maybe-ubiquity=installer
initrd /casper/initrd
}
hopefully you are now able to boot the media, notice the right boot order in your bios. Now You can setup the system to your wishes and everything is save. i prefer to make an image from the whole usb drive:
dd if=/dev/sdh conv=sync,noerror bs=64K status=progress | gzip -c > /path/to/persistent_linux_usb.image.gz
Sometimes Windows 10 updates can erase your stick, because windows does not like other os beside. With the image it is less work to do new.
does not work with newer GPUs-->finished, ready to use disk image for minimum 4G flash drives (2.7G) only for 64bit systems
write to disk like:gunzip -c persistent_linux_usb.image.gz | dd of=/dev/sdX
(use isotousb,rufus or anything else for windows write to flash drive)
expand casper-rw unmounted with: e2fsck /dev/sdX2 (X2=your device)
give feedback!
EFI
In case of efi and grub version the partition table must be: GPT, which should be do first!
in gparted go to: > Device > Create Partition Table > gpt
otherwise do msdos (mbr)/ default.
example gpt (using efi)
Device Start End Sectors Size Type
/dev/sdh1 2048 8390655 8388608 4G EFI System
/dev/sdh2 8390656 33433599 25042944 12G Linux filesystem
/dev/sdh3 33433600 60485631 27052032 12,9G Linux filesystem
/dev/sdh4 60485632 62531583 2045952 999M Linux swap
mkdir /mnt/boot/
mount /dev/sdh1 /mnt/boot/
You have
apt install grub-efi
this command should work, but there are many things can get wrong:
grub-install --root-directory=/mnt/boot/ --no-floppy /dev/sdh
chroot /mnt/boot
fix grub in chroot when stuck. (consult google for workaround)
Add this to your: /etc/grub.d/40_custom or grub.cfg (if mbr)
menuentry "Persistent" {
#set root=(hd0,msdos1)
set gfxpayload=keep
linux /casper/vmlinuz file=/cdrom/preseed/kubuntu.seed quiet splash persistent
fsck.mode=skip ramdisk_size=1048576 cdrom-detect/try-usb=true keyb=de locale=de_DE bootkbd=de
console-setup/layoutcode=de
root=/dev/ram rw ---
initrd /casper/initrd.lz
}
then run
update-grub
hopefully you are now able to boot the media, notice the right boot order in your bios. Now You can setup the system to your wishes that keep stay.