How to make an already live Ubuntu pen-drive, a persistent one?

I have created a USB flash drive with the latest Ubuntu version, but it is not persistent. How can I make it persistent without repeating the whole process?


2017

Persistent partitions have not worked in syslinux Live Ubuntu systems since 14.04. This includes SDC, UNetbootin, Rufus etc.

If you really want to make an existing install persistent, you can build a casper-rw file in Windows and add it to the root of your flash drive, see https://www.pendrivelinux.com/casper-rw-creator-make-a-persistent-file-from-windows/

The casper-rw file will be limited to 4GB and only works on a FAT32 partition.

If you want the boot to be persistent press Shift, select language, press F6, hit Enter and type persistent, (For UNetbootin press Tab then F6)

if you want every session to be persistent, modify isolinux/txt.cfg as Danatela shows above (or for UNetbootin install modify syslinux.cfg the same way).

Probably easier to re-make the persistent drive using mkusb, it makes persistent partitions automatically.


Changing Live Pendrive to Persistent Pendrive

That works with both BIOS and UEFI

Many people prefer a Persistent pendrive that will save changes.

  • Create a Live pendrive using Rufus or similar.

  • Boot the pendrive toram to make the drive editable, (press shift when booting, press Esc from language, press F6, press Esc, type {space}toram after "quiet splash ---", and press Enter.

  • Create a casper-rw file:

    sudo dd if=/dev/zero of=casper-rw bs=1M count=512

    sudo mkfs.ext3 -L casper-rw -F casper-rw

(where count=512 is persistence size, with max 4GB).

  • Move the new casper-rw file from home to the root of the Live Pendrive.

  • Edit /isolinux/txt.cfg, (for BIOS boot persistence) and /boot/grub/grub.cfg, (for UEFI boot persistence), add a space and the word "persistent" after "quiet splash ---".

  • Shut down and reboot the persistent drive.


As shown in this guide, you can reduce size of FAT32 partition on your flash drive then make ext4 partition labeled casper-rw and it will be treaten as persistence file. If Gparted fails to reduce the size of FAT32 partition, you can do it in Windows program EaseUS Partition Master.

It seems to me that you can also create file named casper-rw and create ext filesystem in it with mke2fs -t extX /path/to/casper-rw so it will be persistence file too.

Also, you need to change isolinux/txt.cfg adding word persistent to boot options like this:

default live
label live
  menu label ^Try Ubuntu without installing
  kernel /casper/vmlinuz.efi
  append  file=/cdrom/preseed/ubuntu.seed boot=casper cdrom-detect/try-usb=true persistent noprompt floppy.allowed_drive_mask=0 ignore_uuid initrd=/casper/initrd.lz quiet splash --
label live-install
  menu label ^Install Ubuntu
  kernel /casper/vmlinuz.efi
  append  file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity cdrom-detect/try-usb=true persistent noprompt floppy.allowed_drive_mask=0 ignore_uuid initrd=/casper/initrd.lz quiet splash --
label check
  menu label ^Check disc for defects
  kernel /casper/vmlinuz.efi
  append  boot=casper integrity-check cdrom-detect/try-usb=true persistent noprompt floppy.allowed_drive_mask=0 ignore_uuid initrd=/casper/initrd.lz quiet splash --
label memtest
  menu label Test ^memory
  kernel /install/mt86plus
label hd
  menu label ^Boot from first hard disk
  localboot 0x80