An approach to persistence for overlayfs Puppy frugal installs.
Or, yet another 'init' script.
By default, Puppy would run in pupmode=66, no matter the filesystem of the install location or the save location.
So 'pup_rw' is always in RAM.
At every shutdown:
1) User is asked to save, "Yes" or "No"?
2) If "Yes", an archive of 'pup_rw' is created, e.g. using 'savesession-archive'.
The archiving process is "smart", ignoring files that don't need to be persistent.
In 'init':
If a "save" exists:
(A "save" could be a savefolder, savefile, or even a savesfs.
This version does not include support for a savesfs.)
1) The "save" is loaded as an RW directory at 'pup_ro1'
2) If a save archive exists, it is extracted into 'pup_ro1'.
The save archive file is then deleted.
3) The "save" could be re-loaded as an RO directory at 'pup_ro1'.
4) 'pup_ro1' is added to the stack immediately below the RW layer.
If no "save" is found:
If a save archive file exists, it is extracted into 'pup_rw'.
If no "save", and no archive:
It's a first-boot, pupmode=5.
Notes:
1) Only 2 pupmodes are really needed, pupmode=5 for first boot, and another for 'rc.shutdown'.
This is implemented as pupmode=66, because then a current 'rc.shutdown' will do the appropriate thing.
Hmmm... need pupmode=5 during first boot, but pupmode=66 during first shutdown.
This is done with a simple 'shutdownconfig' replacement in 'pm66plus01-ydrv.sfs'.
Or possibily:
If 'snapmergepuppy' were replaced with a symbolic link to 'savesession-archive',
maybe pupmode=13 could be used when a 'pup_ro1' is in play.
2) Out of the box, Puppy just runs with persistence, independent of the filesystem it is installed on,
no surprising questions for first-timers, e.g. no savefile setup on first shutdown.
3) Files that are deemed to not require persistence are NEVER saved to disk.
(Controlled by which files 'savesession-archive' includes in the archive.)
4) Since the "save" is never the top RW layer, there is never any issue with a "work" directory.
Also the "save" is strictly RO in the running system, so if it is a savefile, it is remounted RO.
The partition containing a savefolder could possibly be remounted RO, but that might impede "outside the stack" activity, e.g. installing new Puppies.
5) If a 'pup_ro1' is being used, it can be backed-up at any time during a session, since it is RO or is effectively RO.
Though the backup would not include any changes from the current session.
If 'pup_ro1' is not being used, the save archive can be copied at any time.
6) There needs to be a utility to create an empty "save" in the save location.
This could be run whenever the user deems the save archive is getting too large.
It could even be run before first-shutdown, so that it is in place for second-boot.
7) There could be an "archive location" concept introduced to Puppy.
This would be a partition dedicated to having save archive files written to it.
If it is on a different partition to the "save location" then the "save" partition could be remounted RO by 'init'.
The 'savessession-archive' process would mount and umount this partition.
This would enable a Puppy running with a "save" to approach the robustness of pupmode=5 in relation to sudden shutdowns.
8) This is not about the addition of an extra save mechanism, it's a replacement for the whole of the 'init' save mechanism handling.
9) Yes, there is no support for optical drives.
Although it could include support for booting image files, as per current 'init', e.g. ".iso" files.
10) Yes, it's the end on my beloved pupmode=12.
11) "RO" means "read-only"
"RW" means "read and write"
To try this first working version:
Download 'pm66plus01_local-initrd.gz' and 'pm66plus01-ydrv.sfs' from https://www.mediafire.com/folder/hutn1c5w6g9e7/pm66plus
Move both files into a fresh Puppy frugal install directory.
(I used FrugalPup for the install, if you do the install some other way, you need to ensure that the 'grub.cfg' menuentry includes support for a 'local-initrd.gz').
Rename 'pm66plus01_local-initrd.gz' to 'local-initrd.gz'.
Rename 'pm66plus01-ydrv.sfs' to an appropriate ydrv...sfs filename for the Puppy. e.g. 'ydrv_s15pup64_22.12.sfs'
Reboot.
Assuming a sucessfull boot to the desktop, fill-out the 'QuickSetup' form.
Reboot and click on the "Yes" button to save the session.
Assuming another sucessfull boot to the desktop, make further tweaks, and reboot.
The Puppy is now running in classic pupmode=66.
If you installed Puppy with a Linux save location (often the install directory), you can now start using a savefolder.
Create a new directory in the save location with the appropriate "save" name for the Puppy. e.g. 's15pup64save'
Reboot and click on the "Yes" button to save the session.
Assuming another sucessfull boot to the desktop, the Puppy is now running with a savefolder at 'pup_ro1'.
If you installed into a non-Linux partition, you can start using a savefile.
Create a new savefile with a name appropriate to the Puppy and reboot. e.g. 's15pup64save.4fs'
This should result in the Puppy running with the savefile at 'pup_ro1'.
Note that in the running Puppy the savefile is mounted RO.
Classic pupmode=66:
On shutdown the contents of 'pup_rw' in RAM are archived.
In 'init' an empty 'pup_rw' in RAM is populated by extracting the archive.
Current Puppy uses this only on fat32 partitions, e.g. usb sticks.
Extracting archive to ro1:
1) Unfortunately, the busybox tar in many Puppies 'initrd.gz' will not clobber existing files as I would expect,
so the files in the archive are removed from 'pup_ro1' before the extraction.
2) Whiteout files in 'pup_ro1' seem to work, even though they are not in 'pup_rw'
3)The whiteout files in 'pup_ro1' are then validated by checking if they "delete" a file in 'pup_sfs'.
If it does not, it is removed because it is a "defunct" whiteout file.
4) A list of overlayfs whiteout files can be obtained with this command:
find -H /initrd/pup_ro1 -type c
'pup_sfs':
This 'init' uses my "singly-init" algorithm to create an RO overlay at 'pup_sfs', of all the ".sfs" files defined for this session.
If a file does not exist in 'pup_sfs' then it's not in any of the ".sfs" files.
This overlay is then used as a "lowerdir" for the main RW overlay.
(If a savesfs were implemented, it would not be part of 'pup_sfs', it would be 'pup_ro1'.)
'pm66plus-ydrv.sfs':
'pm66plus-ydrv.sfs' contains an "improved" version of 'savesession-archive',
a very simple replacement for 'shutdownconfig' to force pupmode=66 on first-shutdown,
and a '/root/.config/save-exclude.lst' file.
savesession-archive filter:
'savesession-archive' combines the lines of "$HOME/.config/save-exclude.lst" file into a filter for a "grep -vE" command.
Editing this file will change which files get included in the save archive and hence 'pup_ro1'.