<-- Back to WDL Cheatsheet menu: viewtopic.php?p=36426#p36426
Duprate wrote: Mon Sep 06, 2021 8:51 pm
2- w_changes=RAM, it didn't work for me!
NOTE: The following post is quite technical. Don't bother with it at this stage unless you are particularly intersted in getting RAM modes to work - system works fine by default with direct writes to external upper_changes for persistence anyway. But I'm just writing this to document that saving RAM modes does exist as a feature should you ever need it
There is no longer any w_changes=RAM mode.
Rather, there are three alternative w_changes RAM modes, as follows:
1.
w_changes=RAM0
This mode doesn't use any existing external media upper_changes folder at all. Instead a temporary upper_changes folder is created in RAM at directory /mnt/layers/RAM/upper_changes. Any session changes will appear in there as you work, but all is lost on shutdown (since was just in RAM) though of course you can copy or rsync whatever was there out to a new external upper_changes folder for using again some other time.
2. w_changes=RAM1
This was just a variation on w_changes=RAM0 above. The only difference is that once the RAM /mnt/layers/RAM/upper_changes is created, any external upper_changes contents are copied into that on boot. Again, any new changes just appear in RAM (the external upper_changes not being used at all after boot), and these new session changes will be lost on shutdown. However, I use a simple rsync script to allow me to copy the whole lot back again to the external upper_changes folder - i.e. this provides persistence. The disadvantage of this mode is that copying in the external upper_changes contents uses up RAM unnecessarily, but in practice the method is actually nice, simple, and reliable if you keep your external upper_changes folder small in size. In fact I preferred this mode for months - but I have a technique when using it:
a. When I first install new system I tend to not put upper_changes in RAM at all but instead fill my external upper_changes with all the extra big apps I want.
b. Then I make a 'rollback' upper_changes file by simply renaming the existing external upper_changes directory as somthing like 50upper_changes (you can leave that as an uncompressed changes rollback folder or use mksquashfs to produce 50upper_changes.sfs). The next time you boot the system that 50upper_changes simply becomes top read-only layer and a fresh empty upper_changes folder becomes the topmost read/write layer. I sometimes repeat that add to system followed by rollback files (e.g. 51upper_changes, 52upper_changes). Thereafter I have usually nothing else much to add so then I alter my grub kernel config to use w_changes=RAM1 mode and often do not bother rsyncing back thereafter (and keep external upper_changes of zero or very small size).
I have a reasonably well tested rsync script for this that I'll publish later. You more likely want to use no w_changes RAM modes at all or will prefer w_changes=RAM2 mode below since it saves some RAM used:
3. w_changes=RAM2
However, the third w_changes mode (w_changes=RAM2) is more like what you'd traditionally use on DebianDogs or Puppy systems. Again upper_changes is saved into RAM at /mnt/layers/RAM/upper_changes, but difference with this RAM2 mode is that any external upper_changes folder gets automatically mounted as the topmost read-only layer (so merged as part of the overall overlay merge result). Once again, any changes that occur during a boot session get lost on shutdown OR you run a save-back to the external upper_changes folder script to get full persistence. Note however that /mnt/layers/RAM/upper_changes for this mode only contains that single boots session changes so the save back to external upper_changes script actually needs to MERGE that /mnt/layers/RAM/upper_changes and not simply clobber the external upper_changes. Complication with this RAM2 scenario is that you have to keep some overlayfs 'whiteout' marker files for layer deletions to be correctly recorded. In practice I actually currently use a probably very imperfect single-line merge-back command (in a script). Fredx181 tells me he did something similar originally in his DD-bullseye OS but felt there were potential problems of leaving unneeded whiteout markers, in which case my simple script would also need expanded to seek out unwanted whiteouts (or you could likely easily modify fred's snapmergepuppy overlayfs-related script but using the WeeDog directory layers (you can see all WD layers by simply opening your filemanager at /mnt/layers).
Anyway, for now, personally, I'm still myself using w_changes=RAM2 to boot (i.e. put that on grub kernel line) and then simply using simple rsync one-liner to merge back - I suspect that is fine for small upper_changes use, but maybe there are problems if more complex rollback scenarios - I haven't been testing this mode for long yet. The save-merge-back command I use for this RAM2 mode is simply:
Code: Select all
rsync -av /mnt/layers/RAM/upper_changes/ /mnt/sda4/WDL_whatever/upper_changes
EDIT: that /mnt/sda4 is for my own system. You'd have to change that to match your own partition used. I actually have a few extras in the wd_saveRAM2 script I use to auto-determine which is my boot partition. Again I'll upload that wd_saveRAM2 script later rather than complicate current early testing with it just now.
Note it is very important to PUT a / at the end of /mnt/layers/RAM/upper_changes/, and NOT put a slash at the end of /mnt/sda4/WDL_whatever/upper_changes (i.e. the external media upper_changes folder), otherwise rsync makes a new upper_changes folder 'inside' the other one on external media upper_changes instead of merging as intended (try it and you will see what I mean...)
Let me know if you ever do try w_changes=RAM2 mode. I'm interested on results to see if more complex merge scheme really is required. I have suspicion that more complex removing of white out (char files) could itself cause issues and simply one-liner above isn't problematic at all for me thus far in small upper_changes situations I've been testing it with thus far. One thing I do extra though is that I use --exclude with rsync to not include certain large changes such as certain web browser caches and so on - exactly what is best to exclude is something I still have to determine.
-------------------------------
Of course, for now, to get you started, the easiest mode of all is not to use w_changes in any RAM mode at all. By default WDL init will auto-create an external upper_changes folder and auto-use that directly for persistence. Once you have the system built up the way you like it, that, I suggest is the time to consider if you want to use one of the w_changes=RAM[0 or 1 or 2] modes (primarily as a mechanism to save flash sticks from regular write cycles). In our forum-land, w_changes=RAM2 is probably what you would want on the whole I suspect.
wiak