1

Does booting "persistent live to RAM" achieve the absolute lowest USB flash wear from a Ubuntu Live install with persistence, or are there additional tweaks that can be made to reduce flash writes even further? When I say 'live install with persistence' I mean the mkusb solution specifically, I'm not hacking some original solution manually.

From what I understand so far, the "persistent live to RAM" option leads to all writes being executed in RAM only and their data being dumped to the actual flash only on OS shutdown. But I'm not so sure that really minimizes total written blocks/cells per session - isn't that a really big chunk of data being written on each shut down, including everything on the root partition whether it was modified or not? Or is it some kind of selective process that skips unchanged data when doing the final dump back to storage? And is there really nothing configured to write logs or updates anywhere else during OS runtime, bypassing the RAM overlay?

Don Joe
  • 76
  • Sorry, but something doesn't add up in this "everything happens in RAM" explanation - if that were true the responsiveness of that OS would be beyond any install on even the fastest permanent storage solutions, whereas in my recent experience using the same bootable USB with persistence cloned to an NVMe SSD gave me incredible reaction speeds, far faster than any session of running that same install from its original Samsung Bar USB 3.0 64GB stick. If everything was moved to and happening entirely in DDR4 system RAM it should win out in speed over an NVMe SSD, but it loses quite visibly. – Don Joe Feb 27 '23 at 16:17
  • @Terrance I don't seem to have clarified this enough in my previous: both times I picked "persistent live to RAM" on boot, the only difference was starting the same cloned install sitting on an NVMe vs. on a USB stick. The NVMe one is visibly faster during usage (not just the initial load!), no special measurements needed to tell the difference, even though both are run allegedly "entirely from RAM". Something is fishy here, something important is being done outside of RAM that makes the speed of the storage you started from matter. – Don Joe Feb 27 '23 at 20:54
  • I didn't notice that you change your question from the first time I commented until now. I have no say on that persistence live to RAM as that is completely different than the toram. I will have to dive in deeper before any more comments from me. – Terrance Feb 27 '23 at 21:33
  • From testing here, I cannot get the Persistence to work on a drive for me as it might need EFI for it to work correctly, but I can get the straight toram to work just fine. I got it to load on 22.04 LTS and load completely into RAM without an issue. In theory, if you can get the Persistence and toram to work together then yes, it would reduce the amount of writes to the USB drive, but you would have to leave the drive in so the persistent mount is always available for when you make changes and it might crash if removed. Without persistence and without the USB it shouldn't crash the OS. – Terrance Feb 28 '23 at 04:23
  • @Terrance I used the ready-made solution installable with mkusb, maybe I should mention that in the question as well. – Don Joe Feb 28 '23 at 06:00
  • There are different ways to run Ubuntu from RAM. Any install of Ubuntu prefers to run in RAM if there is enough RAM. Persistent Live and Live Ubuntu will run fully in RAM using the toram option when booting. Persistent Live will save to the writable partition (AKA casper-rw), if the USB is plugged in, just like any Persistent install. The USB will last forever if it is removed using sudo umount -lrf /isodevice after booting to RAM, however, all new data will be lost once the drive is shut down. I have tried running Ubuntu as a server off MicroSD in toram mode. It lasted about six months. – C.S.Cameron Feb 28 '23 at 06:07
  • @DonJoe The mkusb is the one that I couldn't get to work properly. As far as the speed goes for the OS it is hard to tell you an answer as you didn't add that to your original question. I would kill all comments here and add or rewrite your question all together. Your comments are leaning away from your question completely. We are not a forum here but a Q&A site. If you want to discuss it, then I recommend that you ask over at the sister site of https://ubuntuforums.org – Terrance Feb 28 '23 at 14:48
  • I'm not the one who turned the comments into a discussion without posting a direct answer to the question. 2. The comments about speed do not change the focus of the question, which is still = minimizing writes; the comments about speed simply highlight some evidence that OS operation in my scenario is not happening 100% in RAM, which means that there should be space for further tweaking to minimize writes. 3. Beyond that, the comments so far have helped me refine the question 2 times, which is exactly what comments are for. The question seems quite clear to me now, it just needs an answer.
  • – Don Joe Feb 28 '23 at 15:41
  • @C.S.Cameron OK, but that practically removes the persistence function, so it's not really a solution within the scenario I proposed above. Most of what I've found so far about minimizing writes is stuff like disable swap or set swappiness=1, delay write-cache flushing, delay partition commits etc. But I don't know if any of that helps in my scenario as long as it remains unclear how much and how often things are written to flash under the "persistent live to RAM" operating mode. – Don Joe Feb 28 '23 at 15:47
  • 1
    So basically you have asked the same as https://askubuntu.com/questions/869214/what-is-happening-when-i-run-a-persistent-storage-live-usb-from-ram And yes, it will reduce writes to the USB drive until you make persistent changes that will happen on the casper-rw mount. Temp items will all be handled in RAM and not on the USB. – Terrance Feb 28 '23 at 18:12
  • So basically no I have not. That question is about reads, I asked about writes. And I was even more specific: I asked if writes can be reduced beyond what is already reduced by selecting "persistent live to RAM". I will also note that the selected answer on that page is also quite confused/vague about what happens with "persistent live to RAM" w.r.t. what's really in RAM and what isn't. – Don Joe Feb 28 '23 at 19:14
  • @Terrance Ah, I get it now, thanks for the link BTW! So it seems the answer is: yes, absolutely extra tweaks can be used, because "persistent live" with or without "toram" always writes to casper-rw, and the only part that's affected by "toram" is the read-only ISO, the base system. – Don Joe Feb 28 '23 at 19:46
  • @DonJoe I have to say that I just got it to work in a VM as a test, and with the persistence to RAM it runs better than anything else I have ever used, but it does take longer to boot due to copying the USB to RAM other than the persistence (writable). I was able to monitor the amount of USB writes vs HDD (RAM) and the USB was hardly touched during that test other than the VirtualBox tools install, and updated software that was stored in the persistence but it worked exactly as it needed to. The response time in the toram was incredible for a VM. – Terrance Mar 01 '23 at 01:32