Install Puppy to non-root location at USB stick

Booting, installing, newbie
Message
Author
Toxic
Posts: 9
Joined: Sun 14 Dec 2008, 23:34

Install Puppy to non-root location at USB stick

#1 Post by Toxic »

I have USB stick with several live distros and other stuff (like Win PE, etc).
I have working GRUB (grub4dos 0.4.4, to be precise) on USB device. I need Puppy to run from non-root directory, e.g. /boot/distros/puppy. I've tried some options to grub but still with no results. Here's what I have in GRUB:

Code: Select all

title Puppy Linux 4.1.2
root (hd0,0)
kernel /boot/distros/puppy/vmlinuz root=/dev/ram0 pmedia=usbstorage psubdir=boot/distros/puppy
initrd /boot/distros/puppy/initrd.gz
boot
Grub starts to load kernel, but it always says pup_412.sfs not found..., however it's in /boot/distros/puppy/pup_412.sfs
I've tried to change pmedia param (usbstorage, usbflash, usbhd) - no luck.

Any suggestions?

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

#2 Post by rcrsn51 »

I'm not sure if the psubdir argument is able to drill that far down into your subfolder. I would try putting everything in a /puppy folder instead.

Then use:

Code: Select all

title Puppy Linux 4.1.2
root (hd0,0)
kernel /puppy/vmlinuz pmedia=usbflash psubdir=puppy
initrd /puppy/initrd.gz 

Toxic
Posts: 9
Joined: Sun 14 Dec 2008, 23:34

#3 Post by Toxic »

Ok, will try. However it's not my goal...

ICPUG
Posts: 1308
Joined: Mon 25 Jul 2005, 00:09
Location: UK

#4 Post by ICPUG »

To confirm rcrsn51's thoughts.

Puppy's init script is written to drill down only one directory when looking for the Puppy files.

If you want to go further down you have to modify that script.

Bruce B

#5 Post by Bruce B »

There have been no demands or even requests for nesting Puppy any deeper.

In the absence of reasons, demand or requests, it won't likely happen.

But this is open source, and one of things I like about it is: you can make it behave as you wish, providing it is technically feasible. What you want is technically feasible as far as I can see.

Toxic
Posts: 9
Joined: Sun 14 Dec 2008, 23:34

#6 Post by Toxic »

Well, It did boot from /puppy, as I expected.

Where should I make a request about nested drill?

Besides, I'm win32 programmer myself, so if you point me how to extract and then repack desired file I might try to edit it myself. Articles are welcome too.

ICPUG
Posts: 1308
Joined: Mon 25 Jul 2005, 00:09
Location: UK

#7 Post by ICPUG »

toxic,

the init script is in initrd.gz.

Pizzasgood made instructions for unpacking this file and repacking it here:

http://www.murga-linux.com/puppy/viewtopic.php?t=25645

This was for Puppy series 3. I have not seen anything since. I presume it is the same for series 4.

The init file is in /sbin/init I think

Toxic
Posts: 9
Joined: Sun 14 Dec 2008, 23:34

#8 Post by Toxic »

Well, I did it by changing only few bytes:
FND_INITRDGZ="`find /mnt/data -maxdepth 4 -mount -type f -name initrd.gz | grep -v ' ' | sed -e 's%^/mnt/data%%g' | tr '\n' ' '`"
FND_PUPXXXSFS="`find /mnt/data -maxdepth 4 -mount -type f -name pup_${PUPPYVERSION}*.sfs | grep -v ' ' | sed -e 's%^/mnt/data%%g' | tr '\n' ' '`"
FND_ZDRVSFS="`find /mnt/data -maxdepth 4 -mount -type f -name zdrv_${PUPPYVERSION}.sfs | grep -v ' ' | sed -e 's%^/mnt/data%%g' | tr '\n' ' '`"
FND_PUPSAVE2FS="`find /mnt/data -maxdepth 4 -mount -type f -name pup_save*.[23]fs | grep -v ' ' | sed -e 's%^/mnt/data%%g' | tr '\n' ' '`"
FND_SWAPFILEPUP="`find /mnt/data -maxdepth 4 -mount -type f -name pupswap.swp | grep -v ' ' | sed -e 's%^/mnt/data%%g' | tr '\n' ' '`"
And since PSUBDIR parameter is used as regular expression pattern I've escaped '/' character in command line. In result, I have following command line:

Code: Select all

label puppy
kernel boot/puppy/vmlinuz
append initrd=boot/puppy/initrd.gz pmedia=cd psubdir=boot\/puppy
So, almighty developers, can you please increase value for maxdepth parameter in default init script? It will solve nested root location problem.

User avatar
Crash
Posts: 453
Joined: Fri 09 Dec 2005, 06:34
Location: Melbourne, FL

#9 Post by Crash »

ICPUG-

Thanks for remembering a post that is almost a year old. And thanks to Pizzasgood for providing the instructions. Anything like this helps us Linux newbees (You'd think I would have progressed farther in three years :)).

Toxic-

Nice hack of initrd.gz. Doesn't look like a difficult thing to change.

The nesting four deep has its good points and bad. I like to hide versions of Puppy on my hard drive when I am testing out a new media such as SD card, and do so by moving the files two levels down in the directory structure. I suppose I could move them down five levels, but it would take some getting used to.

Also, I think the bootup may be slow if you have a lot of stuff on your hard drive and the search is four levels deep, but I don't know that for sure. Anyway, booting Puppy to a subdirectory is relatively new, since about version 3.01 or so. It works good for me as-is, but I don't have as many different distros on my hard drive as you do.

Toxic
Posts: 9
Joined: Sun 14 Dec 2008, 23:34

#10 Post by Toxic »

Agree. Drilling 4 dirs depth is a very time-consuming when you have partitions with a complex directory structure. Easiest way is to add another kernel parameter which will allow user to specify desired depth level.
However, I think there should be more straight and simple lookup method, like in Parted Magic distro, for example:

Code: Select all

for devices in sd* hd*
do
  echo /dev/$devices | cat >> /tmp/device_list
done

for devices in $(cat /tmp/device_list)
do
  clear
  echo Scanning device: $devices
  mount -n $devices /livemnt >/dev/null 2>&1
  if [ -e /livemnt/${LOCATION}/pmagic/pmodules/pmagic.7z ]; then
    PMAGIC_USB_DEVICE="$devices"
    echo "$PMAGIC_USB_DEVICE" | cat > /tmp/pmagic_device
    break
  fi
  umount -n /livemnt >/dev/null 2>&1
done
Where LOCATION variable is a counterpart of PSUBDIR in Puppy.

User avatar
Crash
Posts: 453
Joined: Fri 09 Dec 2005, 06:34
Location: Melbourne, FL

#11 Post by Crash »

I'm still analyzing the code here, and can't yet make comments on the actual implementation, but it seems like there are reasonable solutions. My thought was to have a boot parameter "MAX_DEPTH" or some such name that would define the subdirectory search depth on boot-up. It would have 2 as default and have some upper bound so things wouldn't go crazy if you entered "100", for instance. But tying it to PSUBDIR seems more elegant.
Toxic wrote:So, almighty developers, can you please...
There was a TV three part series called The Martian Chronicles that came out in 1980, based on Ray Bradbury's novel. I don't know how well it followed the book, not having read it, but I remember the end quite well. Rock Hudson invites his family on a picnic to "meet the Martians", who are pretty elusive by this time. The family is at the edge of a pond and they look in at their reflections. Rock Hudson says "Those are the Martians".

Toxic
Posts: 9
Joined: Sun 14 Dec 2008, 23:34

#12 Post by Toxic »

Well, this code is simple. It first retrieves a list of available sd? and hd? devices, then it mounts each of them and searches for specific file at specific path on that device. It works much faster because it doesn't iterate through entire filesystem as find function does.

ICPUG
Posts: 1308
Joined: Mon 25 Jul 2005, 00:09
Location: UK

#13 Post by ICPUG »

Crash

Your story about the Martian Chronicles ending was SO appropriate and made me smile!

With Free Software we can, with the necessary skills, all become developers.

It seems my little memory jogger has triggered some very useful investigation. Can't wait to see the outcome of your and Toxic's labours.

User avatar
Crash
Posts: 453
Joined: Fri 09 Dec 2005, 06:34
Location: Melbourne, FL

#14 Post by Crash »

IPUG-

Thanks for the support. I'm sure something will come out of this.

Toxic-

I agree the Parted Magic code is straightforward - it's the init code that I need to analyze.

I'm just transitioning over to doing Linux (Bourne?) shell scripts, so this will take a little while. Compared to DOS batch code, I find it to be far more powerful but it can get me into trouble faster, too. So I have to take it kind of easy.

So far, all I am using to do the inquiry is ROX, Rxvt, and Geany. That's about all I need - makes a quite powerful development environment.

User avatar
Crash
Posts: 453
Joined: Fri 09 Dec 2005, 06:34
Location: Melbourne, FL

#15 Post by Crash »

I found that the following code allows you to boot Puppy Linux several levels deep to the path specified by the psubdir parameter. I added a new flag, "psubok=TRUE", which tells init that you really, really think the subdirectory is OK to use and it contains all the Puppy files. If psubok is not set to "TRUE", the original code executes intact. Here is the code:

Code: Select all

 [ $psubok ] && PSUBOK=$psubok #All puppy files in PSUBDIR. ex: TRUE
 if [ "$PSUBOK" == "TRUE" ]; then
 FND_INITRDGZ="`find /mnt/data/$PSUBDIR -maxdepth 1 -mount -type f -name initrd.gz | grep -v ' ' | sed -e 's%^/mnt/data%%g' | tr '\n' ' '`"
 #v3.01 '*' means zero or more extra characters. this is for custom naming...
 FND_PUPXXXSFS="`find /mnt/data/$PSUBDIR -maxdepth 1 -mount -type f -name pup_${PUPPYVERSION}*.sfs | grep -v ' ' | sed -e 's%^/mnt/data%%g' | tr '\n' ' '`"
 FND_ZDRVSFS="`find /mnt/data/$PSUBDIR -maxdepth 1 -mount -type f -name zdrv_${PUPPYVERSION}.sfs | grep -v ' ' | sed -e 's%^/mnt/data%%g' | tr '\n' ' '`"
 FND_PUPSAVE2FS="`find /mnt/data/$PSUBDIR -maxdepth 1 -mount -type f -name pup_save*.[23]fs | grep -v ' ' | sed -e 's%^/mnt/data%%g' | tr '\n' ' '`"
 else
 FND_INITRDGZ="`find /mnt/data -maxdepth 2 -mount -type f -name initrd.gz | grep -v ' ' | sed -e 's%^/mnt/data%%g' | tr '\n' ' '`"
 #v3.01 '*' means zero or more extra characters. this is for custom naming...
 FND_PUPXXXSFS="`find /mnt/data -maxdepth 2 -mount -type f -name pup_${PUPPYVERSION}*.sfs | grep -v ' ' | sed -e 's%^/mnt/data%%g' | tr '\n' ' '`"
 FND_ZDRVSFS="`find /mnt/data -maxdepth 2 -mount -type f -name zdrv_${PUPPYVERSION}.sfs | grep -v ' ' | sed -e 's%^/mnt/data%%g' | tr '\n' ' '`"
 FND_PUPSAVE2FS="`find /mnt/data -maxdepth 2 -mount -type f -name pup_save*.[23]fs | grep -v ' ' | sed -e 's%^/mnt/data%%g' | tr '\n' ' '`"
 fi
Essentially, all that is changed is the $PSUBDIR parameter being appended to the "find" directory path, and the maxdepth being set to 1 instead of 2. This forces find to only search in the PSUBDIR directory.

I didn't modify the search for pupswap.swp since I don't know enough about it to know where people commonly locate it. It could just as easily be included inside the modified code.

I haven't any idea what the MULTIFOLDER search does, so I didn't touch it either.

I am using linld to boot Puppy from DOS in a FAT file system. The code I use is as follows:

Contents of boot script:

Code: Select all

LINLD.COM image=D:\linux\puppy\p412\vmlinuz initrd=D:\linux\puppy\p412\initrd.gz cl=@D:\PUPPY.LIN
Contents of puppy.lin file:

Code: Select all

root=/dev/ram0
pmedia=idehd
acpi=on
psubok=TRUE
psubdir=linux/puppy/p412
This is a great tool for learning. I am now much more familiar with some basic shell features such as the do loop, if statement, the find utility, and regular expressions. I gain as much out of this type of exercise as the utility it may provide to others.

/// Edited Jan 18

Small change to code to reflect ideas discussed later in post.

///
Attachments
init.gz
Modified init file from Puppy V4.12 initrd.gz
(16.79 KiB) Downloaded 396 times
Last edited by Crash on Sun 18 Jan 2009, 05:04, edited 2 times in total.

Toxic
Posts: 9
Joined: Sun 14 Dec 2008, 23:34

#16 Post by Toxic »

PSUBOK is not necessary since concatenation of string and empty parameter will give source string as result, so you can use find /mnt/data/$PSUBDIR without conditional statements. It will be find /mnt/data/ if $PSUBDIR is not provided/defined.

User avatar
Crash
Posts: 453
Joined: Fri 09 Dec 2005, 06:34
Location: Melbourne, FL

#17 Post by Crash »

The psubdir parameter with the original code is useful if you have several pup_save files in different subdirectories but only one copy of the pup_xxx.sfs file. That way you can selectively boot into different customized versions without needing extra copies of the operating system itself. I don't know if I am saying this quite right, but the original code serves a slightly different purpose.

The " && [ "$PSUBDIR" != ""] " part in the second line is probably not necessary since the new code should work as you say if the psubdir parameter is null. I just didn't see a need to execute the new code if the user intended the operating system to be located at the root level.

Anyway, like I said, this is more of a learning exercise for me, but any new ideas that come out are great. I hope that whoever decides the approach for this aspect of the Kernel in the future simply take the ideas discussed in this post into account.

There is another really nice thing I learned in this exercise. You can insert intermediate debug code and save the results in a file of your choice in "/tmp". After bootup, the file shows up in "/initrd/tmp". It is really useful both to debug your own code and to understand the intent of the original code. For example, one of my debug files contains intermediate results of data like this:

LESSPARTS=sda1|ntfs sda2|vfat sda3|ntfs
PSUBOK=TRUE
PUPPYFILES=sda1 ntfs
sda2 vfat /linux/puppy/p412/initrd.gz /linux/puppy/p412/pup_412.sfs /linux/puppy/p412/pup_save.2fs
sda3 ntfs

It really helped me understand how the process works.

Toxic
Posts: 9
Joined: Sun 14 Dec 2008, 23:34

#18 Post by Toxic »

Again, no need for [ "$PSUBDIR" != ""]. You can use [ -n "$PSUBDIR" ] or simply [ "$PSUBDIR" ].

User avatar
Crash
Posts: 453
Joined: Fri 09 Dec 2005, 06:34
Location: Melbourne, FL

#19 Post by Crash »

True, there are shorter ways of writing the expression. I'm still used to making things look like 'c' code :).

I actually took it out completely (see edit on page 1 of the thread). There is an advantage to be able to execute the new code when the psubdir isn't specified. With the psubok flag "TRUE", it boots right into Puppy at the root, and uses the pup_save file at the root. With the psubok flag not true, the Kernel searches for all your subdirectories and lists your choices of save files to use. This is more versatile than the first version I posted.

vg1
Posts: 142
Joined: Sun 02 Dec 2007, 18:56

#20 Post by vg1 »

This is excellent development. Something I, and I suspect many, have been waiting for a long time. Perhaps it deserves its own thread, say 'init-development' or similar. And in a different section, perhaps cutting edge? I'm sure this will be interesting to many, but may easily be missed here.

I have quite a few pyppy versions and other distros scattered all over my hd, all frugal installs [except one full - ubuntu, but I rarely use it]. It's all rather untidy with files scattered all over.
With puppy2 I was able to keep versions inside subdirs [with system .sfs on root] so that was ok. With p3 & p4 the number of directories increased inevitably, because I could not keep them two levels deep. Now I can.

The attached init works fine with p412, I suppose the code can be added back to earlier p4 versions, probably even p3. I will tackle that next.

However, one thing I have also been trying for a long time is still eluding me. Crash, in your previous post you say '... have several pup_save files in different subdirectories but only one copy of the pup_xxx.sfs file. That way you can selectively boot into different customized versions without needing extra copies of the operating system itself'. How can you do that with your code? What would be the setup and grub entry to use? I tried a few combinations, but no luck.

Dougal had suceeded precisely that in p214R, and it remains the only version to enable that completely. It lets you specify a save file to use [not necessarily in a separate subdir] and will boot straight into that, even with many other save_files side by side in the same dir. If one is not specified, THEN it presents all the save_files from that directory for your choice. This is exactly what's needed. No need to keep different save_files in dedicated directories, as long as they are named differently. So for p214R you can have eg. pup_save-214R-jwm.2fs, -icewm.2fs, -bb.2fs, -lxde.2fs, -kde.2fs etc. All coexisting in the same folder, and all from grub with a dedicated menu.lst entry with the appropriate 'PUPSAVE='. Unfortunately, his search code only works on p214 and its versions [and p215 & its versions, with some tweaks].

In this respect p3 and p4 search function is 'stupid': it presents a choice of save_files even if the one you wish to use has been specified, or searches the whole hd for puppy files even with a specified directory.

regards, vg

Post Reply