persistent

Return to the main mkusb page


Persistent live systems

Most of the time it is enough with a live only USB pendrive and only a waste of effort to create a persistent live system. The cloning method of mkusb is very reliable and works with most linux distros. It needs hybrid iso files. But sometimes it is better to have a persistent live system, and beginning with version 10 mkusb can create such systems.

mkusb

1. Method developed from 'grub-n-iso'

This persistent live system is developed from booting via grub and the ISO file 'grub-n-iso' by Andre Rodovalho, described in

One pendrive for all PC (Intel/AMD) computers - single-boot dual-boot multi-boot and

How to Create a EFI/UEFI GRUB2 Multiboot USB drive to boot ISO images

The same pendrive can boot in UEFI mode and BIOS mode with a 32-bit operating system. Today 64-bit operating systems can boot almost all except the oldest computers. But this persistent live system cannot boot with secure boot. Data from usb-pack_efi.tar.gz are used to boot.

2. Using data from the source iso file

The grub boot system can be copied from an amd64 iso file. It can be modified slightly (to make a menuentry for persistence and to point to another partition). This works with the amd64 (64-bit) systems based on Ubuntu also with secure boot.

Persistent live systems made with this method boot in UEFI mode and can be made to boot in BIOS mode, if the program grub-install is available. And it is, except in installed systems running in UEFI mode, where the package grub-pc cannot be installed without conflict with existing EFI grub packages. So this method provides a tool the make persistent live systems in UEFI mode and for UEFI mode (for amd64 systems).

In a live or persistent live system it is 'always' possible to install grub-pc, so it is possible to create systems that boot also in BIOS mode from a persistent live system running in UEFI mode.

3. Compressed image file with a persistent live system

A compressed image file with a persistent live system of Lubuntu 14.04.3 LTS (32-bit) and mkusb version 10.4 can be installed into a USB pendrive or flash memory card. If you run Ubuntu installed in UEFI mode, it provides an alternative to create persistent live systems that work in BIOS mode, and even for 32-bit computers.

This compressed image file can be downloaded from dd_lubu-14.04.3-desktop-i386_one-pendrive_7.8GB.img.xz

and has the following md5sum

d001805e78369dba97f1183e5d31da6b  dd_lubu-14.04.3-desktop-i386_one-pendrive_7.8GB.img.xz

Use mkusb in linux or 7-zip and Win32 Disk Imager in Windows to expand and {copy/clone/flash/burn/restore/install} it into a USB pendrive, a flash memory card or a hard disk drive or SSD with at least 8 GB.

See this link to post #49 in the thread 'One pendrive for all PC (Intel/AMD) computers - single-boot dual-boot multi-boot' for more details.

Partitions

When you select persistent mkusb creates a partition for persistence in the target drive and the target system can use it automatically.

In a separate menu window you can choose between a GUID partition table, GPT, and an old style MSDOS partition table. Normally GPT is recommended, but many HP computers need an MSDOS partition table to boot directly from USB.

The persistent live drive boots from the third partition with a FAT32 alias vfat file system. The operating system is cloned from the iso file to the fourth partition. The fifth partition with an ext4 file system stores the overlay data for persistence.

  • partition: (NTFS) usbdata for storage and transfer of files

  • partition: GPT: bios_grub flag for booting in BIOS mode; MSDOS: extended partition

  • partition: (FAT32) boot partition

  • partition: (ISO 9660) cloned iso file

  • partition: (ext4) casper-rw or live-rw or persistence

Comparison with 'live only' systems

Otherwise, when you select live only mkusb clones the iso file and there will be no persistence (except with openSUSE iso files, that make persistent live systems as cloned). This kind of cloned system with an Ubuntu 64-bit operating system can boot also in secure mode.

Advantages

  • works with all current Ubuntu flavour desktop files (Ubuntu, Kubuntu, Lubuntu, ... Xubuntu) and with Linux Mint, LXLE, ToriOS, several other distros/re-spins based on Ubuntu and with Debian Jessie
  • very safe (minimal risk to overwrite the wrong drive by mistake)
  • easy to use
  • the target drive with the persistent live system works in [almost] all PC (Intel/AMD) computers

Disadvantages

  • works but less flexible in installed systems running in UEFI mode
  • cannot make a system that works in 32-bit systems as well as with secure boot
  • does not work with linux distros that are not based on Ubuntu or Debian (maybe you can tweak the grub.cfg file and make it work)
  • does not work with non-desktop iso files for example the Ubuntu mini.iso or the Ubuntu Server
  • in some computers (for example middle-aged HP desktop and laptop computers), ToriOS can boot only with a cloned 'live-only' pendrive, and with the system of method 3 from the compressed image file.

Alternatives

Unetbootin and the 'Ubuntu Startup Disk Creator' alias usb-creator 0.2.x can also be used, when you want persistence in the target drive. They create and use a casper-rw file with the maximum size 4 GB (due to the file system FAT32). (But usb-creator version 0.3.2 in Xenial Xerus is cloning like mkusb makes live-only drives.)

Persistence works with an ext2, ext3 or ext4 partition with the label casper-rw, and that partition can be 'anywhere', in another pendrive or in an internal drive (which makes it faster). Persistence with an ext partition 'anywhere' works when booting from a DVD as well as from a cloned iso file (from a pendrive made by mkusb). Just add the boot option persistent when you want persistence. Then the live system will search for a casper-rw file or casper-rw partition.

Debian Jessie uses the partition label or file name persistence and ToriOS uses live-rw (instead of casper-rw, and this is managed by mkusb).

You can also create a home-rw partition to store the content of your home directory and it will survive even if the system modifications are damaged in the casper-rw partition.

Backup and restore of persistent overlay data

The partition that stores persistent overlay data is easily damaged, particularly if you remove the pendrive before it is unmounted.

It is a good idea to use persistence to add functionality by installing packages and tweak the system to what you like. But it is bad idea to update/upgrade a persistent live system continuously. Then you will soon get a borked system.

If/when the persistence no longer works you may need to start all over again by removing what has been stored. Often you can keep the [overlay copy of the] home directory (and delete all other subdirectories of your overlay system in the casper-rw partition). Delete while running it live-only! This will save many settings, tweaks and personal files, but you must reinstall the program packages, that have been added.

Therefore it is important to have a convenient way to backup and restore the persistent data. This was introduced in mkusb 10.3.4 with shell-scripts to make it easy to backup and restore the overlayed persistent data of the persistent live system created by mkusb. These shell-scripts are written to

  • /dev/sdx1 mounted at /media/xubuntu/usbdata and

  • /dev/sdx3 which can be mounted at /mnt.

These scripts work in linux operating systems based on Ubuntu. In some versions, they are not executable, but can be run as parameter to bash. Boot into the live-only mode and run the scripts according to the following examples. (The scripts will complain if you try to use them in persistent mode.)

Backup example

cd /media/xubuntu/usbdata
ls -l
bash backup

Restore example

cd /media/xubuntu/usbdata
ls -l
bash restore

Automatic tarball names

The name of the tarball file (containing the backup) is updated automatically to create versions. Remove old versions manually!

1-casper-rw.tar.gz
2-casper-rw.tar.gz
3-casper-rw.tar.gz
...

Copy the tarball to another drive

Finally, to be sure the backup survives, you should copy the tarball to another drive, that you keep somewhere else, so that both backup copies are not lost. If you use the pendrive regularly, you should make backup copies of the casper-rw partition regularly too, maybe once a week or twice a month.

Select another directory/file

It is also possible to select another directory where to write/read the tarball. In that case, you add a parameter to the command line, for example

bash backup /media/xubuntu/backup  # target directory in another drive, a 'backup' drive

bash restore /media/xubuntu/backup/1-casper-rw.tar.gz  # source tarball in another drive, 'backup'

The commands under the hood of backup and restore are described in this post in the Ubuntu Forums.


Return to the main mkusb page

Win32DiskImager/iso2usb/temp/persistent (last edited 2016-03-28 15:28:33 by nio-wiklund)