Hi.
I wanted to do something exactly like that some months ago.
What I ended up doing is using a normal Debian installation
with an overlay file system mounted over the root.
It is too tricky to get the live images working with persistence.
Well, try this. Install Debian with a normal ISO image from your disk;
you need to boot with the linux and initrd.gz from here:
https://ftp.debian.org/debian/dists/bullseye/main/installer-<arch>/current/images/hd-media/
^
Substitute <arch> with the corresponding string to your architecture
(i386, amd64, etc).
>From this installer you can find the ISO in your disk and install
Debian in your USB,
or in a virtual machine and then copy with "dd" the disk image to your USB.
Then, change whatever you need to change.
After that, you will need to boot from the USB adding "break=bottom"
to the command of linux; which, for convenience, you can achieve modifying
the /boot/grub/grub.cfg in your USB and not have to do it every time you boot
pressing "e"; or do this last thing if you pretend to boot the USB only once.
>From the spawned shell you need to make a directory both in the rootfs
and in /root/ (here this is the USB, not root's home directory).
Mount a tmpfs over the directory in the rootfs. Create three
directories in there
which you will use as the lowerdir, upperdir and workdir options of the overlay.
Patch /root/etc/fstab to reflect the final mounts you will have when finished;
you can do this at the end, but the patch would be lost then.
Run "modprobe -d /root/ overlay" to load the overlayfs module.
Check that /root/ is mounted as read-only; if not, fix it. Mount
/root/ with "--bind"
at /dir/low/ (replace as appropriate, "dir" is the directory you made before
where the tmpfs is mounted). Unmount /root/ (this is necessary).
Now, mount this:
mount -t overlay -o
lowerdir=/dir/low/,upperdir=/dir/up/,workdir=/dir/work overlay /root/
Mount with "--rbind" the tmpfs to the same directory you made in /root/.
Unmount the tmpfs and its submounts from the rootfs.
Exit from the shell.
You should get a normal Debian system with a read-only filesystem
and a temporary space for modifications. I like to mount everything with the
noatime option also.
Some programs fail to work because AppArmor doesn't work well with this
mount configuration: LibreOffice is one of them. You can boot the kernel
with apparmor=off in its command line to disable it.
You can save some changes from the tmpfs to the lower read-only
filesystem if you first mount it with "--bind" somewhere else and then
remount it with "-o remount,rw" there. Be careful because the
documentation says it is undefined behaviour to do this, although
I have tried it and it works fine for changes in the lower directory tree.
I hope this helps. Have a nice day.