Skeleton FR initrd uploaded

Moderator: Forum moderators

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

Skeleton FR initrd uploaded

Post by wiak »

NEW LATEST:

# initrd/init: simple switch_root init with overlay filesystem set up.
# Copyright William McEwan (wiak) 26 July 2019+; Licence MIT (aka X11 license)
# version="7.0.3"; revision="-rc1" Date: 05Apr2024
# 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

EDIT: I've also thrown together a new kmod version of this latest FR Initrd - I think Arch distros needed that. It is untested, but maybe fine... Late here, will upload that Arch-related skeleton FR initrd tomorrow.

Attachments
wd_initconfig_make.tar
remove dummy tar and make executable
(1.65 KiB) Downloaded 18 times
get_WDLskelinitrd_kmod_latest.sh.tar
this one for Arch-based KL distros only - untested
(1.06 KiB) Downloaded 26 times
get_WDLskelinitrd_latest.sh.tar
remove dummy tar and make executable
(1.04 KiB) Downloaded 25 times
Last edited by wiak on Tue Apr 09, 2024 2:37 pm, edited 3 times in total.

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

User avatar
wiak
Posts: 4082
Joined: Tue Dec 03, 2019 6:10 am
Location: Packing - big job
Has thanked: 65 times
Been thanked: 1208 times
Contact:

Re: Skeleton FR initrd uploaded

Post by wiak »

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
Αξίζει να μεταφραστεί;

User avatar
wiak
Posts: 4082
Joined: Tue Dec 03, 2019 6:10 am
Location: Packing - big job
Has thanked: 65 times
Been thanked: 1208 times
Contact:

Re: Skeleton FR initrd uploaded

Post by wiak »

NOTE TO ALL KL ISO PRODUCERS:

An IMPORTANT modification is required to the simple script save2flash

I have been testing new w_initconfig mechanism in that latest FR initrd recently released and all seems fine with it.

However, save2flash script included a check (I believe I unnecessarily put it in originally) to make sure RAM2 was selected mode on the boot loader. (usually grub2) kernel/linux argument list.

That check causes save2flash to exit out, refusing to snapmergepuppy, if that RAM2 kernel line argument isn't the found. Problem with that is that it prevents the override kernel arguments benefit that w_initconfig mechanism provides (or what an alternative override via modified extternal w_init could provide as an alternative to w_initconfig). An ability to override is a great thing (which is why, for example, systemd has an override unit mechanism).

To cut a not-too-long story short, save2flash script requires a few lines commented out to prevent the apparently completely unnecessary /proc/cmd line check for RAM2 mode. I suggest leaving the old code in, but commented out, just in case we ever find an issue that requires a revert, though I envisage no problem with its removal.

Please therefore modify save2flash script to the following and repackage for all new iso releases (e.g. the likes of the xbps package involved). Doing so, will allow you to use w_initconfig as described in my posts above to redirect save persistence to anywhere on system no matter what was in original grub configuration; this alteration is useful overall, but particularly useful for the likes of iso booting, which otherwise has limited control over where save folder can go:

Code: Select all

 #!/bin/bash

[ "`whoami`" != "root" ] && exec sudo ${0}

#if grep -q "w_changes=RAM2" /proc/cmdline || grep -q "w_changes1=RAM2" /proc/cmdline; then  #THIS LINE NEEDS COMMENTED OUT
 if [ "$(mount | grep /mnt/layers/uc_ro | grep rw)" ]; then  

  if [ "$DISPLAY" != "" ]; then
yad --center --on-top --picture --filename=/usr/share/pixmaps/spinner.gif --text="      <b>Saving Session . . .</b>    " --size=orig --width=220 --height=70 --center --inc=500 --no-buttons --undecorated &
pd=$!
/usr/bin/snapmergepuppy
sleep 4
kill $pd
  fi 

 else
yad --center --title="Save session" --text=" \n    Cannot run save session on demand\n    Directory <b>/mnt/layers/uc_ro</b> not connected  " --width=480 --button="Close!gtk-close:0"
exit
 fi
 
#else  #THIS LINE NEEDS COMMENTED OUT
#yad --center --title="Save session" --text=" \n    Cannot run save session on demand\n    Boot with option <b>w_changes=RAM2</b> or <b>w_changes1=RAM2</b> \n    to make use of this feature  " --width=480 --button="Close!gtk-close:0"  #THIS LINE NEEDS COMMENTED OUT
#fi  #THIS LINE NEEDS COMMENTED OUT

EDIT: To avoid any error and thus save time , maybe best to first simply modify the save2flash xbps file and send me it for checking prior to using in new iso releases. I'd do that myself, but still on the move and not used to building xbps packages any more.

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

User avatar
rockedge
Site Admin
Posts: 6549
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2751 times
Been thanked: 2627 times
Contact:

Re: Skeleton FR initrd uploaded

Post by rockedge »

wiak wrote:

not used to building xbps packages any more......

I've been using this version of XBPS compiled on Puppy Linux F96-CE_4 to quickly build .xbps packages directly in F96-CE_4

XBPS package manager for F96-CE_4

All I do is customize the Rox right-click menu to add in a symlink to /usr/local/bin/dir2xbps and then can build the packages directly from a directory.

Careful using xbps-install in F96-CE_4 !! It will install packages from the Void Linux repos into F96-CE_4, which can have system breaking results if glibc is upgraded for example while bringing in dependencies.

User avatar
fredx181
Posts: 3075
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 374 times
Been thanked: 1313 times
Contact:

Re: Skeleton FR initrd uploaded

Post by fredx181 »

Updated save2flash (v1.9_0) .xbps package with the change suggested above by @wiak : viewtopic.php?p=116540#p116540

User avatar
wiak
Posts: 4082
Joined: Tue Dec 03, 2019 6:10 am
Location: Packing - big job
Has thanked: 65 times
Been thanked: 1208 times
Contact:

Re: Skeleton FR initrd uploaded

Post by wiak »

Re-uploaded wd_initconfig_make to first post of thread because I had a stupid wee mistake in it. I had fixed it at home, but forgot to upload fixed version (previous version probably worked though, but gave an error message).

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

Post Reply

Return to “KL-Dev_Work”