You can easily put the writable filesystem (in the casper-rw file)
for a live media onto a hard disk. The limitation is that the
casper-rw file must go on a FAT partition. Newer machines (UEFI)
all have a FAT EFI partition, but that's typically too small to hold
a 1G-4G casper-rw file. On another big enough FAT partition, you can
make directories, each holding a casper-rw file for possibly different live medias.
Suppose sda11 is 10G and has a 10G FAT filesystem, mounted at /mnt/sda11,on which there are directories /A , /B , /C , /D , and /E. Assume we will use /A for our persistent media, putting a casper-rw there.
cd /mnt/sda11/A
dd if=/dev/zero of=casper-rw bs=1M count=4096
mkfs.ext4 -F -O^has_journal -L casper-rw casper-rw
Take your live media created with persistence, and edit the /boot/grub/grub.cfg file and the /syslinux/txt.cfg file, adding after the word "persistent"
"persistent-path=/A"
/boot/grub/grub.cfg
...
menuentry "Try Ubuntu without installing" {
set gfxpayload=keep
linux /casper/vmlinuz.efi file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash --- cdrom-detect/try-usb=true noprompt persistent persistent-path=/A
initrd /casper/initrd.lz
}
/syslinux/txt.cfg
default live
label live
menu label ^Try Ubuntu without installing
kernel /casper/vmlinuz.efi
append noprompt cdrom-detect/try-usb=true persistent persistent-path=/A file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash ---
label live-install
...
That's it. You don't even need to rename/remove the casper-rw file on the USB media.
If there's room on the USB media, you can even copy the hard disk's casper-rw back to the USB, and take your changes with you.
The persistent-path does not allow any explicit disk reference, so should be unique across all FAT partitions. Tested with 1 or 2 FAT partitions (one being the EFI partition). Will not work on an ext2 or ntfs filesystem instead of FAT. If you also add the "toram" word on the same line as "persistent", your compressed filesystem on the slow USB will be copied into ram and give much better performance, however,
there seems to be a shutdown issue, with the FAT partition not being cleanly unmounted (which does not seem to cause any problems but...)
Best Answer
Upgrade a persistent live system
There are reasons to upgrade a persistent live system, if you use it for other purposes than testing, for example because you want a very portable operating system, more portable than an installed Ubuntu system in an external drive.
You upgrade the basic persistent live system by installing it from a new iso file, typically a new daily iso file of an LTS release, but also to a new version of Ubuntu (16.04 to 18.04). But you lose your data files, tweaks and the manually installed programs.
You can copy
/home
to another version of UbuntuThe
/home
directory contains personal data as well as settings and tweaks. These data are almost always independent of the version of version of Ubuntu (or Ubuntu community flavour). It means that you can copy them from one version to another version within a fairly wide scope of versions.I have tested that
This works when you address the 'home' directory
casper-rw
partition (or file)home
partition (or file)If the user IDs are different, you must make them match in the new system. This means that it is easy to upgrade a persistent live system of Ubuntu to a new version of Ubuntu, or stay within the same community flavour of Ubuntu (Kubuntu, Lubuntu, ... Xubuntu). It is possible but more difficult to switch between flaovurs and to switch between installed systems and persistent live systems.
Do not copy the
casper-rw
partition to a new version of UbuntuYou are right, a full upgrade of a persistent live system is not possible, at least not the easy way by copying the
casper-rw
partition from an old version to a new version. After some upgraded program packages, it doesn't even work to upgrade to a newer [daily] iso file within the same version of Ubuntu (or Ubuntu community flavour).So you must re-install the program packages, that you installed manually, and you must re-do the system settings, that are not in
/home
(for example those in/etc
).Methods and tools
mkusb
andmkusb-backup-n-restore-home
mkusb
.Backup
/home
from thecasper-rw
partition to a tarball with the commandCreate the second and upgraded persistent live from a new iso file with
mkusb
. This can be in the same or another USB pendrive.Restore
/home
from the tarball to the new persistent live system's casper-rw` partition with the commandBoot into the new persistent live system and install programs manually, when necessary.
The following links describe how to install and use these tools,
help.ubuntu.com/community/mkusb
help.ubuntu.com/community/mkusb/persistent
Backup and restore the /home directory in casper-rw partitions of mkusb persistent drives
This method may suit better,
mk-persistent-live_with_home-rw
Create a persistent live drive with
mk-persistent-live_with_home-rw
. This will be different from a drive made bymkusb
. The idea is tokeep the
home-rw
partitioncasper-rw
partition (format).grub.cfg
that matches the iso file.This method may suit better,
/home
directoryif you want to change between flavours of Ubuntu or between a persistent live system and an installed system, and must tweak the user IDs manually.
The following link describes how to install and use this tool,
Make persistent live drives with casper-rw and home-rw partitions