1

I'm using Xubuntu 20.04 LTS live USB (non-persistent) and I just tried the toram option. It got stuck on the logo screen (or so it seemed) so I force shut down the computer.

Now I booted normally without toram and while I was working on the computer, I accidently removed the USB but to my surprise, everything is working normally. I mean, shouldn't it hang/freeze. Is this normal?

How can I make sure whether I'm running Xubuntu on ram or USB. And if it turns out to be from ram...how? Did I permenantly load Xubuntu to my ram? I thought everything gets deleted once I restart. If that's not the case, how can I delete is from ram?

Thanks for any help guys!

JJrussel
  • 287
  • 1
  • 4
  • 11

2 Answers2

2

RAM or Not to RAM

I understand that even if Ubuntu is not booted toram that it still runs mostly in RAM. It seems to somewhat depend on how the Live/Persistent drive was created.

If you boot normally, and open several programs, say GParted and LibreOffice Writer, then close the programs and unplug the USB, the programs should still be in memory and can be restarted without the USB. (This did not work for me with mkusb Persistent last time I tried). Programs that were not previously booted, will not boot with the USB unplugged.

If you Boot toram and unplug the USB, (after everything stabilizes), all the programs, (within filesystem.squashfs), should be bootable.

My recommendation is to wait until you are sure the USB is not being written to, yank the USB and try starting a program that you have not just been using, say Calculator or Solitaire. If it starts you are likely booted toram.

If you do not like the idea of yanking your USB you should be able to unmount it using: sudo umount -lrf /cdrom where is the path to the root partition.

After you shut down a Live install that has been running in RAM, (such as an Etcher ISO9660 clone or Ventoy ISO file boot), all data in RAM disappears, as long as hibernation has not been set up on the disk. If hibernation has been set up, RAM data gets dropped into a swap file or partition and is available on resume. It is not easy to set up hibernation on a USB that does not have persistence or a Full install.

C.S.Cameron
  • 18,890
  • 10
  • 64
  • 105
  • 1
    I booted into the live session without `toram` and immediately removed the USB and tried opening programs. I opened every single program and they all worked normally! Even GNU Image Manipulation Program, which is a pretty intensive program by the looks of it. Wth! – JJrussel Nov 12 '20 at 00:52
  • @JJrussel: One place that I know `toram` makes a big difference is filesystem check. For me it runs about 30 times faster with `toram` than without. – C.S.Cameron Nov 12 '20 at 01:52
2

Comparing mountpoints without and with toram

Live-only without toram:

$ df -h
Filesystem                   Size  Used Avail Use% Mounted on
tmpfs                        1.6G   18M  1.6G   2% /run
/dev/sdb1                    1.8G  1.8G     0 100% /cdrom
/cow                         7.8G   17M  7.8G   1% /
/dev/disk/by-label/writable   54G   95M   51G   1% /var/log
tmpfs                        7.8G     0  7.8G   0% /dev/shm
tmpfs                        5.0M  4.0K  5.0M   1% /run/lock
tmpfs                        4.0M     0  4.0M   0% /sys/fs/cgroup
tmpfs                        7.8G     0  7.8G   0% /tmp
tmpfs                        1.6G   80K  1.6G   1% /run/user/999

Live-only with toram:

$ cat /proc/cmdline 
BOOT_IMAGE=/casper/vmlinuz file=/cdrom/preseed/lubuntu.seed quiet splash toram ---


$ df -h
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           1.6G  1.8M  1.6G   1% /run
/dev/shm        1.9G  1.8G   90M  96% /cdrom
/cow            7.8G   26M  7.8G   1% /
tmpfs           7.8G     0  7.8G   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           4.0M     0  4.0M   0% /sys/fs/cgroup
tmpfs           7.8G     0  7.8G   0% /tmp
tmpfs           1.6G   80K  1.6G   1% /run/user/999
/dev/sdb4        54G   95M   51G   1% /media/lubuntu/writable
/dev/sdb1       1.8G  1.8G     0 100% /media/lubuntu/Lubuntu 20.10 amd64

Comments

The crucial difference is what is mounted on the mountpoint /cdrom

  • without toram a partition on the USB drive is mounted on /cdrom, and should be kept mounted for the system to work correctly, so the USB drive should be kept connected.

  • with toram /dev/shm is mounted on /cdrom, and this is a ramdrive. This means that the partition containing the system can be unmounted. (As you can see, Lubuntu mounts it under /media, and it can be unmounted. Other Linux distros may not even have that partition mounted after copying to RAM.)

You can check which boot options were used with the command

cat /proc/cmdline

Edit: Checking the files of the live system brings them into RAM

I learned something today. The original poster, JJrussel, observed that there is a difference between Xubuntu 18.04 LTS and 20.04 LTS: It is possible to continue running 20.04 LTS live after removing the USB drive (that is was booted from).

  • I can verify it in a computer with 'enough' RAM (and many modern computers have enough RAM). I could start and run Firefox and LibreOffice after the USB drive was unplugged.

  • I continued testing by booting Xubuntu 20.04 LTS live (live-only) with the boot option fsck.mode=skip, which makes the boot process skip checking the files of the live system. In this case I could not start and run Firefox and LibreOffice after the USB drive was unplugged.

  • In both cases I unmounted /cdrom before unplugging the USB drive,

    sudo umount -lrf /cdrom
    

Conclusion:

Checking all the files of the live system brings them into RAM, and when there is enough RAM, they will remain there, so that they are available also after the USB drive is removed.

sudodus
  • 45,126
  • 5
  • 87
  • 151
  • 1
    I am curious about the OP's observation that after pulling the plug on a Live/persistent USB, everything appears to be working normally, (with some exceptions). Does this mean that Ubuntu, more or less, normally runs in RAM? Sometimes I think the need for fast SSD's and USB's is a little overstated, (except when it comes to starting up, shutting down and saving data). One of these days it would be nice to see some serious benchmarking. – C.S.Cameron Nov 11 '20 at 11:17
  • @C.S.Cameron, You are right, Ubuntu *live*, more or less, normally runs in RAM. It fetches programs from the storage, and then, keeps it in RAM as long as there is enough RAM for it. When necessary new programs replace old (and currently less used) programs in RAM. So the smoothness depends a lot on the size of RAM in relation to the total size of the active programs and data to be managed. I think the output of `free` is useful to illustrate how the available RAM is used. – sudodus Nov 11 '20 at 12:54
  • That sounds right. I was just comparing an old laptop with 4GB RAM booted from a USB2 with a laptop with 24GB RAM booted from SSD and speeds were nearly identical the second time I started a program. +1 for .`cat /proc/cmdline` that is my learn something new for today. `Free` is another good command I use that a lot. – C.S.Cameron Nov 11 '20 at 13:53
  • @sudodus this is what I'm getting https://imgur.com/cW8Acvg – JJrussel Nov 12 '20 at 00:46
  • @sudodus Also something else (in addition to my comment to C.S.Cameron, which was that all programs run without the USB)....i tried booting into Xubuntu 20.04 created with Ventoy & I got the same result. I can fully run everything without `toram` & without the USB, similar as on Xubuntu 20.04 created with UNetbootin. But then, when I tried Xubuntu 18.04, nothing worked without the USB. Why? I'm wondering if this is because of that one time I ran 'toram` which has now caused permenant change in the computer I'm using, or if it's a feature unique to Xubuntu 20.04 that's absent in 18.04. – JJrussel Nov 12 '20 at 01:49
  • @JJrussel: I think your results are the same as ours, Xubuntu 20.04 runs mostly in RAM whether the session is booted `toram` or not. (as long as the USB is a Live install such as Etcher, UNetbootin or Ventoy make). A Persistent install seems a little bit different – C.S.Cameron Nov 12 '20 at 07:10
  • @JJrussel, You taught me something today: See my edited answer. – sudodus Nov 12 '20 at 08:55
  • @C.S.Cameron and JJrussel, Checking all the files of the live system brings them into RAM, but I still think it is more reliable to use the boot option `toram`, when you want to run live with the USB drive unplugged. Otherwise I suspect that crucial parts of the system might be swapped out, if some process needs more RAM than what is free. – sudodus Nov 12 '20 at 08:59
  • @sudodus: Brilliant! This even explains why mkusb Persistent not `toram` USB does not seem to be running in RAM as much as a Live only not `toram` USB. This makes me wonder if `fsck.mode=skip` slows down a USB drive? I don't see much difference in normal operation myself. I guess that as far as running in RAM goes `fsck` is redundant if the USB is booted `toram` – C.S.Cameron Nov 12 '20 at 12:22
  • @C.S.Cameron, I think you are right about that. The time spent to check the files at boot matches the time spent for reading the files to RAM with `toram`. We can try to decide if it is a good idea or not with `fsck.mode=skip` in persistent live drives: I think it might depend on the size of RAM and the read speed of the USB drive. – sudodus Nov 12 '20 at 12:37