I know there are other posts about how to create a live ubuntu usb with persistent memory – HOWEVER, there is no [question / answer] on how to convert a live (ubuntu) usb to one with persistent memory / storage. Is this possible?
Live USB – Can I Convert a Live Ubuntu USB to One with Persistent Memory?
live-usbpersistence
Related Solutions
The current Unix USB Installers (e.g. Universal USB Installer from PenDriveLinux.com) create a persistent file on the boot partition together with the other files needed for booting. This boot partition is formatted with FAT32 and because of limitations in FAT32, the maximum size of this file is 4GB. To have more persistent storage, this file can be replaced by a partition. The size of such a partition is only limited by the size of the USB drive.
I used the GParted partition manager to resize the FAT32 partition and make space for a big EXT4 partition for the persistent storage. The persistent file can simply be deleted and at the next boot, the Ubuntu system will automatically use the bigger persistent partition. There is one complication, though: you need another Ubuntu system to do this because Ubuntu cannot modify its own active boot partition.
I used a 2nd USB drive with Ubuntu live. For the instructions below I used "32 bit Ubuntu 13.10 desktop" version.
Install Ubuntu live on 2 USB drives. Configure a small persistent storage of around 100 MB for each of the USB drives.
Boot Ubuntu from one of the USB drives. Make sure the other USB drive is unplugged.
Start "GParted Partition Editor" from the Ubuntu Dash. This partition manager is default installed in 13.10.
Insert the other USB drive, wait a short moment and do a refresh in GParted (Ctrl+R). You will notice that a new device is added at bottom of the list of devices. Check that the size matches with the target USB drive. Select this device (see example picture below, the device name can be different on your system).
Check that the mount point (
/media/ubuntu/UUI
) is identical as in above picture.Open a terminal window (Ctrl+Alt+T) and remove the persistent file with the following command (adjust this command if the mount point is different in your case):
rm -v /media/ubuntu/UUI/casper-rw
Refresh GParted (Ctrl+R) and notice the change in "Used".
Right-click on the partition and select unmount. You will notice that the Mount Point is no longer displayed.
Right-click on the partition and select Resize/Move. Select New size: 1000. This will leave some space to store additional or updated files. Click "Resize/Move". An "unallocated" partion will appear
Now create a new partition for the persistent storage. Select the unallocated partition and right click on New.
Select file system “ext4“ and label
casper-rw
and click Add.Check if everything looks OK and click on the green check mark to apply all pending operations.
Shut down Ubuntu, remove the first USB drive (this USB drive is no longer needed) and reboot from the second USB drive.
Open a terminal (Ctrl+Alt+T) and type the following command:
df . -h
Check that the Avail size matches with the persistent partition size you created.
NOTE: With the release of Ubuntu 20.04 Python 2 has been deprecated and Live USB will not work with 20.04 due to missing dependencies. It will still work with 18.04 LTS.
The Startup Disk Creator which is also known as usb-creator-gtk
has had the ability of persistent and erase removed from the application, thus in my opinion making it worse then it ever has been. I wrote an answer earlier about it here. Also, just using the usb-creator-gtk
with Ubuntu 16.04 as well as dd
cause the USB drive to be formatted with a 512byte instead of 2048 as it is listed causing issues with GParted and other applications from seeing the drive properly. Unetbootin in my recent tests would not make the 16.04 USB bootable, especially if the drive was formatted as ext4.
I have found Live-USB-Install works very well and seems really stable. We will create an Ubuntu 16.04.1 LiveUSB with persistence.
Download Live-USB-Install from here:
Install Live-USB-install (requires unrar):
sudo apt install unrar sudo dpkg -i /path/to/download/live-usb-install-2.5.11-all.deb
If it gives you any dependency problems, just run the following:
sudo apt -f install
From the command line, now run Live-USB-Install (have your USB drive inserted that you're going to use. We will format the USB drive):
sudo live-usb-install
After the program launches, select the ISO you are going to use:
Click Open to Select ISO file
- Select the proper USB drive and the Format button to format your USB to FAT32 (syslinux won't install in anything other than NTFS or FAT32):
After formatting, remove and reinsert the USB drive.
Select Refresh so it sees your drive again.
- Select Distribution, Version, Persistent and Size you want for storage (for now 4095 or 4GB is the maximum due to size limitation of FAT32):
Click OK and be patient, this will take a while to create.
Boot to USB and select the persistent option.
You should now be able to install applications into the LiveUSB and still be there on a reboot. Enjoy!
NOTE: I tried booting to a Mac (which uses EFI), and it didn't load the menu so it didn't load the persistent. On the USB in the /boot/grub/grub.conf
file I did this change adding the word persistent to the linux line:
menuentry "Try Ubuntu without installing" {
set gfxpayload=keep
linux /casper/vmlinuz.efi file=/cdrom/preseed/ubuntu.seed persistent boot=casper quiet splash ---
initrd /casper/initrd.lz
}
Then it seemed to load the persistent OK. I didn't get the full chance to test it out though.
Hope this helps!
Best Answer
Changing Live Pendrive to Persistent Pendrive
This works both with 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 a Space and
toram
afterquiet 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 the persistence size in megabytes, with a max of 4GB).Move the new casper-rw file from home to the root of the Live Pendrive;
Add a Space and
persistent
afterquiet splash ---
in the following files:/isolinux/txt.cfg
, (for BIOS boot persistence Rufus);/syslinux.cfg
, (for BIOS boot persistence UNetbootin);/boot/grub/grub.cfg
, (for UEFI boot persistence).Shut down and reboot the persistent drive.
It's also possible to turn a Live USB into a Full-Install USB which has some advantages, except it won't install Ubuntu: Can Ubuntu be installed to the pendrive it was booted from?