Need script for USB -> full install

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

Need script for USB -> full install

#1 Post by starhawk »

I have a certain system with a certain situation that requires me to boot it with a full install. It's an unusual situation... I'm using this getup to test driver code until it works; I've got some nice people helping me. Trouble is, I need files to persist after a system hang, which means frugal is right out.

The "hard drive" in that system is an SD card in an SD-to-IDE adapter, the idea being that it's easy to install to an SD card. Trouble is I need that full install, and right now I don't have another system that (a) will boot Puppy and (b) has an internal IDE header. Swapping the drive around is a real PITA as well, and since it's a 64gb SDXC card in there I don't think I want to use 'dd' to image it (although, that idea did just now occur to me).

I know this configuration is known-bad in terms of drive longevity -- but it's what I need and I'm only using it in this one case.

01micko wrote me a quick-n-dirty script, but it doesn't work, and he doesn't (unfortunately) have the time to fix it for me -- I can't code, even bash script stuff... not yet :oops:

I've got my local guru dude to analyze it; he says that there are a couple issues with the script as it is. One, it looks for the three files zdrv, adrv, ydrv, and if it doesn't get all three, it doesn't run a particular loop that copies the initrd stuff over. Two, it hits a point where it's looking at certain pre-WoofCE things and it bombs out there.

I don't know enough to fix it. I tried, by commenting out the adrv/ydrv stuff and the legacy code (I'm using X-Tahr 1b3 here, which is essentially TahrPup 602 + XFCE, so it's WoofCE and doesn't need the legacy crap, I *think*) -- but there's still something wrong because when I go to install Grub4Dos it doesn't see a Pup there.

...can someone help? I've attached the original code (not my alterations, since they don't work) to this post, as a tarball.
Attachments
installer.sh.tar.gz
(2.39 KiB) Downloaded 176 times

Scooby
Posts: 599
Joined: Sat 03 Mar 2012, 09:04

Re: Script Help Needed -- Full-To-USB Install -- Details Inside

#2 Post by Scooby »

starhawk wrote: I've got my local guru dude to analyze it; he says that there are a couple
issues with the script as it is. One, it looks for the three files zdrv, adrv,
ydrv, and if it doesn't get all three, it doesn't run a particular loop that
copies the initrd stuff over.
I guess this is the snippet you ask about?

Code: Select all

for drv in zdrv* adrv* ydrv*;do
 echo "extracting $drv"
 [ -f $SRCPATH/"${drv}" ] && cp -af "$SRCPATH"/"${drv}" "$DESTMNTPT"/
 [ -f /"${drv}" ] && cp -af /"${drv}" "$DESTMNTPT"/

 if [ -f "$DESTMNTPT"/"${drv}" ];then #w482
   mkdir -p "$DESTMNTPT"/data
   mount -t squashfs -o loop "$DESTMNTPT"/"${drv}" "$DESTMNTPT"/data
   cp -a -f --remove-destination "$DESTMNTPT"/data/* "$DESTMNTPT"/
   
   sync
   umount "$DESTMNTPT"/data
   rm -f "$DESTMNTPT"/"${drv}"
 fi
done
I tried it with a contrived example here and it seems to work.
Test executed with adrv, ydrv but no zdrv.
The for-loop is entered, does nothing except echo'ing "extracting zdrv*"
for zdrv but processes adrv and ydrv
extracting zdrv*
extracting adrv7783457834
entering if [ -f /tmp...
extracting ydrv1
entering if [ -f /tmp...
My guess is that this code is not where your problem lies?


starhawk wrote: Two, it hits a point where it's looking at certain pre-WoofCE things and it bombs out there.
What message do you get when it bombs or describe more detailed what happens please?

DO you get this message from code?

Code: Select all

	fatal "On legacy, this only works if the source is the same as the running environment"

I don't know whats changed with woofce so cannot really help you there


Anyway a good tip is "When in doubt, echo out" that is put in some echo
statements to get more knowledge of what happens

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#3 Post by starhawk »

I'm using it with X-Tahr 1b3, which has zdrv but no adrv/ydrv.

I had forgotten, but there are actually three bomb-outs.

One, rm reports that it cannot remove /mnt/sdxx/data -- where sdxx is the drive and partition in question.
Two, I get the "fatal" error that you describe.
Three, I believe it is not copying initrd.gz over -- that's what the adrv/ydrv/zdrv mess leads to according to my guru friend.

Scooby
Posts: 599
Joined: Sat 03 Mar 2012, 09:04

#4 Post by Scooby »

starhawk wrote: Three, I believe it is not copying initrd.gz over -- that's what the adrv/ydrv/zdrv mess leads to according to my guru friend.
The code should still work. For loop is entered and processed for zdrv
that is if script made sure to change directory to where zdrv is supposed to be.
starhawk wrote: One, rm reports that it cannot remove /mnt/sdxx/data -- where sdxx is the drive and partition in question.
This is interesting and originates around that for-loop with zdrv,adrv and ydrv

Probably because something is still mounted on data directory but why it's so I would need more information.

Do get any error messages regarding mount or umount?
starhawk wrote: Two, I get the "fatal" error that you describe.
Where is initrd directory placed after woofce if not in /lib/modules/"$KERNELVER"/initrd ??

Also it is here initrd stuff is copied not in for loop with zdv,adrv,ydrv


I am sorry but like 01micko I don't have much time or I would setup
test environment with X-Tahr

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#5 Post by starhawk »

No mount/umount errors.

Not sure about initrd -- I'll have to check. I'll get back to you in a little bit...

Scooby
Posts: 599
Joined: Sat 03 Mar 2012, 09:04

#6 Post by Scooby »

further thinking on
One, rm reports that it cannot remove /mnt/sdxx/data -- where sdxx is the drive and partition in question.
You probably get ?
"rm: cannot remove '/mnt/sdxx/data': No such file or directory
now that makes sense, then I believe when for-loop is run we are
not in the correct workingdir.

You could possibly try changing that code snippet to below
This is a quick and dirty hack of course but I believe it would work
changes marked with bold

--------------------------------------8<-------------------------------

Withdrew code, since it won't work, need more info about location of zdrv

---------------------------------------------------------------------->8----------



Anyway could you tell me where zdrv is located on X-tahr please?
Last edited by Scooby on Tue 15 Mar 2016, 21:13, edited 1 time in total.

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#7 Post by starhawk »

Changes made. Have not yet re-run.

I'm not sure if the initrd.gz is copied -- if it is, it's not in /lib/modules/"$KERNELVER"/*. The only thing in there is a folder named 'misc' which contains ndiswrapper.ko...

Scooby
Posts: 599
Joined: Sat 03 Mar 2012, 09:04

#8 Post by Scooby »

Dont rerun, I dont think will work, sorry

We need to investigate more, but that for-loop is not sane

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#9 Post by starhawk »

I will wait for you, then :)

Scooby
Posts: 599
Joined: Sat 03 Mar 2012, 09:04

#10 Post by Scooby »

Well you need to help me with location of zdrv

Where is it?

Code looks for it in / and $SRCPATH

could it be both?

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#11 Post by starhawk »

I don't think so. Although X-Tahr 1b3 is what I run every day, so it's both the target OS to install, and the environment within which the installer script is running -- my OS partition is at /mnt/sda3. (Geographically it's the first partition on disk, but it's numbered as the third... very, very long story.)

I do admit that most of my installs are of the manual frugal type, though, so if /mnt/sda3 can map to /, then it's possible the thing's seeing double.

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#12 Post by starhawk »

One other odd phenomenon that I just rediscovered with that script.

It seems to put a lock or read-only effect on / -- I can't print to my network printer (the only printer I have right now) -- I can't save files to /root -- files I open report as locked -- and Gparted reports no devices available to peruse.

That's more than a little strange... what's doing it? I have no idea.

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#13 Post by starhawk »

*looks around, sees nobody*

...oh, well...

partsman
Posts: 363
Joined: Wed 06 Jun 2012, 19:00
Location: OHIO,USA

#14 Post by partsman »

Hi starhawk :D
I am going out on a limb here but maybe try manually full install as so :
1. copy initrd to usb.

2. copy vmlinux to usb.

now for the tricky part :D

3. using a live cd or whatever mount the main sfs and copy the contents to the usb.

4. copy the zdrive sfs to the usb

5. open the zdrive sfs with uextract and it will merge the contents from the zdrive to what is already there from the main sfs

now with that said you may have to convert the zdrive sfs to a folder if uextract has issues with extracting the sfs :wink:

6. install grub4dos :D

Hope it helps or at least gives you an idea ! :wink:
[color=red]Anyone can build a fast processor. The trick is to build a fast system. (Seymour Cray)[/color] :wink:

partsman
Posts: 363
Joined: Wed 06 Jun 2012, 19:00
Location: OHIO,USA

#15 Post by partsman »

More random thoughts :lol:

Lazy puppy made a script called SARA-ScriptBox :wink:
If I remember right this would accomplish the a usb full install :D
BUT ! There may be other modifications in there with it !!

Maybe you could look at the code an reverse engineer it to do only the full install :wink:

Here is SARA-ScriptBox :
http://murga-linux.com/puppy/viewtopic.php?t=91422
[color=red]Anyone can build a fast processor. The trick is to build a fast system. (Seymour Cray)[/color] :wink:

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#16 Post by starhawk »

@partsman -- Thanks, I've tried the former (manual full install) and it does not work.

A quick look at SARA B reveals no instructions on how to use... am I missing something? This one is not a problem I'd like to solve by pressing random buttons to see what they do... ;)

partsman
Posts: 363
Joined: Wed 06 Jun 2012, 19:00
Location: OHIO,USA

#17 Post by partsman »

Hi starhawk :D

Let me ask so we are on the same page here !
Is the issue where merging the main sfs and the zdrive the part that is the issue ?

If so maybe something like this :
Code:
ls A | while read FILE; do
cat A/"$FILE" B/"$FILE" >> C/"$FILE"
done
[color=red]Anyone can build a fast processor. The trick is to build a fast system. (Seymour Cray)[/color] :wink:

Scooby
Posts: 599
Joined: Sat 03 Mar 2012, 09:04

#18 Post by Scooby »


OBS! If you want any hope of this script to work you have to locate
a replacement for /lib/modules/"$KERNELVER"/initrd


In script you try exchanging the for-loop with

Code: Select all

shopt -s nullglob

for drv in /zdrv* /adrv* /ydrv* "$SRCPATH"/zdrv* "$SRCPATH"/adrv* "$SRCPATH"/ydrv*;do
 echo "extracting $drv"
 [ -f "${drv}" ] && echo cp -af "${drv}" "$DESTMNTPT"/  
 
 DRV_FILENAME="${drv##*/}"					
 
 if [ -f "$DESTMNTPT"/"${DRV_FILENAME}" ];then #w482
   echo "Processing $DRV_FILENAME"
   mkdir -p "$DESTMNTPT"/data
   mount -t squashfs -o loop "$DESTMNTPT"/"${DRV_FILENAME}" "$DESTMNTPT"/data
   cp -a -f --remove-destination "$DESTMNTPT"/data/* "$DESTMNTPT"/
   
   sync
   umount "$DESTMNTPT"/data
   rm -f "$DESTMNTPT"/"${DRV_FILENAME}"
 fi
done
rm -r "$DESTMNTPT"/data
That for loop will look in / and $SRCPATH after zdrv, adrv, ydrv
and process them

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#19 Post by starhawk »

Did as instructed, Terminal input/output copied below. In the meantime, I've verified that the initrd does not actually get copied or extracted at all.

Worth noting, I now don't get the FS errors described before... nice :)

Code: Select all

root# ./installer.sh
I assume you have formatted the drive to ext(2,3,4)
I'm not babysitting so if it isn't do it now!
Is it? (y or n + [Enter/Return])
y
OK, rememeber.. I'm not responsible here...
Proceeding...

Insert your drive and mount it.
Then tell me the target drive partition (eg: sdc1, sdd1 etc)
GET IT RIGHT!
what is the drive partition?
sdb1
Seems sane..
Ok, /mnt/sdb1 exists. Good.

Now we need some source files
either mount a CD/DVD or an ISO file
THEN, tell me the mount point path
EXAMPLE: /mnt/sr0 or /mnt/+mnt+sda5+iso+tahr64-6.0.3.9.iso
An easy way to do that is enter the mounted folder and type 'pwd' in a terminal
Type the source mount point path.
/mnt/+root+Downloads+X-tahr-1b3.iso/
Seems sane..
Press y + [Enter/Return] to continue
y

Installing... just wait a while.
copying bin
copying dev
copying etc
copying lib
copying mnt
copying opt
copying proc
copying root
copying sbin
copying tmp
copying usr
copying var
extracting /mnt/+root+Downloads+X-tahr-1b3.iso//zdrv_tahr_6.0.2.sfs
cp -af /mnt/+root+Downloads+X-tahr-1b3.iso//zdrv_tahr_6.0.2.sfs /mnt/sdb1/
rm: cannot remove ‘/mnt/sdb1/data’: No such file or directory
On legacy, this only works if the source is the same as the running environment
root# 

Scooby
Posts: 599
Joined: Sat 03 Mar 2012, 09:04

#20 Post by Scooby »

Yeah I am sorry I added an echo when I tested so
this should be correct version

Code: Select all

shopt -s nullglob

for drv in /zdrv* /adrv* /ydrv* "$SRCPATH"/zdrv* "$SRCPATH"/adrv* "$SRCPATH"/ydrv*;do
 echo "extracting $drv"
 [ -f "${drv}" ] && cp -af "${drv}" "$DESTMNTPT"/ 
 
 DRV_FILENAME="${drv##*/}"               
 
 if [ -f "$DESTMNTPT"/"${DRV_FILENAME}" ];then #w482
   echo "Processing $DRV_FILENAME"
   mkdir -p "$DESTMNTPT"/data
   mount -t squashfs -o loop "$DESTMNTPT"/"${DRV_FILENAME}" "$DESTMNTPT"/data
   cp -a -f --remove-destination "$DESTMNTPT"/data/* "$DESTMNTPT"/
   
   sync
   umount "$DESTMNTPT"/data
   rm -f "$DESTMNTPT"/"${DRV_FILENAME}"
 fi
done
rm -r "$DESTMNTPT"/data 



This is one part

and then this is another
I've verified that the initrd does not actually get copied or extracted at all.
code

Code: Select all

# LEGACY - pre woof-CE
KERNELVER=`uname -r`
if [ -d /lib/modules/"$KERNELVER"/initrd ];then
	#note, important to not have 'initrd' folder in full hd installation, messes up rc.sysinit.
	cp -af /lib/modules/"$KERNELVER/initrd"/* "$DESTMNTPT"/lib/modules/$KERNELVER/
	depmod -b "$DESTMNTPT"
else
	fatal "On legacy, this only works if the source is the same as the running environment"
Code looks for /lib/modules/"$KERNELVER"/initrd and does not
find it at that path
Does the directory initrd exist at all?

I offer help with code you have to check environment that is
at what path the interesting directories are

You could try

Code: Select all

find / -type d -name initrd
to find all directories named initrd
Last edited by Scooby on Thu 17 Mar 2016, 20:57, edited 1 time in total.

Post Reply