live mounting of sfs is it possible ?

Under development: PCMCIA, wireless, etc.
Message
Author
magerlab
Posts: 739
Joined: Sun 08 Jul 2007, 20:08

live mounting of sfs is it possible ?

#1 Post by magerlab »

is it possible to use a slax approach in puppy?
i mean to install sfs into a booted system and use it without reboot like it's done in slax?

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#2 Post by disciple »

You can just click on it to mount it, so it depends whether your particular sfs needs to be unioned to use it properly.
Puppy 1.x could union .sfs files on the fly (It was supposed to be unsafe to ununion them on the fly, but I did it all the time without ill effect), but it is supposed to be either impossible or unsafe in 2.x on. I think this was because unionfs is less stable with a 2.6 kernel, but I can't remember for sure - it could be because of the changes in Puppy's architecture.
Do you know if Slax unions an sfs, or just mounts it? I suspect it must be possible, and I seem to remember seeing something on the forum recently about unioning on the fly again... but it certainly isn't done commonly.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
jcoder24
Posts: 604
Joined: Fri 06 May 2005, 12:33
Location: Barbados

#3 Post by jcoder24 »

It depends on if you have additional loop devices available and the type of union you use. I find it works best with aufs rather than unionfs. Also while adding works ok, removal presents issues.

I use the following script to add additional loops while puppy is running. After running the script I would then run ldconfig and fixmenus.

Usage: scriptname` file.sfs

Code: Select all

#/bin/sh
#jcoder24 20080412
#last mod 20080424

#--
# Initialise variables
#--
#if [ `echo $1 | grep -ic /' ] 
#grep -ice "^./" 

sfs_path=`dirname $1` #may need to check

sfs_file="$sfs_path/`basename $1`"
sfs_module=`echo $1 | gawk '{ gsub(".*/","",$0); gsub(".sfs","",$0); print $1 }'`
#sfs_module=`echo $1 | gawk '{ gsub(".sfs","",$0); print $1 }'`
#sfs_module=`echo $1 | gawk '{ gsub("[^a-zA-Z0-9].*","",$0); print $1 }'`
logger "sfs_handler: >> module: $sfs_module file: $sfs_file path: $sfs_path <<"

#--
# Check args and requirements
#--

#- If wrong number of args or file not found, show usage and quit
if [ $# -ne 1 ] ; then
	echo "Usage: `basename $0` file.sfs"
	exit 1
else
	if [ `echo $1 | grep -ice ".\.sfs$"` -ne 1 ]; then
		echo "Usage: `basename $0` file.sfs"
		exit 1
	elif [ ! -f $1 ]; then
		echo "File not found!"
		exit 1
	fi
fi

#- This only works with aufs, so if it's not loaded advise accordinly and quit
if [ `lsmod | grep -ic aufs` -eq 0 ]; then
	echo "`basename $0` requires aufs. To correct boot puppy with layerfs=aufs"
	exit 1
fi

#--
# Search for a free loop device and determine if file mounted already
#--
free_loop=""

for aloop in `ls /dev/loop* | grep -ve loop0 -e loop1 -e loop2`
#for aloop in `ls /dev/loop* | grep -ve loop0 -e loop1 -e loop2 -e loop6 -e loop7 -e loop4 -e loop5`
do
	sfs_loaded=`losetup-FULL $aloop 2>/dev/null`
	status=$?
	echo $aloop err_code $status

	if [ $status -gt 0 ]; then
#		echo $aloop "FREE"
		[ -z "$free_loop" ] && free_loop=$aloop
	fi

	if [ `echo $sfs_loaded | grep -ic $sfs_module` -gt 0 ]; then
		echo "A module with this name is already loaded! Aborting..."
		Xdialog --title "sfs_handler" --msgbox "`basename $sfs_module` is already loaded.\n"  6 0
		exit 0
	fi

	last_loop=`echo $aloop | cut -c10-`
done
logger "sfs_handler: Free $free_loop Last $last_loop"


#--
# If no free loops found, create a new one
#--
if  [ -z "$free_loop" ]; then
	logger "sfs_handler: No loop devices available."
	Xdialog --title "sfs_handler" --msgbox "Failed! No loop devices available.\n"  6 0
	exit

	next_loop=`expr $last_loop + 1`
	free_loop="/dev/loop$next_loop"
##	echo "Last $last_loop Next $next_loop"
##	mknod /dev/loop$next_loop b 7 $next_loop
#	echo "Creating new loop $next_loop..."
#	[ ! -b /dev/loop$next_loop ] && "mknod /dev/loop$next_loop" b 7 $next_loop
#	chown root:root /dev/loop$next_loop
#	chmod 666 /dev/loop$next_loop
fi


#--
# Load Module
#--

#- If module on cd then advise user
for cd in `mount | grep iso9660 | cut -d " " -f3`
do
	if [ `echo $sfs_path | grep -ic $cd` -gt 0 ]; then
		msg="sfs is located on a cdrom, do you still want to load it"
		Xdialog --title "sfs_handler" --yesno "$msg"  6 0
        	[ $? -ne 0 ] && exit 0
		break
	fi
done
echo "Lets go!"

status=0
[ ! -d "/mnt/$sfs_module" ] && mkdir /mnt/$sfs_module
echo "Mounting $sfs_module..."

losetup-FULL $free_loop $sfs_file
status=$?
if [ $status -eq 0 ]; then
logger "sfs_handler: losetup $status"

	mount $free_loop /mnt/$sfs_module
	status=$?
	if [ $status -eq 0 ]; then
logger "sfs_handler: mount $status"

		mount -o remount,append:/mnt/$sfs_module=ro /
		status=$?
		if [ $status -eq 0 ]; then
logger "sfs_handler: aufs $status"

			Xdialog --title "sfs_handler" --msgbox "Success! `basename $sfs_module` module loaded.\n"  6 0
		else
			Xdialog --title "sfs_handler" --msgbox "Failed! `basename $sfs_module` module not loaded.\n"  6 0
		fi
	else
		umount $free_loop
		losetup-FULL -d $free_loop
		Xdialog --title "sfs_handler" --msgbox "Failed! Could not mount $sfs_module.\n"  6 0
	fi
else
	Xdialog --title "sfs_handler" --msgbox "Failed! Could not setup $free_loop for $sfs_module.\n"  6 0
fi

magerlab
Posts: 739
Joined: Sun 08 Jul 2007, 20:08

#4 Post by magerlab »

thank you for the answers !
how to use that script? can i associate it to sfs files?

User avatar
WhoDo
Posts: 4428
Joined: Wed 12 Jul 2006, 01:58
Location: Lake Macquarie NSW Australia

#5 Post by WhoDo »

jcoder24 wrote:It depends on if you have additional loop devices available and the type of union you use. I find it works best with aufs rather than unionfs. Also while adding works ok, removal presents issues.
Since the Puppy 4.xx series uses aufs by default, does this mean that we could include hot mounting of sfs files as a feature from now on? :shock:

What issues does removal present? Can these be overcome?

This would be a "killer" feature to add to Puppy 4.2 Deepthought. It just requires a little deep thought is all. :wink:
[i]Actions speak louder than words ... and they usually work when words don't![/i]
SIP:whodo@proxy01.sipphone.com; whodo@realsip.com

User avatar
J-Bob
Posts: 282
Joined: Sun 10 Feb 2008, 00:58
Location: Canada
Contact:

#6 Post by J-Bob »

WhoDo wrote:
jcoder24 wrote:It depends on if you have additional loop devices available and the type of union you use. I find it works best with aufs rather than unionfs. Also while adding works ok, removal presents issues.
Since the Puppy 4.xx series uses aufs by default, does this mean that we could include hot mounting of sfs files as a feature from now on? :shock:

What issues does removal present? Can these be overcome?

This would be a "killer" feature to add to Puppy 4.2 Deepthought. It just requires a little deep thought is all. :wink:
My thoughts exactly.

Having this in 4.2 could lead to to it getting an even better advantage over the competition.

- J-Bob

User avatar
jcoder24
Posts: 604
Joined: Fri 06 May 2005, 12:33
Location: Barbados

#7 Post by jcoder24 »

magerlab wrote:how to use that script? can i associate it to sfs files?
You can
- associate it with sfs files.
- drag and drop sfs files onto it
- run it from a console eg "sfs_handler myfile.sfs"

If I remember correctly removal caused the system to become unresponsive forcing the need to reboot. However, I haven't tested this recently with the newer version of aufs in puppy 4.

If removal still causes problems you could just leave out the 'feature'. In that case you could inform users that manually loaded sfs files remain loaded until reboot.

Another thing that will have to be accounted for in the above script include loading sfs files from cds and usb drives. Another useful thing would be to have a pinstall.sh for the sfs file that would run fixmenus, ldconfig (make libraries available without rebooting), restart xwindows, make fonts available, etc.

There may be other things to consider which the pros like MU would be able to highlight like the layering of the files esp when dealing with libraries.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#8 Post by technosaurus »

add a little fixmenus and some restartwm in and you have a winning recipe

also if this goes we should make a little pet2sfs script as well (I may have seen one already - something like.... pet2tgz ..., tar ..., dir2sfs ....)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
jrb
Posts: 1536
Joined: Tue 11 Dec 2007, 19:56
Location: Smithers, BC, Canada

Mount and use .sfs files from the OpenWith menu

#9 Post by jrb »

I have taken jcoder24's script and added "fixmenus" and "restartwm" to lines 123 and 124. I then placed it in a file called "load_sfs" along with a symlink in /root/.config/rox.sourceforge.net/OpenWith to /usr/sbin/load_sfs and made a .pet out of it.

Install the .pet and you can right click on an .sfs file and OpenWith load_sfs.

The .sfs will be installed and menu entries created (if they were in the .sfs).

Tested with OpenOffice-3.sfs in puppy412 and puppy420a3. I OpenedWith load_sfs, went to the document menu and opened OpenOfficeWriter, typed a test document and saved. When I rebooted OpenOffice and menu entries were gone. Too Cool! :D

Edit: Latest version 23feb09 only restarts jwm (or icewm), not X, so does not shut down open programs.
Last edited by jrb on Mon 23 Feb 2009, 18:02, edited 2 times in total.

reckrhodes
Posts: 116
Joined: Wed 30 May 2007, 08:15

#10 Post by reckrhodes »

I tried this wonderful pet. Yes, it works fine. Devx_410.sfs and OpenOffice-3.0.sfs function greatly.

How many sfs's can I load without rebooting my computer?

User avatar
jrb
Posts: 1536
Joined: Tue 11 Dec 2007, 19:56
Location: Smithers, BC, Canada

#11 Post by jrb »

Hi, reckrhodes,
I've only tried two at a time up to this point but I'm planning on experimenting with puppy-4.1.2-barebones from:
http://www.murga-linux.com/puppy/viewtopic.php?t=36727 and adding everything, browser, office suite, games, wine, etc. with .sfs files

If you do plan on using a lot of .sfs files I would definitely keep your pup_save.2fs backed up just to be safe.

User avatar
jrb
Posts: 1536
Joined: Tue 11 Dec 2007, 19:56
Location: Smithers, BC, Canada

#12 Post by jrb »

Exciting stuff,
I just rebuilt the puppy420a4 .iso to include Opera10.sfs, OpenOffice3.0.sfs and devx412.sfs, and then burned it to cd.

I am currently typing in Opera10, have already typed and saved a short letter in OpenOfficeWriter and loaded devx412.sfs. if I knew how to compile I would do that too. All from cd loaded with load_sfs.

I booted pfix=ram and have not yet created a pup_save file. Interestingly my puppy space monitor shows no memory being used (OK it's actually .01Gb). Does anyone know where the contents of mounted .sfs files gets stored (or not)?

User avatar
WhoDo
Posts: 4428
Joined: Wed 12 Jul 2006, 01:58
Location: Lake Macquarie NSW Australia

#13 Post by WhoDo »

jrb wrote:Does anyone know where the contents of mounted .sfs files gets stored (or not)?
/initrd/pup_roX where X is the assignment number for each sfs file mounted.
[i]Actions speak louder than words ... and they usually work when words don't![/i]
SIP:whodo@proxy01.sipphone.com; whodo@realsip.com

User avatar
jrb
Posts: 1536
Joined: Tue 11 Dec 2007, 19:56
Location: Smithers, BC, Canada

#14 Post by jrb »

Thanks WhoDo,
I'm just wondering why they don't seem to take up any memory?

reckrhodes
Posts: 116
Joined: Wed 30 May 2007, 08:15

#15 Post by reckrhodes »

Good job jrb.

I tested again this wonderful pet, this time sfs files are located from 3 levels of subdirectories and it works fine. (My partition is vfat)

Both jcoder24 and you should be applauded for a job well done.

Hope this will be included to the Puppy 4.2 final and Woof.

User avatar
jcoder24
Posts: 604
Joined: Fri 06 May 2005, 12:33
Location: Barbados

#16 Post by jcoder24 »

WhoDo wrote:
jrb wrote:Does anyone know where the contents of mounted .sfs files gets stored (or not)?
/initrd/pup_roX where X is the assignment number for each sfs file mounted.
Actually, "load_sfs" as you call it creates a sub-director in /mnt and mounts the sfs there. Eg load_sfs opera10.sfs will create /mnt/opera10 and mount/load the file there.

Since the script does not facilitate removal, the new folders remain after rebooting (provided you didn't boot with pfix=ram). We can create the folders as hidden folder instead.

~~~

If were are going to putting this in an official release, we should clean up the code. ie remove some of the logger and echo statements and some of the comments. I'll see what I can do in the next few days.

If you don't mind can you document your changes in the script and add the date of change? Also update the "#last mod" date.

User avatar
jrb
Posts: 1536
Joined: Tue 11 Dec 2007, 19:56
Location: Smithers, BC, Canada

#17 Post by jrb »

Hi jcoder,
Actually I've done very little coding. Mostly, as here, I've followed someone else's code and made changes to suit my needs. It wasn't until after I had posted that I realized I should have marked my changes. Just got excited I guess.

I've actually built two .pets from your code. One for puppy412 as posted here and one for puppy412a4 which is posted in the bug fix thread. When I realized the first one wouldn't work on the ROX right-clicks I rebuilt it. I also packaged the second one with ldconfig. I'm not sure its necessary but felt it wouldn't hurt.

As for removing comments I think you should definitely keep "A module with this name is already loaded!" and "Failed". The "sfs is located on a cdrom" seems unnecessary as it seems to mount and run modules from cd really well.

This code works really well. I'm totally impressed. I think it will become a major feature of puppy.

Here are my (minor) changes for both .pets starting at line 120. Do you want me to repost the .pets with the documentation?

Load_sfs

Code: Select all

      mount -o remount,append:/mnt/$sfs_module=ro / 
      status=$? 
      if [ $status -eq 0 ]; then
   #fixmenus & restartwm added by jrb 6feb09
      fixmenus
      restartwm 
   #"Success" message removed by jrb 6feb09
      else 
         Xdialog --title "sfs_handler" --msgbox "Failed! `basename $sfs_module` module not loaded.\n"  6 0 
      fi 
   else 
      umount $free_loop 
      losetup-FULL -d $free_loop 
      Xdialog --title "sfs_handler" --msgbox "Failed! Could not mount $sfs_module.\n"  6 0 
   fi 
else 
   Xdialog --title "sfs_handler" --msgbox "Failed! Could not setup $free_loop for $sfs_module.\n"  6 0 
fi
load_sfs-420

Code: Select all

      mount -o remount,append:/mnt/$sfs_module=ro / 
      status=$? 
      if [ $status -eq 0 ]; then
    #ldconfig, fixmenus, restartwm added by jrb 8feb09  
      ldconfig
      fixmenus
      restartwm 
    #"Succes" menu deleted by jrb 8feb09
      else 
         Xdialog --title "sfs_handler" --msgbox "Failed! `basename $sfs_module` module not loaded.\n"  6 0 
      fi 
   else 
      umount $free_loop 
      losetup-FULL -d $free_loop 
      Xdialog --title "sfs_handler" --msgbox "Failed! Could not mount $sfs_module.\n"  6 0 
   fi 
else 
   Xdialog --title "sfs_handler" --msgbox "Failed! Could not setup $free_loop for $sfs_module.\n"  6 0 
fi

User avatar
jrb
Posts: 1536
Joined: Tue 11 Dec 2007, 19:56
Location: Smithers, BC, Canada

#18 Post by jrb »

I have added a version of load_sfs packaged with ldconfig. This will load any lib files which your .sfs may contain. Also updated documentation in original load_sfs.pet

magerlab
Posts: 739
Joined: Sun 08 Jul 2007, 20:08

#19 Post by magerlab »

is it possible not to restart X after mounting sfs with that script?

User avatar
jrb
Posts: 1536
Joined: Tue 11 Dec 2007, 19:56
Location: Smithers, BC, Canada

#20 Post by jrb »

magerlab,
The short answer is yes. The long answer is I already set it up that way for puppy4.2 and just hadn't gotten around to doing it for 412. But I will post it above immediately after I finish this post.

I should mention that if you edit /root/.xinitrc and add fixmenus just before the end it will clear your menus of any remnants from previously loaded .sfs's

Code: Select all

#v3.95 support fbpanel tray/taskbar...
#only launch tray for w.m. without inbuilt tray...
if [ "$CURRENTWM" != "jwm" -a "$CURRENTWM" != "icewm" ];then
 [ -f /usr/bin/fbpanel ] && fbpanel &
 [ -f /usr/bin/lxpanel ] && lxpanel &
fi

#to refresh menus on boot - jrb 17feb09
fixmenus

#exec $CURRENTWM
#v2.11 GuestToo suggested this improvement...
which $CURRENTWM && exec $CURRENTWM
[ -x $CURRENTWM ] && exec $CURRENTWM
exec jwm

###END###

Post Reply