site  contact  subhomenews

Delayed session save simplified

October 20, 2025 — BarryK

When running in RAM, you can click on the "save" desktop icon and click the "Save Session" button to save the session immediately. Normally, you would be asked at shutdown.

The problem with doing an immediate save, is that it can't actually happen immediately, as the permanent storage, /mnt/wkg/.session, (actually, now /mnt/wkg/.session/session1) is mounted as a read-only layer in overlayfs. It cannot be written to.

The workaround was to save it to an intermediate folder, /mnt/wkg/.session-transit, then complete the flush to /mnt/wkg/.session in the initrd at next bootup. A very clumsy solution.

I have changed to an intermediate folder /mnt/wkg/.shutdown/easy_rw, and this gets flushed to /mnt/wkg/.session at shutdown, not delayed until next bootup.

The script /usr/sbin/ask-save-zram1, which runs by clicking on the desktop "save" icon, now does this when click "Save Session" button for an immediate save:

if [ -d /mnt/${WKG_DEV}/${WKG_DIR}.shutdown/easy_rw ];then
rm -rf /mnt/${WKG_DEV}/${WKG_DIR}.shutdown/easy_rw
fi
cp -a /mnt/.easy_rw /mnt/${WKG_DEV}/${WKG_DIR}.shutdown/easy_rw

...where /mnt/.easy_rw is the current session in RAM; that contains the main-desktop session and all the container sessions.

/etc/rc.d/rc.shutdown detects the pre-existence of .shutdown/easy_rw and runs  /etc/rc.d/shutdown-pivot-root to perform a pivot_root out of the overlayfs and flush to /mnt/wkg/.session

...the code can be studied in those scripts, with "#20251020" to identify changes.

There has been feedback that delaying save until initrd in next bootup is broken anyway. So now should be fixed, and also greatly simplified.    

Tags: easy