10

I have an Ubuntu live USB and I don't have any other PC, laptop, or USB sticks. Can I make my live USB persistent? If not, is there any other way to save files in it so that they will stay there even after I restart my PC?

Note: I have a PC with an Intel 6th Gen Core i3 processor and 4GB RAM, and I'm currently running Ubuntu from a 16GB USB stick. I can't borrow others' computers or USB drives, but I do have a phone if that helps.

MDeBusk
  • 1,386
MrDuck
  • 103

3 Answers3

16

Usually I recommend using mkusb in order to create a persistent live USB drive. But in this case I think it is too risky, because there is no backup, the only working operating system is in the target drive.

Instead I suggest to make the default /var/log and /var/crash mounted writable partition into a 'free' usbdata partition, that can be mounted and unmounted by the user.

  • When booting, at the grub menu, press 'e' to make a temporary edit: add nopersistent to the line starting with linux

    linux ... quiet splash nopersistent ---
    
  • continue booting with F10 or ctrl x

  • now you can unmount the partition with ext4 file system

    sudo umount /dev/sdx3
    

    where x is the drive letter (can be a, b, c ...)

  • change the label

    sudo tune2fs -L usbdata /dev/sdx3
    
  • shutdown, wait for 10 seconds and boot again.

The system will be live (not persistent live), but the ext4 partition can be used for storage. Until you have another drive available this is a rather safe method to create storage space on the drive. In order to make it convenient, you can create one or more directories at its top level and modify the ownership.

The partition will probably automount (it did when i tested with Lubuntu 20.04.4 LTS, which is lighter than standard Ubuntu).

cd /media/lubuntu/usbdata
sudo mkdir Docs
sudo chown 999 Docs

999 is the numeric ID of the live user (for standard Ubuntu as well as Lubuntu and the other community flavours). Now you can go there and test writing files.

cd Docs
echo 'Hello World' > hello
cat hello
ls -l hello
sudodus
  • 47,684
6

Live USB to Persistent USB

A persistent Linux USB is basically just a Live USB with a persistent overlay file or partition, (ie casper-rw, writable or home -rw).

It is possible to make a Persistent USB from scratch:

Simple Hand Made Persistent USB that Boots either BIOS or UEFI

It is also possible to make a Full install of Ubuntu from a Live USB to itself, see: https://askubuntu.com/a/855805/43926

Similar see: How to make a persistent Drive using Startup Disk Creator

And Can Ubuntu be installed to the pendrive it was booted from?.

C.S.Cameron
  • 20,530
  • 12
  • 78
  • 125
3

No, you can't. And the amount of work and the high risk of data loss makes such project absurd.

You can use MKUSB to re-do the live USB but this time selecting the 'persistent live' option, arguably the easiest and fool-proof method.

ChanganAuto
  • 1
  • 8
  • 15
  • 23