2

I'm new to Linux as a whole, so excuse me if this is an easy fix.

I recently installed Ubuntu onto a flash drive and run it from that.

After setup I installed a few apps such as Discord, Chromium, and Spotify.

While trying to install a VM my laptop died so I connected it to the charger and rebooted.

When I log back in all those added packages are gone, and even the network settings had reset to default.

How do I keep what I add to Ubuntu when I run it from a USB flash drive?

JWo1f28
  • 23
  • If your currently used flash drive sticks out from the PC very far, it could be accidentally removed, so switching to a tiny flash may be worthy of consideration for safety's sake. There are very short USB flash drives with decent capacity available from many well known manufacturers at reasonable cost. – K7AAY Mar 01 '20 at 17:34

2 Answers2

5

LiveUSBs of Ubuntu and its flavours do not have persistence; when you reboot, all those installs are gone, because when you boot from a LiveUSB, it creates a virtual space in memory, extracts all the OS files into that virtual space, and runs in memory.

Why? Well, until recently, USB flash drives didn't have a lot of room, so squashing all the files together into one compressed file which sits on the flash drive, and extracting those files into memory which pretends it's a drive makes sense. Also, USB flash drives break a lot more than other drives, so minimizing how much and how often you write back to the USB flash drive helps preserve it.

It's not like you are running from an internal drive, where changes to the Ubuntu filesystem and apps you add, are preserved on that drive. You are running in something similar to a ramdrive and when the system shuts down, what's in memory does not return to the LiveUSB. Normally.

You can create persistence easily in a LiveUSB using the current version of the Rufus app when you make a LiveUSB of Ubuntu version 19.10 in Windows. Rufus allows you to easily transcend the 4GB barrier mentioned elsewhere in this thread. There are (more complex) Linux-based methods (more info) as well.

K7AAY
  • 17,202
  • 1
    +1; See also this link for more details. – sudodus Feb 28 '20 at 21:29
  • 2
    Cheers. This isnt a permament setup, just waiting until my new PC arrives, I wanted to know what I was doing with ubuntu before making it a primary OS, thank you for the advice. – JWo1f28 Feb 28 '20 at 21:39
  • 1
    I have been running VBox from a Full install Ubuntu pendrive for about three years now and have had no problems except for slow. I can run Windows 10 and use AutoCAD and SolidWorks. – C.S.Cameron Feb 29 '20 at 03:06
2

Full Install USB

Another option.

If you want to run Ubuntu from USB just like from an internal drive you can make a full install to USB.

It is safest to first unplug your internal drive and then insert your USB. You can then install as you would to HDD, either automated install or using "something else".

Advantages of a persistent install:

1) You can use the persistent pendrive to install Ubuntu to another computer.

2) A persistent install takes up less space on the pendrive.

3) You can reset the pendrive by overwriting the old casper-rw file with a new one.

4) The install to pendrive takes less time.

Advantages of a Full install:

1) You can update and upgrade.

2) If you have problems or wish to modify, the solution is the same as with an internal install, (You can ask for help in these forums).

3) No ugly startup / install screen.

4) Better security, you can use full encryption

5) You can use proprietary drivers.

6) Hibernation works.

7) A persistent install is limited to a 4GB casper-rw and a 4GB home-rw persistence file, to get more persistence requires persistence partitions.

8) Faster boot.

9) You can run VBox and use virtual machines.

Note that once booted, both methods run at about the same speed.

C.S.Cameron
  • 19,519
  • 2
    Two methods for creating Full install pendrives: https://askubuntu.com/questions/1051543/how-to-make-a-live-ubuntu-18-04-usb-with-a-persistent-storage-of-more-than-4gb/1051558#1051558 and https://askubuntu.com/questions/1119700/how-to-fully-install-ubuntu-on-usb-flashdrive/1119713#1119713 – C.S.Cameron Feb 29 '20 at 03:43