How to force PUPMODE 13 (flash drive) when using hd install

How to do things, solutions, recipes, tutorials
Message
Author
kleung21
Posts: 28
Joined: Sat 18 Nov 2006, 07:11
Location: Toronto, Ontario

How to force PUPMODE 13 (flash drive) when using hd install

#1 Post by kleung21 »

The truth is, this method should allow you to force ANY pupmode. However, you should have a good understanding of how the pupmodes work first before you change things as you can break your puppy.

Barry has posted a description of Puppy and pupmodes at http://www.puppyos.com/development/howpuppyworks.html

I want to thank everybody that helped in coming out with this solution, especially Pizzasgood, Darkerror05, Dougal, and MU

Who this is for? Why I did it.

If you run puppy off your hard drive and use a puppy save file.

Pupmode 13 is the one used by USB drives. The advantage of forcing your hard drive to behave in the same manner is that a) it decreases writes and b) if you have a loud hard drive like mine, its a LOT quieter as it only flushes the cache/new files every 30 minutes. In this mode, the system will try to use every last bit of ram first before writing accessing the drive (I think)

This will disable your swap drive as well; which is good from my standpoint as the memory/swap drive increases access to the Hard drive = noise.

The tradeoff is that if your computer crashes in that time period, you're SOL with respect to new data.

The default mode for hard drive running is PUPMODE=12. In this mode, all writes are immediately passed through onto the save file image. Thus, there will be frequent writes as you keep modifying data/develop temp files, etc...

How-to

The parameter to edit is located in a boot-up script locked inside the compressed file initrd.gz
Unfortunately, there is no way you can directly edit this. Instead, you will have to uncompress this file, mount it in a temporary location, and then recompress it to get it to work.

Before you start

1) backup initrd.gz. This file is located in your initially mounted drive.

2) You will need to run the following commands to edit the init shell file. You can run this from a terminal -> xterm, etc...

The following commands will uncompress initrd.gz, mount it in a temporary location, run leafpad text editor so you can make the changes, and then recompress initrd.gz for you

Code: Select all

gunzip initrd.gz
mkdir /root/minit
mount -o loop initrd /root/minit
leafpad /root/minit/sbin/init
sync
umount /root/minit
sync
gzip initrd
cd /root
sync
3) What you need to change inside the init script

Find the following line of
Code:

Code: Select all

case $PUPMODE in
then add before it this line of
Code:

Code: Select all

PUPMODE=13
That's it in a nutshell. Now reboot and your puppy works in mode 13. I can see this as a method for forcing other PUPMODES but since I haven't analyzed all the other failpoints, you might want to check it out yourself.

EXTRAs

If you want your hard-drive to power down quickly after this is all done, you can edit 1 more startup script to add the following commands. This can be done without fancy initrd.gz work.

Open up a text editor and open the file

/etc/rc.d/rc.local

add the following commands at the end. You will have to change the command to specify the correct hard drive.

Code: Select all

swapoff -a
hdparm -S3 /dev/hda
hdparm -y /dev/hda
These 3 commands will
- turn off all swap files
- set your hard drive to spin-down into standby mode after 15 seconds. S1=5sec, S2=10sec S3=15 sec, you get the picture.
- put your hard drive into standby mode immediately.

User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

#2 Post by Pizzasgood »

I wrote a script a while back to force a save in mode 13, just in case you did something important or want to do a hard-shutdown.
http://www.murga-linux.com/puppy/viewto ... py&t=11542

Also note, every thirty minutes, Puppy will start copying everything you've done. That means it runs nice the rest of the time, but you might experience slowdown when it copies everything that accumulated in one burst.
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

Fractal
Posts: 8
Joined: Wed 08 Dec 2010, 11:54

#3 Post by Fractal »

Unfortunately your mount command fails with "you must specify the filesystem type".
It won't work with any of the filesystem types when I try to use the "-t" option. What am I doing wrong?

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#4 Post by jamesbond »

If you want to force puppy to run in PUPMODE=13 all you need to do is specify pmedia=ataflash on your boot command line. No initrd hacking is required.

cheers!
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

_Mark_
Posts: 97
Joined: Thu 24 Sep 2009, 07:17

#5 Post by _Mark_ »

jamesbond wrote:If you want to force puppy to run in PUPMODE=13 all you need to do is specify pmedia=ataflash on your boot command line. No initrd hacking is required.

cheers!
That's what I like the hard way followed by the easy way, presuming they both work I know which one I would use :)

Fractal
Posts: 8
Joined: Wed 08 Dec 2010, 11:54

#6 Post by Fractal »

No! PMEDIA=ataflash does not do that with the version I am running (4.2.1)
Here's my GRUB lines:

kernel /vmlinuz PMEDIA=ataflash
initrd /initrd.gz

But there's no "Save" icon on my desktop and no save is made when shutting down and (most importantly) my CF drive is trashed if I suddenly remove power. This is vital because once I get my application deployed, the customers will be pulling power all the time as their preferred shutdown method (it's an industrial deployment). Puppy must protect my CF, which means PUPMODE=13 is a must.

I think version 4.2.1 has this bug, but newer versions I have tried fail to initialise my SBC's serial port, which I am using to communicate with an industrial controller.

If you helpful guys could point me in the right direction so I can start editing my init script, I'd appreciate that. Pizzagood's method doesn't work for me.

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#7 Post by rcrsn51 »

Another strategy is discussed here.

Fractal
Posts: 8
Joined: Wed 08 Dec 2010, 11:54

#8 Post by Fractal »

Thanks, guys!

All done. Basically, I have been looking for an alternative to Windows Embedded and I found Puppy. Puppy 5x worked well and I was impressed until I discovered that my application could not read or write the serial port of my SBC. I finally settled on 4.2.1 and remastered it. Then my customers decided they wanted window transparencies so I needed a composing WM (JWM is not composing).
I am now experimenting with Succi Puppy which uses xcfe as it's WM, which is compositing. My app now has transparent-capabilities but I have a Portugese initrd, and also the PUPMODE 13 bug.

So thanks for that script - I am now running in PUPMODE 13.
Now to un-translate all that Portugese... ;) Ta again.

Sylvander
Posts: 4416
Joined: Mon 15 Dec 2008, 11:06
Location: West Lothian, Scotland, UK

#9 Post by Sylvander »

Running Lupu-520 from "live" CD-RW, with lupusave on a folder, in the root folder, of an ext3 partition [sdb2], on the 2nd internal HDD.
Hence, initrd.gz is on a CD-RW disk! :?

I'd like to give this a try...
And yet, being less than experienced...
I'm puzzled by:
1. The code provided, as follows...

Code: Select all

gunzip initrd.gz
mkdir /root/minit
mount -o loop initrd /root/minit
leafpad /root/minit/sbin/init
sync
umount /root/minit
sync
gzip initrd
cd /root
sync
You'll probably laugh, but...
Do I <Enter> one line of code at a time?
Or copy and "Shift+insert" all of it in one go?

2. Could you perhaps explain what each line of code achieves?

3. After which line should I edit the contents of "the init shell file".

4. Regarding "Extras"...
(a) I have no swap partition in use, so how does that affect things.
(b) In my Puppy file = /etc/rc.d/rc.local
Should I be using the code:

Code: Select all

hdparm -S3 /dev/sdb
hdparm -y /dev/sdb
5. Thought it better to ask, rather than proceed in hope, with fingers crossed.

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#10 Post by jamesbond »

Sylvander, the original post was in 2006, probably for Puppy 2.x series. The instruction is now longer valid - Puppy has since changed the format of initrd.gz (from ramdisk format, to initramfs format).
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

Sylvander
Posts: 4416
Joined: Mon 15 Dec 2008, 11:06
Location: West Lothian, Scotland, UK

#11 Post by Sylvander »

Is it no longer possible to run a HDD pupsave as if it were a Flash Drive pupsave?

If it IS still possible...
Does anyone know how to do it?
[Without using GRUB, or making a locked-down installation]

I want to be able to choose whether/when to save the [pupsave on HDD] session, either during the session or at shut-down.
Just like I do when the pupsave is on a Flash Drive.

Jasper

#12 Post by Jasper »

Hi Sylvander,

STEP 1
You could permanently change System>Puppy Event Manager>Save Session> Interval to 0.


STEP 2a
Then if you don't want to save you could rename your current save file by putting say an "x" as the first character with a view to returning to the original name after shut down.


or STEP 2b
Alternatively and more easily, you could do a hard "power off", unless that is never to be recommended.

My regards
Last edited by Jasper on Thu 17 Feb 2011, 15:31, edited 1 time in total.

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#13 Post by jamesbond »

Sylvander wrote:Is it no longer possible to run a HDD pupsave as if it were a Flash Drive pupsave?

If it IS still possible...
Does anyone know how to do it?
[Without using GRUB, or making a locked-down installation]

I want to be able to choose whether/when to save the [pupsave on HDD] session, either during the session or at shut-down.
Just like I do when the pupsave is on a Flash Drive.
Have you tried pmedia=ataflash I suggested above? If you are running from CD-RW - you should be able to see the boot menu, you can just type "puppy pmedia=ataflash" during boot-up. Then follow Jasper's suggestion.
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

Sylvander
Posts: 4416
Joined: Mon 15 Dec 2008, 11:06
Location: West Lothian, Scotland, UK

#14 Post by Sylvander »

@jasper
1. "You could permanently change System>Puppy Event Manager>Save Session> Interval to 0."
(a) When using a pupsave on a Flash Drive:
That applies, and I already know how to do that, plus...
How to stop "SAVING TO FILE" at shutdown.
These are what I use when the pupsave is on a Flash Drive.

(b) I believe that in order to apply these when the pupsave is on a HDD, I need to be able to make the Puppy [using a pupsave on a HDD] behave as though it were a Puppy using a pupsave on a Flash Drive.
That would be an elegant solution.
Your other 2 suggestions are inelegant solutions I don't fancy using.

@jamesbond
2. "If you want to force puppy to run in PUPMODE=13 all you need to do is specify pmedia=ataflash on your boot command line. No initrd hacking is required."
(a) Where is this "boot command line"?
Remember I'm using a "live" Puppy CD-RW.
Wouldn't want to be forced to type a command at EVERY boot.
Is it possible to include it within one of the files on the CD?
i.e. Alter a line of code within a file in the ISO used to make the CD?

Jasper

#15 Post by Jasper »

Hi Sylvander,

I have amended my post above by adding step numbers.

It is easy to test if Step 1 works on your hard drive by making an insignificant and unimportant change, and then using either Step 2a or Step 2b (ignoring elegance for a one-off trial). Then rebooting.

My regards

With MultiPup I'm pretty sure CatDude explained to us (you and me) how to change both the choices and sequence of the initial boot parameters; but (though I tried It) I can't retest that as my CD/DVD facilities are now kaput.

Fractal
Posts: 8
Joined: Wed 08 Dec 2010, 11:54

#16 Post by Fractal »

My SBC doesn't have a HDD - it has a 512MB CF drive, so it's important that Puppy protects it with minimal writes.
I am using 4.2.1, because 5.x doesn't seem to want to let me use the serial port, which I need.
Here are my findings:

PMEDIA=ataflash does NOT WORK. This might be because the CF cards I am using all register as non-removable.

To force PUPMODE=13, I edited my init script in the root of initrd using the "editinit" script from Pizzagood. I added the line "PUPMODE=13" at an appropriate point to force it to use PUPMODE=13.

However, this does mean editing the init script and permanently knobbling it.

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#17 Post by jamesbond »

Fractal, Sylvander uses Lupu 5.2 - so it pmedia=ataflash should work (I think).

Sylvander - when you say "live CD-RW" - I assume you just burn puppy ISO to your CD-RW and boot from there. Now, I don't usually use live-CD-RW, so no guarantee that this will work. The file you would need to edit isolinux.cfg. Change the last line from "pmedia=cd" to "pmedia=ataflash". The easiest way to do this is:
a) extract isolinux.cfg from Lupu 5.2
b) edit the file as above
c) get a version of puppy that has ISOMaster in it.
d) use isomaster to replace the isolinux.cfg in the puppy iso with the one you just edited
e) save the new iso, and then burn it.

Good luck.
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

Sylvander
Posts: 4416
Joined: Mon 15 Dec 2008, 11:06
Location: West Lothian, Scotland, UK

#18 Post by Sylvander »

Job done, altered ISO file made as per your instructions. :D

Here's greater detail on what I did:
1. Extract isolinux.cfg file from lupu-520.iso file.
(a) Using Xfe, I navigated to the folder holding the ISO file.
(b) Clicked on the icon [in Xfe] to "Lauch Terminal" that applies to the contents of that "Active" window.
(c) Typed the first few characters of the command filemnt [e.g. filem] and hit <Tab> to complete the name of the command.
[There should be a space after the command name]
(d) Type the first few characters of the name of the ISO file = lupu-520.iso [e.g. lu], and hit <Tab> to complete the name.
(e) Hit <Enter> to activate the command upon the named file.
(f) The ISO file mounted successfully at folder = /mnt/[name of file] = /mnt/lupu-520.iso

2. Edit the file as above.
(a) Right-clicked on the isolinux.cfg file within the /mnt/lupu-520.iso folder, and copied it to a handy folder = /00
(b) Right-clicked on that file, chose "Open with...", chose "Leafpad", and the file opened in Leafpad.
(c) Edited as you'd instructed, closed the file, and saved the changes when offered.
(d) Right-clicked on /mnt/lupu-520.iso folder, and chose "unmount".
An error was reported as though it had failed, but it actually succeeded in the unmount.

3. Ran ISOMaster.
(a) Went to "Menu->Multimedia->ISOMaster", and clicked that to run it.
(b) Clicked "File->Open", and navigated to the ISO file, made sure it was selected [highlighted], and clicked the "Open" button.
(c) The ISO file opened, and all the included files were listed in the bottom window.

4. Use isomaster to replace the isolinux.cfg in the puppy iso with the one you just edited.
(a) Highlighted the isolinux.cfg file in the lower pane and clicked the "Remove" icon.
It was removed.
(b) Used the "Go back" icon above the upper pane to navigate to the /00 folder holding the edited isolinux.cfg file, highlighted the file, clicked the "Add" icon above the lower pane, it was added to the lower pane.

5. Save the new iso, and then burn it.
(a) Used "File->Save as..." to navigate to the folder location of the original ISO file, and saved it with the name lupu-520-ataflash.
The program auto-added the .iso extension.
(b) Used "Menu->Multimedia->burniso2cd" to burn the ISO image to a new CD-RW disk.

6. Still to try the new CD-RW; wish me luck. :D
SUCCESS! :D
IT WORKS! 8)

Jasper

#19 Post by Jasper »

Hi Sylvander and jamesbond,

It's good to see a job well done.

My regards

Bruce B

#20 Post by Bruce B »

Fractal wrote:To force PUPMODE=13, I edited my init script in the root of initrd using the "editinit" script from Pizzagood. I added the line "PUPMODE=13" at an appropriate point to force it to use PUPMODE=13.

However, this does mean editing the init script and permanently knobbling it.
You can make backups of init, for example cp init init.BAK. When you repack it, leave init.BAK inside the newly compressed initrd.gz

You might not know for sure if the modifications do as you want until you reboot. If not, open initrd.gz and cp init.BAK init. Now you have a fresh geunine init to play with.


~

Post Reply