I've been racking my brain trying to figure out the best way to do this. It might sound a bit confusing, so let me explain the "why" first.
I already have a Linux live USB stick (on a high-end 256GB Samsung USB stick that's as fast as an SSD, it works great!) But what I want is to create a different Linux USB stick(s) only for performing basic bulk tasks like cloud restores or running the same maintenance script on different laptops/desktops at once. Some of these are in various states, various OSes, some don't even have a network connection... But sticking in Linux USB with the files I need and a standardized script running/recovery environment is perfect.
Problem is, I obviously have a limited number of USB sticks. What I want is to be able to boot into the OS and have it all stay in RAM, then pull out the USB stick and nothing weird happens, it just keeps going. Well guess what already does this out of the box? The Ubuntu Live 22.04 installer in "Try Ubuntu" mode. This also has the advantage of taking up way less space than a standard 22.04 install, which also means less RAM use as the disk is stored entirely in RAM. It takes up as little as 1.6GB by my observation.
Update: By removing maybe-ubiquity
from grub, I was able to get the system to boot directly into the Live Ubuntu rather than the installer. Thanks to @Raffa for the help with that. Secondly, I was able to customize the non-persistent filesystem (under /casper/filesystem.squashfs
) by using the unsquashfs
tool, booting a VM, changing stuff, and re-making it. However, this is super inconvenient, especially if you only want to make a small tweak.
Also, I can confirm that even with the toram
option added to grub, the persistent partition (which fyi, you get by simply naming an ext4 partition 'writeable' and booting with the persistent
option) DOES NOT get cached. The system will immediately glitch out and eventually hang/crash upon removal of the USB. In non-persistent mode however, things are now nice and stable when the USB is removed. I even wrote a script that safely unmounts the USB on boot, so you're good to remove it as soon as you see the desktop come up.
One idea I have is that I could automate the unsquishing and resquashing process, so that you can literally boot into non-persistent mode like normal, but upon running a script, the RAM contents are written back into filesystem.squashfs. This has the risk that data will be lost if the system powers off unexpectedly, but given that I'd only be making changes every once and a while, and under most cases only using non-persistent mode, this makes sense for my use case.
maybe-ubiquity
option (ie. not ask ask if you want to TRY or INSTALL), so if I wanted to create aush a system I'd explore those. You also ask about the TORAM option, but without the product/release details I just glanced at your question (as didn't have a specific ISO/product to consider). – guiverc Jan 07 '23 at 10:33