w_initconfig to override w_changes/w_changes1

Moderator: Forum moderators

Post Reply
User avatar
wiak
Posts: 3627
Joined: Tue Dec 03, 2019 6:10 am
Location: Packing - big job
Has thanked: 56 times
Been thanked: 994 times
Contact:

w_initconfig to override w_changes/w_changes1

Post by wiak »

Wrote this info and included when I last updated FR initrd, but to prevent this brief documentation being lost, here it is again. For simplicity, and because I'm short of time, I'll leave the original of this text along with the actual wd_initconfig_make script at its first published location here: viewtopic.php?p=116127#p116127

NOTE WELL: The very latest save2flash utility is required installed for w_initconfig to work properly (i.e. the one that DOES NOT check w_changes from /proc/cmdline).

# Changes: 05Apr2024 Now have optional w_initconfig externally sourced before w_init
# Can be used to override the likes of w_changes and w_changes1 and more...

Hardly tested this, but only a minor change (simple single line of code) involved so all previous functions untouched.

Clarity has often commented in various Puppy topics that Pups can redirect savefolder via a config file (they call that SAVESPEC apparently). In actual fact, KL distros have always been able to redirect savefolder location via w_init by simple writing to the top of external w_init file the likes of:

w_changes=UUID=whatever_xxx=/directory
w_changes1=RAM2

or can leave w_changes1 line out if wanting direct saves

As far as I remember doing so even works for ISO booting with the likes of Ventoy and so on. i.e. grub menu can easily be overridden by putting copy of w_init into the BOOTISOS folder and adding the suggested top two lines.

However, just to make that old KL/FR initrd redirect save persistence file/folder mechanism simpler to use, I now made a quick mod to the FR initrd to split the w_init into two parts. The first part is optional and is an external text config file called w_initconfig. It simply gets autorun before w_init (i.e. sourced) and could contain any relevant alterations a user wants, but definitely could simply contain that redirection of save folder information... Anyway, to make it even more simple, I've written a quick w_initconfig generator that will accurately and correctly write the relevant redirect of upper_changes savefolder information (i.e. with correct UUID and directory name); that was simple to write since just a modification to well-used and now re-used wd_grubconfig script code.

The w_initconfig file generator script is attached (script name is wd_initconfig_make). To use it simply place a copy of that script in the directory on whatever partition you want to redirect the savefolder persistence to - any place at all in fact. Then simply run the script and it will generate a suitable w_initconfig which you should copy into you frugal install directory (or BOOTISOS directory if using Ventoy). That w_initconfig redirection will take precedence over any grub menu choice so makes it easy to redirect save persistence anywhere and not just Persistence/Sessions... ANYWHERE YOU LIKE and includes working with ISOS as far as I believe, and no doubt in Qemu too (but didn't have time to test). Better docs later - just try it out. Help text given by:

Code: Select all

./wd_initconfig_make --help

==============================================
From: viewtopic.php?p=116165#p116165

Here is an example of me using the new wd_initconfig_make script. Scenario is that I have a frugal install of KLU jammy XFCE on my laptop. Since that uses a huge Puppy-style kernel out-of-the-box it is a trivial matter to swap in the new FR initrd:

1. just remove the old initrd.gz and w_init,
2. run the get_WDLskelinitrd_latest.sh from the frugal install directory, which auto-downloads new FR initrd-latest.gz along with w_init-latest
3. rename initrd-latest.gz to initrd.gz and w_init-latest to w_init

Prior to booting the KL distro, time to try out redirecting its upper_changes savefolder to some other partition/dir on the system. I've plugged in and mounted a Linux formatted usb stick for this test. I've simply created an empty directory on that usb stick named anything you like - I used name mysessions. So procedure to arrange all the KL distro saves to go to an auto-created upper_changes savefolder on that usb stick /mysessions is simple this:

1. place a copy of executable script wd_initconfig_make script into usb stick /mysessions directory
2. run it from there using command:

./wd_initconfig_make

That should auto-create a simple text config file called w_initconfig that contains the correct UUID-related w_changes= information along with w_changes1=RAM2 mode (user can manually edit out w_changes=RAM2 if they instead want direct writes rather than save on demand writes).

3. now simply copy that w_initconfig file to the main frugal install directory of the KL distro (in my case KLU jammy, which is on my main harddrive. You don't need wd_initconfig_make or w_initconfig inside the mysessions folder anymore; these were just used for generating the w_initconfig file for inserting into the actual frugal install directory.

That's all there is to it. On next boot of the KL distro an upper_changes folder will be auto-created on the usb stick /mysessions directory. Just make sure the usb stick is plugged in for the reboot (it will be auto-mounted so no need to worry about that detail).

NOTE: I don't have any iso that includes the new FR initrd as yet, so haven't tried with the likes of Ventoy, but I'm confident it will work there too. KL was specially designed to see files in the partition/dir where iso files are stored (wherever). Should just need to place copy of similarly generated w_initconfig into the BOOTISOS folder (or / or boot-isos or wherever you place your isos in fact...) and upper_changes redirection should automatically occur without any user-intervention required at boot time. To be tested of course... KL/FR way of handling Ventoy (and iso booting in general) is a bit different than most others, which is why it is pretty easy to have the likes of w_initconfig working with iso booting (including Ventoy) as well as normal frugal installs. Other distros tend to expect such config files inside the frugal install directory, which can't be added on the fly into a read-only iso of course... KL FR initrd does it differently. That isn't to say that initrd of other distros couldn't change approach to seek config files outside the iso of course; sometimes tricky to implement in a general-purpose way as an afterthought though; KL FR initrd adopted the approach from its start, hence it working in all such use cases without requiring maybe-messy error-prone code hacks. Some luck involved in original FR initrd design decisions as it turns out, which was no doubt helped by fact that most of that was designed in one quick few months coding blast in early 2019 rather than endlessly hacked in the years since. I very much doubt I could complete the feat nowadays - don't have the time anymore anyway... Modifying any initrd is tricky since one mistake and system often doesn't even boot (dreaded kernel crash) - the more flexible the initrd the more dangerous it becomes since lots of functionality closely inter-related with all other code in the initrd'; often best to leave well alone, but w_initconfig wasn't really a design change - just a more convenient way of using an existing facility so I was able to incorporate it in about 5 minutes of dev time... (a rare occurrence in terms of almost no dev time required...).

As I said in first post of thread, KL distros have always been able to redirect upper_changes savefolder in similar manner, but using the full w_init file. This splitting of w_init to include (optional) small initial w_initconfig file makes the procedure, I hope, a bit easier and especially with the help of the wd_initconfig_make auto-generator of w_initconfig content. Should be a dream for Ventoy or other iso booting mechanisms and keen to see how it works in combination with Qemu (though would involve partitions created on qemu-style qcow2 or raw file disks more generally than actual external hardware storage. Though I guess the latter 'could' be used for persistence with suitable qemu boot arguments - if so that would additionally be a handy way to share files between host and qemu guest).

https://www.tinylinux.info/
DOWNLOAD wd_multi for hundreds of 'distros' at your fingertips: viewtopic.php?p=99154#p99154
Αξίζει να μεταφραστεί;

Post Reply

Return to “How-To”