How to utilise pre-made, empty save-file in latest pups

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
User avatar
MinHundHettePerro
Posts: 852
Joined: Thu 05 Feb 2009, 22:22
Location: SE

How to utilise pre-made, empty save-file in latest pups

#1 Post by MinHundHettePerro »

Hello :)!

The long-lost ability of a fresh pup to utilise a pre-made, empty, savefile is restored. 8)

Cannot remember exactly when it got lost - 4.3.1?, was definitely there in the 2-series, most likely also in 3-series (and 4.1.2?).

Anyway, I did miss this ability for a long time and have thought, on and off, for a few years to re-instate this function. Today, I finally got around to it 8).

Why?
- For a tester, or a frequent installer, it saves one reboot ...
- Makes it much easier for a user to implement usage of savefile file-systems other than ext?, not requiring pup-shutdown to create the savefile ...

For pupmode 12, it was easy - just some small changes in /etc/rc.d/rc.update ...

For pupmode 13 (pmedia=ataflash and usbflash), there were kernel panics until a small change in initrd.gz, inhibiting the sourcing of a non-existant file (in pup_ro_1) ...

Diffs of changes to /etc/rc.d/rc.update and initrd.gz_/init are provided for slacko-5.3.7.1 (slacko beta 4).

EDIT 130818 with improvements to the rc.update patch. (Diffed against Slacko-56_4G)

Code: Select all

--- rc.update.orig	2013-08-18 14:29:09.000000000 +0200
+++ rc.update	2013-08-18 17:02:23.286719035 +0200
@@ -71,6 +71,17 @@
  fi
 }
 
+# MHHP 130818, For to, again, allow for a pre-made, empty, pupsave-file in PUPOMODEs 12 &13 without loosing desktop icons etc.
+S_LAYER=`grep '^SAVE_LAYER=' /etc/rc.d/PUPSTATE | cut -f 2 -d '='|cut -f 2 -d "'"`
+case $PUPMODE in
+  "12"|"13")
+    [ ! -d /initrd"$S_LAYER"/root ] && [ ! -d /initrd"$S_LAYER"/usr ] && [ ! -d /initrd"$S_LAYER"/var ] && PUPMODE_org="$PUPMODE" && PUPMODE="5"
+  ;;
+  *)
+  ;;
+esac
+# /MHHP
+
 case $PUPMODE in
  "7") #tmpfs (pup_rw), hd for persistent storage (pup_ro1), ${DISTRO_PUPPYSFS} (pup_ro2).
   NEWFILESMNTPT="/initrd/pup_ro2"
@@ -198,6 +209,8 @@
  ;;
 esac
 
+[ $PUPMODE_org ] && PUPMODE="$PUPMODE_org" && unset PUPMODE_org && unset S_LAYER # MHHP 130818
+
 . $NEWFILESMNTPT/etc/DISTRO_SPECS #w020 has DISTRO_VERSION, DISTRO_BINARY_COMPAT, DISTRO_FILE_PREFIX
 
 NEWPVERSION="`grep '^DISTRO_VERSION' $NEWFILESMNTPT/etc/DISTRO_SPECS | cut -f 2 -d '=' | cut -f 2 -d '"' | cut -f 2 -d "'" | cut -f 1 -d ' '`" #110422

Code: Select all

--- initrd-tree_org/init	2012-11-13 23:57:00.000000000 +0100
+++ initrd-tree_new/init	2012-11-14 02:18:29.000000000 +0100
@@ -1490,7 +1490,11 @@
 #older ${DISTRO_FILE_PREFIX}save.2fs <v2.16 will not have this file...
 [ ! -f $OLDFILESMNTPT/etc/rc.d/BOOTCONFIG ] && touch $OLDFILESMNTPT/etc/rc.d/BOOTCONFIG
 #note, OLDFILESMNTPT can also be "" so BOOTCONFIG needs to exist in initrd also.
-. $OLDFILESMNTPT/etc/rc.d/BOOTCONFIG #can have EXTRASFSLIST variable.
+
+# . $OLDFILESMNTPT/etc/rc.d/BOOTCONFIG #can have EXTRASFSLIST variable. # MHHP 121113
+# In case a pre-made, empty save-file is supplied, for PUPMODE 13, it cannot be touched by the previous command; sourcing a non-existant file in the following line results in kernel-panic, so let's test if $OLDFILESMNTPT/etc/rc.d/BOOTCONFIG exists, and skip sourcing if non-existant. 
+[  -f $OLDFILESMNTPT/etc/rc.d/BOOTCONFIG ] && . $OLDFILESMNTPT/etc/rc.d/BOOTCONFIG #can have EXTRASFSLIST variable. 
+# /MHHP
 
 #110217 very bad hack, see /etc/rc.d/rc.update, rc.shutdown.
 [ ! -f $OLDFILESMNTPT/var/local/etc_profile_at_shutdown ] && cp -f $OLDFILESMNTPT/etc/profile $OLDFILESMNTPT/var/local/etc_profile_at_shutdown
EDIT:
Yes, I should probably have mentioned that this is mainly for woofers to use, or for those wanting to play around extensively with a certain version of puppy (unsquashing - patching - re-squashing your pupxxx.sfs) :).


Cheers :)/ MHHP
Last edited by MinHundHettePerro on Sun 18 Aug 2013, 15:24, edited 1 time in total.
[color=green]Celeron 2.8 GHz, 1 GB, i82845, many ptns, modes 12, 13
Dual Xeon 3.2 GHz, 1 GB, nvidia quadro nvs 285[/color]
Slackos & 214X, ... and Q6xx
[color=darkred]Nämen, vaf....[/color] [color=green]ln -s /dev/null MHHP[/color]

User avatar
MinHundHettePerro
Posts: 852
Joined: Thu 05 Feb 2009, 22:22
Location: SE

#2 Post by MinHundHettePerro »

There's been some interest in this topic as of lately, and the problem with a dd'ed savefileis mentioned here.

So, to update my above post with a simpler, scripted solution that does not involve any editing of puppy_*.sfs, nor of initrd.gz follows ... 8)

Save the two files below in the directory of your puppy_*.sfs (for non-optical medium booted pupmodes 12 &13), edit the first file for filename, filetype and size, run & done :). (or, continue with implementing puppy-support for your fs of choice and add it here ... :wink:)

make_empty_savefile

Code: Select all

#!/bin/sh
# Create an empty savefile, copy over /etc/rc.d/rc.update and patch that file for to auto-set icons, backdrop etc. as is done in pupmode 5.
# Also create an empty /etc/rc.d/BOOTCONFIG for to avoid kernel panic with empty savefile in pupmode 13 caused by a problem in initrd.gz_init, no need to edit initrd.gz_init, cff http://www.murga-linux.com/puppy/viewtopic.php?p=664566#664566
# To be run in the directory of puppy_******_*.*.sfs and rc.update_slacko-56_MHHP_130818.diff
# MHHP 2013-08-18

# ********************* Please edit *********************
FILENAME="slackosave-56_4g" # name of savefile without extension
FILETYPE="ext2" # ext2|3|4, reiser[fs], make sure your chosen FS is supported by your puppy ...
FILESIZE="512" # in MB
# *******************************************************

PUPFILE=`ls puppy*.sfs`

# FILE_EXTENSION
case "$FILETYPE" in
  ext2)
    FILE_EXT="2fs"
  ;;
  ext3)
    FILE_EXT="3fs"
  ;;
  ext4)
    FILE_EXT="4fs"
  ;;
  reiser|reiserfs)
    FILE_EXT="rfs"
  ;;
    *)
  ;;
esac

dd if=/dev/zero of=./"$FILENAME"."$FILE_EXT" bs=1M count=$FILESIZE
case "$FILETYPE" in
  ext*)
    yes|mkfs."$FILETYPE" "$FILENAME"."$FILE_EXT"
  ;;
  reiser)
    yes|mkfs."$FILETYPE" "$FILENAME"."$FILE_EXT"
  ;;
    *)
  ;;
esac
  
mkdir PUPSAVE
mkdir PUPSFS

mount -t "$FILETYPE" "$FILENAME"."$FILE_EXT" PUPSAVE
mount "$PUPFILE" PUPSFS

mkdir -p PUPSAVE/etc/rc.d

touch PUPSAVE/etc/rc.d/BOOTCONFIG # For to avoid kernel panic with empty savefile in pupmode 13
cp PUPSFS/etc/rc.d/rc.update PUPSAVE/etc/rc.d/

patch PUPSAVE/etc/rc.d/rc.update rc.update_slacko-56_MHHP_130818.diff

umount PUPSFS
umount PUPSAVE

rm -rf PUPSFS
rm -rf PUPSAVE

rc.update_slacko-56_MHHP_130818.diff

Code: Select all

--- rc.update.orig	2013-08-18 14:29:09.000000000 +0200
+++ rc.update	2013-08-18 17:02:23.286719035 +0200
@@ -71,6 +71,17 @@
  fi
 }
 
+# MHHP 130818, For to, again, allow for a pre-made, empty, pupsave-file in PUPOMODEs 12 &13 without loosing desktop icons etc.
+S_LAYER=`grep '^SAVE_LAYER=' /etc/rc.d/PUPSTATE | cut -f 2 -d '='|cut -f 2 -d "'"`
+case $PUPMODE in
+  "12"|"13")
+    [ ! -d /initrd"$S_LAYER"/root ] && [ ! -d /initrd"$S_LAYER"/usr ] && [ ! -d /initrd"$S_LAYER"/var ] && PUPMODE_org="$PUPMODE" && PUPMODE="5"
+  ;;
+  *)
+  ;;
+esac
+# /MHHP
+
 case $PUPMODE in
  "7") #tmpfs (pup_rw), hd for persistent storage (pup_ro1), ${DISTRO_PUPPYSFS} (pup_ro2).
   NEWFILESMNTPT="/initrd/pup_ro2"
@@ -198,6 +209,8 @@
  ;;
 esac
 
+[ $PUPMODE_org ] && PUPMODE="$PUPMODE_org" && unset PUPMODE_org && unset S_LAYER # MHHP 130818
+
 . $NEWFILESMNTPT/etc/DISTRO_SPECS #w020 has DISTRO_VERSION, DISTRO_BINARY_COMPAT, DISTRO_FILE_PREFIX
 
 NEWPVERSION="`grep '^DISTRO_VERSION' $NEWFILESMNTPT/etc/DISTRO_SPECS | cut -f 2 -d '=' | cut -f 2 -d '"' | cut -f 2 -d "'" | cut -f 1 -d ' '`" #110422

EDITED 130818 with improvements

Cheers :)/
MHHP
Last edited by MinHundHettePerro on Sun 18 Aug 2013, 15:19, edited 1 time in total.
[color=green]Celeron 2.8 GHz, 1 GB, i82845, many ptns, modes 12, 13
Dual Xeon 3.2 GHz, 1 GB, nvidia quadro nvs 285[/color]
Slackos & 214X, ... and Q6xx
[color=darkred]Nämen, vaf....[/color] [color=green]ln -s /dev/null MHHP[/color]

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#3 Post by musher0 »

Hello, MinHundHettePerro.

Thanks for suggesting a solution to the problem I reported at http://www.murga-linux.com/puppy/viewto ... 239#719239.

Just so it is clear in my mind:
Must your three scripts above be used only with slacko 5.6_4G, or is your solution valid for any Puppy?

Thanks in advance and best regards.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
MinHundHettePerro
Posts: 852
Joined: Thu 05 Feb 2009, 22:22
Location: SE

#4 Post by MinHundHettePerro »

musher0 wrote:Hello, MinHundHettePerro.

Thanks for suggesting a solution to the problem I reported at http://www.murga-linux.com/puppy/viewto ... 239#719239.

Just so it is clear in my mind:
Must your three scripts above be used only with slacko 5.6_4G, or is your solution valid for any Puppy?

Thanks in advance and best regards.

musher0
Hello, musher0!

Thanks for asking, ...

There's nothing slacko-specific to this workaroundy trick of allowing for a pre-made empty savefile. The script being patched is one of Puppy's start-up-scripts, /etc/rc.d/rc.update. The trick is to let Puppy's standard start-up-scripts run and decide what pupmode is appropriate, then, if an empty savefile is supplied, go back to pupmode 5 and do the first-run routines, after which the previously decided pupmode is resumed.
The naming of the patch-files just reflects the pup I diffed rc.update against. Should apply to "modern" pups, haven't investigated how far backwards, though :)...

Hth :)/
MHHP
[color=green]Celeron 2.8 GHz, 1 GB, i82845, many ptns, modes 12, 13
Dual Xeon 3.2 GHz, 1 GB, nvidia quadro nvs 285[/color]
Slackos & 214X, ... and Q6xx
[color=darkred]Nämen, vaf....[/color] [color=green]ln -s /dev/null MHHP[/color]

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#5 Post by Karl Godt »

Interesting thing MHHP !

The initrd.gz /init tends to change unexpectedly .
It writes all possible dirs and files into the savefile .

My question is about that line :

Code: Select all

+    [ ! -d /initrd"$SAVE_LAYER"/root ] && [ ! -d /initrd"$SAVE_LAYER"/usr ] && [ ! -d /initrd"$SAVE_LAYER"/var ] && PUPMODE_org="$PUPMODE" && PUPMODE="5"
If there is only /PUPSAVE/etc/rc.d/BOOTCONFIG and PUPSAVE/etc/rc.d/rc.update in the savefile , why the check for three directories ?
Is it "just in case" ?
What if tomorrow Barry comes to the conclusion that because Ubuntu had invented /var/ubuntu/update directory, the /init must touch that ?

BTW grouping might be more accurate like

Code: Select all

+   ( [ ! -d /initrd"$SAVE_LAYER"/root ] && [ ! -d /initrd"$SAVE_LAYER"/usr ] && [ ! -d /initrd"$SAVE_LAYER"/var ] ) && ( PUPMODE_org="$PUPMODE" && PUPMODE="5" )
or

Code: Select all

+    [ ! -d /initrd"$SAVE_LAYER"/root -a ! -d /initrd"$SAVE_LAYER"/usr -a ! -d /initrd"$SAVE_LAYER"/var ] && { PUPMODE_org="$PUPMODE"; PUPMODE="5"; }

User avatar
MinHundHettePerro
Posts: 852
Joined: Thu 05 Feb 2009, 22:22
Location: SE

#6 Post by MinHundHettePerro »

Karl Godt wrote:Interesting thing MHHP !

The initrd.gz /init tends to change unexpectedly .
It writes all possible dirs and files into the savefile .

My question is about that line :

Code: Select all

+    [ ! -d /initrd"$SAVE_LAYER"/root ] && [ ! -d /initrd"$SAVE_LAYER"/usr ] && [ ! -d /initrd"$SAVE_LAYER"/var ] && PUPMODE_org="$PUPMODE" && PUPMODE="5"
If there is only /PUPSAVE/etc/rc.d/BOOTCONFIG and PUPSAVE/etc/rc.d/rc.update in the savefile , why the check for three directories ?
Is it "just in case" ?]
Just my simplistic way of testing if the supplied savefile is "empty".
Now changed in the two first posts ...
What if tomorrow Barry comes to the conclusion that because Ubuntu had invented /var/ubuntu/update directory, the /init must touch that ?
That'd be a bummer, wouldn't it? :)
BTW grouping might be more accurate like

Code: Select all

+   ( [ ! -d /initrd"$SAVE_LAYER"/root ] && [ ! -d /initrd"$SAVE_LAYER"/usr ] && [ ! -d /initrd"$SAVE_LAYER"/var ] ) && ( PUPMODE_org="$PUPMODE" && PUPMODE="5" )
or

Code: Select all

+    [ ! -d /initrd"$SAVE_LAYER"/root -a ! -d /initrd"$SAVE_LAYER"/usr -a ! -d /initrd"$SAVE_LAYER"/var ] && { PUPMODE_org="$PUPMODE"; PUPMODE="5"; }
Perhaps not more accurate but, I agree that it would give a more grouped appeareance ...

Cheers :) /MHHP
Last edited by MinHundHettePerro on Sun 18 Aug 2013, 15:26, edited 1 time in total.
[color=green]Celeron 2.8 GHz, 1 GB, i82845, many ptns, modes 12, 13
Dual Xeon 3.2 GHz, 1 GB, nvidia quadro nvs 285[/color]
Slackos & 214X, ... and Q6xx
[color=darkred]Nämen, vaf....[/color] [color=green]ln -s /dev/null MHHP[/color]

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#7 Post by Karl Godt »

Perro , Thanks for the clarification !

User avatar
MinHundHettePerro
Posts: 852
Joined: Thu 05 Feb 2009, 22:22
Location: SE

#8 Post by MinHundHettePerro »

Hello!

First two posts edited with improvements to the rc.update patch ...

Cheers :) /MHHP
[color=green]Celeron 2.8 GHz, 1 GB, i82845, many ptns, modes 12, 13
Dual Xeon 3.2 GHz, 1 GB, nvidia quadro nvs 285[/color]
Slackos & 214X, ... and Q6xx
[color=darkred]Nämen, vaf....[/color] [color=green]ln -s /dev/null MHHP[/color]

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#9 Post by musher0 »

MinHundHettePerro wrote:Hello!

First two posts edited with improvements to the rc.update patch ...

Cheers :) /MHHP
Thanks!
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

Post Reply