Supply a pup_save file as a grub menu argument

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
User avatar
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

Supply a pup_save file as a grub menu argument

#1 Post by Dougal »

-------------------------------------------------------------------------------
EDIT: Note that you can supply a PUPSAVE argument using the
unmodified Puppy -- you just need to add in the grub menu:

Code: Select all

PUPSAVE=ext3,hda3,/pup_save.3fs
(it will also work with pup_save in a directory, so use "/mydir/pup_save.3fs")
This way Puppy will only search for PUPSFS on your HD.
However, note that it will not find your ZDRV module, so you'll
have to supply it, too, in the grub menu:

Code: Select all

ZDRV=ext3,hda3,/zdrv_212.sfs
-------------------------------------------------------------------------------

This is a way to modify Puppy2 init scripts to accept a boot parameter telling it which
pup_save file to use (PUPSFS is needed) and bypass the "ransacking" of the HD
(it gives a minor speedup in boot time).
This is meant for use with frugal installs -- where you give the boot
parameter in the grub menu -- and maybe USB installs, too.

I will send it to Barry for inclusion in future 2.14, but thought some people
(Ecomoney?) might find it useful...

You'll need Pizza's initrd-editor.


Step one: edit initrd.gz
(can be done once for each Puppyversion and used on different computers)


Run the initrd-editor, open your initrd.gz file, then open the init script (/sbin/init)
and find the following two lines (lines 767-8 in 2.12):

Code: Select all

PDEV1=""
case $PMEDIA in
and add before them:

Code: Select all

if [ "$SAVEFILE" ] ; then
PUPSAVE="$SAVEFILE"
if [ "$PUPSFS" ]; then
PDEV1="`echo -n "$PUPSFS" | cut -f 2 -d ','`"
FSTYPE="`echo -n "$PUPSFS" | cut -f 1 -d ','`"
[ "$FSTYPE" = "msdos" ] && FSTYPE="vfat"
PUPSFS="`echo -n "$PUPSFS" | cut -d'/' -f2-`"
else
PDEV1="`echo -n "$PUPSAVE" | cut -f 2 -d ','`"
FSTYPE="`echo -n "$PUPSAVE" | cut -f 1 -d ','`"
[ "$FSTYPE" = "msdos" ] && FSTYPE="vfat"
PUPSFS="pup_$PUPPYVERSION.sfs"
else
then scroll down to the end of the case structure (837-8 in 2.12):

Code: Select all

esac
#...exit with PDEV1= full device name.
and add after it:

Code: Select all

fi

Now save and replace your initrd.gz with the fixed one.
Important: You should compare the size of the modified initrd.gz
with the original before replacing!!



Step two: edit your grub menu.lst

Open your grub menu.lst and to the boot line (after PMEDIA) add the
value of PUPSAVE that you want (you can find it in /etc/rc.d/PUPSTATE).
Note that I use "SAVEFILE" as the parameter, so you can still give
PUPSAVE as a parameter and it'll work like with the normal Puppy.
for example:

Code: Select all

SAVEFILE=ext3,hda3,/pup_save.3fs
VERY IMPORTANT: note that I have removed the quotes that appear in the PUPSTATE file!
If you leave them in you'll end up with
"'ext3" and "/pup_save1.3fs'" rather than "ext3" and "/pup_save.3fs"


You might also want to add a ZDRV parameter to the grub menu (after the PUPSAVE):

Code: Select all

ZDRV=ext3,hda3,/zdrv_212.sfs
Note that you can also supply a PUPSFS boot param, formatted like PUPSAVE/ZDRV.
So you can rename pup_212.sfs to, say, pup_666.sfs and then:

Code: Select all

PUPSFS=ext3,hda3,/pup_666.sfs
You can have your pup_save inside a directory -- so

Code: Select all

SAVEFILE=ext3,hda3,/mydir/pup_save.3fs
But it will not work with PUPSFS (it works after a slightly more complicated modification).

Done!
Last edited by Dougal on Sun 07 Jan 2007, 12:07, edited 1 time in total.
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind

User avatar
Sit Heel Speak
Posts: 2595
Joined: Fri 31 Mar 2006, 03:22
Location: downwind

#2 Post by Sit Heel Speak »

(***EDITED A THIRD TIME Don't do this. I've done further testing and discovered that it works on only one of my four machines, and that only by fluke luck.)

Is modification of initrd.gz really necessary? PFILE= still works in Puppy 2 (**EDITED: at least, it works using Grub4DOS latest version, downloaded from its home page; don't know about other versions...) (***AND EDITED AGAIN: Ah. I wasn't aware of context: the original question concerned booting computers in a cybercafe. This solution of mine, below, might be OK for a single user, but Dougal's offers better security, especially on public computers). This menu.lst works just fine:

Code: Select all

timeout 10 
default 0

title Puppy 2.13 loaded by Grub.exe, choosing pup_213.sfs and pup_save.2fs from 2nd hard disk

rootnoverify (hd0,0) 
kernel (hd0,0)/p213disk/vmlinuz root=/dev/ram0 PHOME=hda2 PMEDIA=idehd  PUPSFS=(hd1,0)/PUP_213.SFS  PFILE=(hd1,0)/PUP_SAVE.2fs-none-262144
initrd (hd0,0)/p213disk/initrd.gz 
boot
Or is there a point I'm missing here?
Last edited by Sit Heel Speak on Sat 06 Jan 2007, 21:05, edited 4 times in total.

amish
Posts: 615
Joined: Sun 24 Sep 2006, 23:15

#3 Post by amish »

i'm glad that the PFILE setting in menu.lst works for you, i setup the menu.lst from 1.07 to "upgrade" to 2.11 and it didn't seem to matter at all what PFILE was, nor did it use the one listed there.

but there may be a point i'm missing as well. you may be right, that init.gz doesn't need changing: perhaps it can be optionally added to init.rd0, in the manner that the puppyfirewall does? just a thought. either way, i think this is a pretty sexy idea, but there was another way iirc, and i don't know how pizza's does it, but he seems like one to ask.

for fun, you might have a look at the posts from this guy sometime. i dont know where he went, but he left great ideas behind regarding puppy1 that might still be useful?

http://murga-linux.com/puppy/search.php ... thor=kethd
sadly, it is not possible to separate politics from free software. free software - politics = unfree software.

User avatar
Sit Heel Speak
Posts: 2595
Joined: Fri 31 Mar 2006, 03:22
Location: downwind

#4 Post by Sit Heel Speak »

Hmmm...perhaps it's because I am not using Grub bootloader config from the Puppy menu, but rather Grub4DOS downloaded from its home page? (***EDITED no, it's because I hacked the BIOS for that ancient machine's funky IDE controller myself, didn't consider all cases, and then forgot I'd done so :roll: :oops: )
Last edited by Sit Heel Speak on Sat 06 Jan 2007, 21:46, edited 3 times in total.

amish
Posts: 615
Joined: Sun 24 Sep 2006, 23:15

#5 Post by amish »

maybe :) i'm using grub4dos from jady's pupwin98. still works for puppy 2. made a howto for it. but the difference in version could matter? who knows?

User avatar
Sit Heel Speak
Posts: 2595
Joined: Fri 31 Mar 2006, 03:22
Location: downwind

#6 Post by Sit Heel Speak »

(deleted by poster)

User avatar
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

#7 Post by Dougal »

Sit Heel Speak: You are right, it does work with an unmodified Puppy… I remembered someone tried it in the past and said it didn't work -- I guess it was because of the quotes.

However, I also had in mind the fact that Sunburnt has been complaining for ages about Puppy2 having problems with booting off USB, caused by the "ransacking" part of the code, so I thought of a way to bypass all that (also speeds up booting a little bit…).

I have modified the first post to say it is possible to pass an argument to an unmodified Puppy and also modified my code a bit so it uses a different name than PUPSAVE, so you can still pass the PUPSAVE argument like in the unmodified Puppy.
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind

User avatar
Sit Heel Speak
Posts: 2595
Joined: Fri 31 Mar 2006, 03:22
Location: downwind

#8 Post by Sit Heel Speak »

Dougal wrote:Sit Heel Speak: You are right, it does work with an unmodified Puppy…
??? It does ???

Try this: copy pup_2xx.sfs and pup_save.3fs (or .2fs) from hda/ to hdb/.

Now try using Grub to start the Puppy on hda. Look carefully at the boot messages and you will see that it is still mounting the save file from hdb.

If your Puppy does start the Puppy on hda, then I would like to know what Grub and menu.lst are you using?

It only appeared to work on mine, with Puppy on both hda and hdb, because my (partially toasted) controller was passing requests to hdb to hda. Seven years ago when I discovered that its secondary channel didn't work, I patched its BIOS so that I/O to the second channel gets sent to the first channel. I forgot this, and was still forgetting it when I first made the initial post saying that it worked.

On my three other computers, it doesn't work. If I try to start the Puppy from savefile on hda, if there is a savefile on hdb then Puppy starts from that.

I hope I have made my mistake clear!

User avatar
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

#9 Post by Dougal »

Sit Heel Speak wrote:
Dougal wrote:Sit Heel Speak: You are right, it does work with an unmodified Puppy…
??? It does ???

Try this: copy pup_2xx.sfs and pup_save.3fs (or .2fs) from hda/ to hdb/.

Now try using Grub to start the Puppy on hda. Look carefully at the boot messages and you will see that it is still mounting the save file from hdb.
It booted my frugal like I mentioned in the first message -- on hda3 -- and I also have pup_save files on hdb2... it worked.

I think what you are experiencing might be related to a basic error in the init script that I discovered yesterday:
when you boot from a non-cd media, findpupfunc is run through your media partitions.
On each partition, it runs ispupfunc -- which searches for PUPSFS and does some other things and, if there's no PUPSAVE, runs test3fsfunc (which searches for PUPSAVE and ZDRV).

Now, try putting your PUPSFS on hdb1 and booting without any PUPSAVE parameter and see what happens...

The moment PUPSFS is found, ispupfunc returns 0, which causes findpupfunc to terminate -- even if it hasn't found a PUPSAVE!!

I think this may account for some problems -- like the USB booting problem Sunburnt has been complaining about.
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind

Post Reply