Ubuntu – How to create a live USB installer for UEFI/EFI systems that reads and saves persistence changes

14.10live-usbpersistenceuefi

I have a 16 GB USB stick which runs a live boot of Ubuntu 14.10 with antivirus software installed which (obviously) needs to be kept up to date as I use it to boot and clean infected Windows machines.

To make it, I used usb-creator-gtk and an ISO for Utopic x64 Desktop downloaded from The Official Site, and a 4 GB persistence file which usb-creator-gtk creates when the option is selected. Nothing fancy, nor anything complicated.

When this is used on BIOS systems, it's all there. I can update the antivirus software and the changes are saved in the user persistence file (casper-rw I believe) However, when used to boot UEFI systems, none of that is there and any changes made are not saved.

It's like I have two environments on this stick: The UEFI version which is the same as the default ISO, DOESN'T save changes and is R-O, and the BIOS version which has my tweaks and custom apps, DOES save changes and is R-W.

So – how I do get the UEFI version of the live environment to save any changes made or even better, how can I get the UEFI and BIOS versions of the live environment to share the same environment?

Best Answer

This is a bug, specifically bug 1159016. The solution is described in this AskUbuntu post. Basically you just have to add the word persistent in boot/grub/grub.cfg after creating the live USB:

menuentry "Try Ubuntu without installing" {
    set gfxpayload=keep
    linux   /casper/vmlinuz.efi persistent file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash --
    initrd  /casper/initrd.lz
}

EDIT:

As you have a large 16GB drive, I would also suggest to split the USB drive into two partitions, a ~6GB FAT32 one for the live USB + persistence, and a 10GB ext4 one for any other data you want to store on the stick. You could also use a separate partition instead of a casper-rw file if you need more than 4GB of persistence, but then usb-creator-gtk will not help you create it. (EDIT: see here on how to do that.)

Unfortunately, when resizing FAT32 partitions you'll run into another bug (bug #1313600), so I suggest you create the partitions manually (6GB FAT32, 10GB ext4) before using usb-creator-gtk:

  1. Run GParted.
  2. Format the whole USB drive, deleting all partitions.
  3. Create a new FAT32 partition at the beginning of the drive, with a size of ~5500MB.
  4. Create the live USB using the FAT32 partition with usb-creator-gtk.
  5. Finally, as I am running an UEFI system I needed to fix this bug as well by adding the word persistent in boot/grub/grub.cfg:

    menuentry "Try Ubuntu without installing" {
        set gfxpayload=keep
        linux   /casper/vmlinuz.efi persistent file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash --
        initrd  /casper/initrd.lz
    }