Make it easy to create a persistent or live-only USB live drive


During the last few years I have been helping users of Ubuntu and Ubuntu family flavours by making a set of tools to create bootable live systems, mainly in USB drives but also in memory cards. You may have heard of mkusb.

I’m very glad that it is now much easier to create persistent live drives. The casper package was modified in Ubuntu version 19.10 so that it is easy to create persistent live drives with a partition for persistence even in a drive that is cloned from the iso file. I wrote about it in this AskUbuntu thread.

But there is also a new feature with the current implementation: a standard cloned drive is not live-only, it saves a log file and can save a crash dump.

  • This is good in order to help users who have problems with installing Ubuntu,
  • but causes problems
    • for people who want a completely live-only drive because of privacy reasons,
    • and also when people want to backup the content of the partition for persistence (because it cannot be unmounted).

This problem is the subject of this this AskUbuntu thread and this Ubuntu Forum thread.

See also this bug report at Launchpad, #1851123: ‘Ubuntu 19.10 and focal live cloned create and mount casper-rw partition’.

Please discuss and suggest methods to solve this problem

Let us discuss and suggest methods to solve this problem - also methods that involve modifications of the iso file.

I can start with the following method

I suggest a simple method to prepare the iso files for binary editing without ‘sacrificing’ anything. What do you think of the following idea for Ubuntu Focal Fossa?

It is possible to add the boot option

  • ‘persistent’ in order to create a persistent live drive
  • ‘nopersistent’ in order to create a live-only drive.

I am looking for a method to edit the iso file (binary edit) without loss of any current feature.

$ echo -n ' nopersistent '| wc -c

In order to add one of these boot options we need an unused space of 14 blank (alias ‘space’) characters in the iso file. I suggest that it is made so that the image contains such space in the image of grub.cfg and the corresponding file for syslinux.

So for the ‘linux lines’ in grub.cfg put 14 blanks (not 1 blank as it is now) after quiet splash,

'linux ... quiet splash              ---'

so that there is space to insert additional boot options

'linux ... quiet splash persistent   ---'
'linux ... quiet splash nopersistent ---'

and for the ‘append lines’ in isolinux/txt.cfg

'append ... quiet splash              ---'

so that there is space to insert additional boot options

'append ... quiet splash persistent   ---'   
*append ... quiet splash nopersistent ---'

This way we can add those boot options without removing anything except blank characters and at the same time without offset of the code after the substitutions.

I have tested that this kind of substitution works in a straightforward way with sed from the iso file. I have a method with a shellscript that ‘wraps a safety belt’ around the process and can write directly to the device without creating a modified file,

ubuntu.iso < sed 's/quiet splash              ---/quiet splash persistent   ---/' > /dev/sdx


ubuntu.iso < sed 's/quiet splash              ---/quiet splash nopersistent ---/' > /dev/sdx

It is easy to modify the current tool mkusb-minp for this task. (Now it is replacing 'quiet splash'.)

1 Like

I would suggest that a cloned install creates a NTFS partition rather than a ext4 casper-rw partition.
This way the space not used by the live install becomes useful as a Data partition with both Linux and Windows.
Perhaps a small tool or script could be created in the NTFS partition that, when activated, would change the Data partition to a persistent partition and add “persistent” to the boot loader. This might be done using an alternate boot partition. Not sure about the details.