During several versions it is straightforward to create a live USB drive by cloning from an iso file with Ubuntu and Ubuntu flavours. But it has not been possible to make a cloned drive persistent by using the unallocated space behind the cloned part of the USB drive. At least, I don't know any way to make it work with 18.04 LTS and older versions.
Today I have tested a method developed by F. Hauri which works for Debian 10, and I found that it works with Lubuntu Eoan. It is actually rather simple. I think and hope that it will work in the next LTS release, 20.04, not only with Lubuntu but with the whole family of Ubuntu and the flavours.
I used the following commands, where the real editing commands are high-lighted.
Code:
strings eoan-desktop-amd64.iso |grep 'quiet splash' # check that 'quiet splash' is there to be replaced by 'persistent ' (12 characters)
sed 's/quiet splash/persistent /' eoan-desktop-amd64.iso > persistent-eoan-desktop-amd64.iso # yes, sed works with binary files
ls -l *eoan* # check that the size is the same
strings persistent-eoan-desktop-amd64.iso |grep 'persistent ' # check that 'persistent' is there now
dus persistent-eoan-desktop-amd64.iso # I use mkusb-dus, you can use the Ubuntu Startup Disk Creator or another cloning tool
sudo lsblk -fm # It is important to check the device letter of the target drive (the USB drive, that you want persistent live
sudo fdisk /dev/sdx # x is the device letter of the target drive, please double-check that you have the correct letter
n # new partition
p # primary
<Return> # default: 3
<Return> # default: next free sector
<Return> # default: last addressable sector
w # write and quit
sudo lsblk -fm # check that things look good and verify that partition #3 is the correct partition to be used to store the persistent data
sudo mkfs.ext2 -L casper-rw /dev/sdx3 # put label and file system into the partition of persistence
sudo lsblk -fm # check that things look good
sync # flush the buffers and wait for prompt
After the sync command you can unplug the drive to test it in another computer or reboot to test it in the same computer.
Edit1: I added a screenshot from cloned drive running persistent live. The commands were recalled from .bash_history (and created in BIOS mode, while the system was running in UEFI mode at the screenshot).
Edit2: The task can be simplified: You need not create a partittion 'behind' the cloned part of the target drive. It is enough the modify the iso file with sed and clone that modified iso file to the target drive. When you boot into it, the Ubuntu system will create the partition for persistence and its file system automatically and it will be a persistent live drive.
There is a graphical user interface in the mkusb family of tools, mkusb-plug, that takes advantage of this new feature of Ubuntu 19.10, 20.04 LTS and future versions of Ubuntu and the Ubuntu family flavours.