How to know whether Xubuntu is running on ram or the live USB?

Solution 1:

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.

Solution 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.