====== Modify Debian live image ======
[[https://unix.stackexchange.com/questions/118965/how-to-create-a-debian-live-usb-with-persistence|Instructions modified from here]]
Example shows unofficial image (with non-free firmware) but works the same with official.
This replaces 'splash quiet' or 'quiet splash' with 'persistence ' - note space at end.
$ LANG=C sed 's/splash quiet/persistence /;s/quiet splash/persistence /' \
< debian-live-11.6.0-amd64-standard+nonfree.iso \
> debian-live-11.6.0-amd64-standard+nonfree-persist.iso
Copy to USB drive
dd oflag=direct conv=fsync bs=8M status=progress if=debian-live-11.6.0-amd64-standard+nonfree-persist.iso of=/dev/
Create new partition for the persistence (will occupy the rest of the drive)
fdisk --wipe never /dev/ <<<$'n\np\n\n\n\nw'
Create filesystem on new partition and configure persistence \\
More info [[https://live-team.pages.debian.net/live-manual/html/live-manual/customizing-run-time-behaviours.en.html#556|Here]]
mkfs.ext4 -m 0 -L persistence /dev/3
mount /dev/3 /mnt
echo '/ union' > /mnt/persistence.conf
umount /mnt
For automatic start add a timeout for grub
mount /dev/2 /mnt
echo 'set timeout=5' >> /mnt/efi/debian/grub.cfg
umount /mnt
===== Further tweaks =====
You may want to configure journald.conf to use Storage=volatile and possibly disable rsyslogd. \\
So that you limit the amount of writes to the USB drive.
Also sysstat might be good do disable in case it has been enabled.