A Non-Layered Puppy with Save

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

A Non-Layered Puppy with Save

#1 Post by rufwoof »

I boot using grub4dos, so my menu.lst looks something like

Code: Select all

title Puppy 533t 
root (hd0,2)
kernel /pup533t/vmlinuz
initrd /pup533t/initrd.lzo
I've created a pup that has no layered file system - I've just dumped the entire puppy sfs into initrd i.e. I created a directory below where initrd.gz is located, changed directory into that directory and ran

Code: Select all

zcat ../initrd.gz | cpio -id
to extract the initrd.gz contents. I then opened (left clicked) puppy sfs and selected all and dragged to copy all files/directories to that new directory,selecting merge contents. I then deleted all of the pup_xx directories (pup_rw etc.).

I then edited the init file to remove everything and just leave

Code: Select all

#!/bin/bash
exec /sbin/init
I then repacked the initrd using

Code: Select all

find | cpio -o -H newc | lzop -c1 >../initrd.lzo
That boots up and runs fine. There is however no save options available as its all running in ram. I'm quite happy with that as I don't use savefile anyway, however it is nice to have some persistence. I'm content to have just everything under /root being saved and to accommodate that I replicated the /root directory onto my hard disk (I called it root-hdd) and changed the contents of initd.lzo : renamed /root /root-ram and created a symbolic link

Code: Select all

ln -s /root-ram /root
and again repackaged the initrd.lzo (find | cpio -o -H newc | lzop -c1 >../initrd.lzo)

Now when I boot it boots to the normal ram only mode, however I can run the command

Code: Select all

rm /root;ln /mnt/sda3/root-hdd /root;restartwm
and after the restartwm completes my root directory is now the one on the hard disk. The drive does of course need to be mounted before executing that command line (left click (in my case) the sda3 drive to mount it).

When using the HDD based root directory any changes made persist across reboots. If I'm about to run something that I don't want changes to root being made persistent then I can switch back to the ram based root using

Code: Select all

rm /root;ln /root-ram /root;restartwm
and then maybe switch back to the hard disk based root again later....etc.

An extension of this idea might be to symbolic link other things that you might want to persist across reboots. For instance you might remaster a version that perhaps had /etc/hosts symbolic linked into a file stored under root

You can't (easily) load sfs's under such a pup, there's nothing however to stop you extracting sfs programs to be stored under the HDD root directory, for instance I have Libre Office and Firefox both stored under that HDD root. So boot to a initial spartan pup (ram based), switch root to the HDD based one and after the second or two for that switch root to run you then have Libre, Firefox and all docs etc available (HDD based root).

In my case I'm not using zram, so the main puppy (large initrd) is stored uncompressed in ram (faster to run). Around 9 months ago however Barry was playing around with something similar but using zram http://bkhome.org/news/?viewDetailed=00074

My pup includes a PXE server installation so that other household PC's (Windows) can boot puppy via their network card. You do however have to set those PC's BIOS to enable that option, typically by disabling secure boot. Leaving secure boot turned off means that should their system crash due to hard disk failure/content error, they have the option to press F12 as the PC is first booting up and then select the net boot option to boot puppy using my PXE server (which of course has to be activated and the firewall disabled). The way I've set my remaster up is that a PC that boots via PXE can remaster its own initrd.lzo (and vmlinuz) files, so that in turn that PC can become a PXE server for other PC's to boot from - all running in ram with no hdd's being touched. And where each of those PC's have their own HDD based copy of /root they can each do their own thing (choice of programs, data storage etc).
Attachments
root-hdd.jpg
(84.75 KiB) Downloaded 603 times
nl.jpg
(27.67 KiB) Downloaded 612 times

stemsee

#2 Post by stemsee »

I like this possibility realized. Innovative.

Have you a script to automate this process?

Have you posted your remaster script anywhere? I would like to have a look at it.

regards
stemsee

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#3 Post by rufwoof »

No for both Stemsee. The remaster is however available in the initrd located at

https://drive.google.com/folderview?id= ... sp=sharing

In the /usr/sbin/REMASTER folder

Basically the standard remaster script extended to prompt less and rather than asking for a CD keeps copies of the CD files locally (within the pup sfs). As they're relatively small files it seems a bit silly not to keep local copies - and holding them integrally reduces the risk of mix-up's. I prefer that than having to find a actual CD or mount a ISO before running remaster. If you remaster using no compression i.e. something like a mksquashfs parameters of -noX -noI -noD -noF, then the remaster copy runs through very quickly, typically around 30 seconds for a average/modest sized puppy.

A problem with the non-layered version is that you can't load sfs's - at least no less differently to that of a full install i.e. is possible, but in effect distils down to being just a straight copy of the sfs content to the / directory - which for a compressed sfs (usual) and big, could easily exhaust memory space. OK provided you allocate a big swap file, but then that in effect becomes disk bound (potentially somewhat like loading the sfs into swap space). That needn't be a bad thing as I believe swapping in/out to swap file can be single instruction i.e. relatively quick/more efficient than copying to/from conventional disk space.

I have a USB HDD that I format all 300GB as a linux swap file and sometimes switch that on to supplement the 1.5GB actual ram this PC has (same one I was using with your auto-kernel compile the other day). It looks to me that the way linux works is that it combines actual+swap and allocates half to front end (memory) and half to back end (swap), so with just over 300GB total you end up with 150GB front end (apparent free memory). More than enough to store uncompressed copies of sfs contents, but still leaves the problem of being relatively slow to copy (load) the sfs.

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#4 Post by rufwoof »

I like just having root as read/write and the rest read only as that provides a sense of security that the main core can't be tampered with (virus/trojan). For relatively infrequent changes to the 'others' I just remaster (around a minute or less time to do so). Having the option to dynamically switch between root being read only or read/write is also nice.

Conceptually you could copy /etc /lib ...etc under root and set the actual /etc /lib ... as sym links to those copies .... in which case saving /root becomes more or less the same as a fully installed puppy, but using frugal style boot up. In such case full install would be the better choice. All a question of where you want to draw the line as to what is read/write and what is read only. For my part I like playing around and trying things out (other pet's/sfs's) which is more likely to screw the system up and having mostly (or all) read only means that a reboot resets things back to fully working/as-before. With full installs (all read/write) you have to be more careful not to change something that might take a while to become apparent.

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#5 Post by rufwoof »

Hmm! interestingly ....

Mounting a sfs in what is in effect a full install to memory by copying the sfs content to / can instead be achieved by using copy recursive use sym links (i.e. cp -rs)

I mounted a sfs - office.sfs in my case (located in /mnt/sda3) by

Code: Select all

mkdir /mnt/office
mount -t squashfs /mnt/sda3/office.sfs /mnt/office
and then

Code: Select all

cd /
cp -rs /mnt/office/* .
that left existing duplicate copies of the same file(s) intact under root, but created symbolic links to all of the other files contained in the office sfs.

Providing the sfs file remains intact/mounted you can run the applications contained within as normal, yet the 'sfs load' flashes by in a second or two as nothing is actually being actually copied and instead is just being symbolic linked to in memory (to the actual office.sfs content mounted in this case under /mnt/office).

If there were a method to delete symbolic links where the target was missing, then conceptually you also umount the sfs by unmounting /mnt/office and then running a recursive remove dead sym links under / (root). I suspect that's both possible and likely quick (being a memory based operation).

Observation. I recreated what I posted earlier - but this time its not picking up the drivers/modules/firmware i.e. network and firewall are both disabled. Obviously something I did the first time around isn't reflected in those notes (maybe I need to leave the pup_xx files present for the first run ??? I need to investigate that further).

stemsee

#6 Post by stemsee »

You should check out the drag and drop chroot sfs script by Fredx181 on DebianDog thread.
http://murga-linux.com/puppy/viewtopic. ... start=4170
Have you tried building the initrd into te kernel?

Also my own StemseeS-Remastering-Suite contains needed cd bootfiles for fatdog64 DebianDog and regular puppies are catered for with a generic set of files. You might appreciate my sfs-direct-remastering script, which does not require working directories, neither script requiresa a cd or iso.

I would like to incorporate some of your ideas/experiments as options, with your permission.

regards stemsee[/url]

stemsee

#7 Post by stemsee »

The squashfile in that initrd can't open on my system!

I would appreciate it if you could just post the remaster script here, save me some hassle, thanks.

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#8 Post by rufwoof »

I don't have a script yet for the non-layered approach. This is my current remaster scripts for layered fs pup, but where no CD is required and pup sfs is merged into initrd

I originally copied the standard remasterpup2 (for slacko 5.3.3) and edited it to a new version I called remasterpup3 as per the following

Code: Select all

#!/bin/sh
#simple script to remaster the puppy live-cd.
#(c) Copyright 2006 Barry Kauler, www.puppyos.com
#2007 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html)
#BK 9 oct 2007: updated for puppy v3.01.
#RE 9 apr 2008: v3.99 copy active post-install scripts
#v4.02 /lib/modules/firmware.dep.<kern>,DOTconfig-K<kern> moved to /etc/modules. ...um no mods this script.
#v411 update what gets copied from /root and /etc.
#v412 /etc/DISTRO_SPECS, renamed pup_xxx.sfs, pup_save.2fs etc.
#w001 pup files renamed to woof-555.sfs, woofsave.2fs (or similar).
#w018 april 2009: Woof-related fixes, new standardised package database format.
#w460 zdrv has new name format, ex zu500269.sfs.
# 22jun09 by Masaki Shinomiya <shino@pos.to> bugfix in cd drive selection
# 23jun09 I18N
# 27jun09 copy all *.msg and *.16 from Live CD
# 01jul09 needed space calculation
# 02jul09 I18N bugfix to burn CD
# 08jul09 remove kernel modules from initrd
# 08jul09 loop mounted iso file usable
# 7aug09 grub4dos support
#w482 shinobar: exclude /lib/modules/${KERNELVER}/initrd.
#v423 bugfix.
# 2oct09 v430JPRC shinobar: make ZDRVSFS
#v431 bugfixes.
#v431JP add application ID on iso image.(removed)
#v431JP removed app ID code, permitions of sfs files, forground collor of rxvt
#v431JP mkisofs with Joliet option, volume id, what copied from cd, remove slmodems
#v431JP error message for full install
#091212 weird bug, no processes but when run this, x restarts...
# 28dec09 remove /modules/${KERNELVER}/modules.*
#100117 save user-modified rox globicons file.
# 20jan10 Puppy v4.x(before woof) backward compatibility
#100913 simplified puppy filenames. see variables in /etc/DISTRO_SPECS.
#100916 no longer have DISTRO_DEVXSFS in /etc/DISTRO_SPECS.(it was only there briefly)
#101020 no longer have /etc/modprobe.conf.
#101107 bug fix from zygo.
#110505 support sudo for non-root user.
#110722 tweak sort.
#110808 PANZERKOPF: bug fix. 110822 reverted.
#120323 replace 'xmessage' with 'pupmessage'.
#120329 Xdialog bug --yesno supposed to "yes" "No" buttons, but they are "OK" "Cancel".
#120512 01micko: support xz compression.
#120605 rerwin: omit /dev/snd content, /dev/.udev subdirectory and modem daemons from new master (because daemons reinstalled from firmware if needed).
#120606 rerwin: support users' replacement of stripped /root & /etc with complete directories (for "boot disk"). 
#120607 rerwin: Remove indicators/files for integrated user-installed packages.
#120628 shinobar: no change id-string for reuse
#120721 revert 'wildcards' option (from 120605); improve /dev/snd file exclusion; exclude /usr/share/icons/hicolor/icon-theme.cache (shinobar).
#121021 rerwin: revert 120605 modem daemon removals (because daemons no longer copied from firmware directory).
#130203 change probedisk2 to probedisk.
#130216 partial support f2fs.
#130222 convert internationalization from "technosaurus method" to gettext method.
#130222 virtual-CD detection was broken.
#130223 various fixes. note, also fixed /usr/sbin/filemnt. now can retain files between remasters.
#130301 o/p of "losetup" (BB), shows all in use, but "losetup-FULL -a" needs param, also o/p format different.
#130302 L18L: moved m_09 m_10 m_11 top and made another use of it.
#130304 cp -n not supported, use -u
#130306 gettext translation fixed, line 354. 130307 again.
#130308 npierce: filter out wrong CDs from choices offered to user; remove CD drive from VIRTUALCD list.
#130527 /etc/.XLOADED has been moved to /root, refer /usr/bin/xwin.

[ "`whoami`" != "root" ] && exec sudo -A ${0} ${@} #110505

export TEXTDOMAIN=remasterpup2x #NOTE: rename to avoid clash with 'remasterpup2.mo' used by previous i18n method.
export OUTPUT_CHARSET=UTF-8
. gettext.sh

Yes_lbl="$(gettext 'Yes')"
No_lbl="$(gettext 'No')"
m_01="$(gettext 'Puppy simple CD remaster')" #window title.
m_02="$(gettext 'ERROR')"
m_07="$(gettext 'currently mounted')"
m_08="$(gettext 'not mounted')"
m_09="$(gettext 'Filesystem')" #130302
m_10="$(gettext 'Size')" #130302
m_11="$(gettext 'Free')" #130302

choice_cdd () {
 #copy files off live-cd.... w018 use probedisk2...
 #DRIVESFND="`probedisk2 2>&1`"
 #IDEDRVSFND="`test-eide 2>&1 | grep "cdrom"`"
 SELECTIONS="`probedisk 2>&1 | grep '^/dev/' | grep "|optical|" | cut -f 1,3 -d "|" | tr " " "_" | tr "|" " " | tr '$' "_"`"
 #zSELECTIONS="`echo "$SELECTIONS" | tr '\n' ' '`" #v431 bugfix. # shinobar: need not for this code
 SELECTIONS="$SELECTIONS $VIRTUALCD"
 if [ "$(echo "$SELECTIONS"|tr -d ' ')" = "" ]; then
  m_14_2="$(gettext 'NO CD/DVD drives found.')"
  Xdialog --wrap --left --title "$m_01: $m_02" --msgbox "$m_14_2
$MSG" 0 80
  exit
 fi
 if [ "$1" = "filter" ];then #130308 Filter out devices with a missing file.
  FILT_SELECTIONS=""
  i="0"
  for ASELECTION in $SELECTIONS
  do
   if [ "$((i++&1))" -eq "0"  ];then
    BLKDEV="$ASELECTION"
   else
    DEVNAME="$ASELECTION"
    MNTPNT="`mount | grep "$BLKDEV" | tr -s " " | cut -f 3 -d " "`"
    [ -z "$MNTPNT" -o -f "$MNTPNT/initrd.gz" -a -f "$MNTPNT/$PUPPYSFS" ] && FILT_SELECTIONS="$FILT_SELECTIONS $BLKDEV $DEVNAME"
   fi
  done
  SELECTIONS="$FILT_SELECTIONS"
  if [ -z "$SELECTIONS" ];then
   m_14_3="$(gettext 'Puppy live-CD or virtual CD was not found.')
$(eval_gettext "(No CD or .iso file has both 'initrd.gz' and '${PUPPYSFS}'.)")"  
   Xdialog --wrap --left  --title "$m_01: $m_02" --msgbox "$m_14_3" 0 0
   exit
  fi
 fi #130308 end of filter 
 m_14_1="$(gettext 'Choose the CD/DVD drive...')"
 DIALOG="Xdialog --wrap --left --title \"$m_01\" --stdout --menubox \"$MSG\n\n$m_14_1\" 0 56 4 $SELECTIONS 2> /dev/null"
 BURNERDRV=""
 RESULT=$(eval $DIALOG) #w018	# 22jun09
 [ $? -ne 0 ] && exit
 BURNERDRV=$RESULT
 [ "$BURNERDRV" = "" ] && exit
 BURNERDRV="`echo -n "$BURNERDRV" | cut -f 3 -d '/'`"
}

#LANG=C #faster, plus Xdialog happier.
KERNELVER="`uname -r`"

#120512 01micko: set compression
COMP=""
mksquashfs -help &>/tmp/mk #refuses to grep from stdout
grep 'lzo' /tmp/mk &>/dev/null
[ "$?" = "0" ] && COMP="-comp lzo"
ARCH="`uname -m`"
[ "$(uname -m|grep ^i)" ] && ARCH="`uname -m|cut -c3,4`"
case "$ARCH" in
86)AOPT="-Xcompression-level 1" ;;
*)AOPT="" ;; #todo add other arches
esac
rm /tmp/mk
COPTIONS=""${COMP}" "${AOPT}""
# Rufwoof : Set overide so as to use no compression at all
#COPTIONS="-noI -noD -noF -noX"
#end set compression

#variables created at bootup by /initrd/usr/sbin/init...
. /etc/rc.d/PUPSTATE
[ "$PUP_LAYER" = "" ] && PUP_LAYER="/pup_ro2"

. /etc/DISTRO_SPECS
if [ ! "$DISTRO_IDSTRING" ];then #101107
  #need some stuff in here if want to support older puppies. maybe also more fixes needed further down.
 pupmessage -bg red -title "RemasterPup" -center "Sorry, your Puppy is too old for this script"
 exit
else
 PUPPYSFS="$DISTRO_PUPPYSFS" #ex: puppy.sfs
 ZDRVSFS="$DISTRO_ZDRVSFS"   #ex: zdrv.sfs
 #DEVXSFS="$DISTRO_DEVXSFS"   #ex: devx.sfs
 SFSBASE="`basename $PUPPYSFS .sfs`" #ex: puppy
fi

#100913 generate a new id-string...
IDDATE="`date +%y%m%d%H%M%S`" #12 bytes, ex: 100911153319
IDPREFIX="`echo -n "$DISTRO_FILE_PREFIX" | cut -b 1`"
#vDISTRO_VERSION="`echo -n "$DISTRO_VERSION" | cut -b 1-3`" #in case it ever gets bigger than 3 chars.
#IDSTRING="${IDPREFIX}${vDISTRO_VERSION}${IDDATE}"
#...needs to be appended to vmlinuz, puppy.sfs, zdrv.sfs and devx.sfs
#110422 increase size of idstring to 32 bytes...
IDSTRING="${IDPREFIX}${IDDATE}ZZZZ${DISTRO_VERSION}"
#...ZZZZ reserved space for future use.
LEN1=`echo -n "$IDSTRING" | wc -c`
LEN2=`expr 32 - $LEN1`
EXTX=''
while [ $LEN2 -gt 0 ];do
 LEN2=`expr $LEN2 - 1`
 EXTX="${EXTX}X"
done
IDSTRING="${IDSTRING}${EXTX}" #32 bytes ex: w110423092024ZZZZ5.1.2XXXXXXXXXX

PPATTERN="/initrd${PUP_LAYER}"
if [ "`mount | grep "$PPATTERN"`" = "" ];then
 #no puppy.sfs file mounted on pup_ro2, probably h.d. install...
 m_03="$(eval_gettext 'This program requires a ${PUPPYSFS} file mounted on /initrd${PUP_LAYER}.')
$(gettext 'Which is not the case here, probably because this is a full hard drive installation?')
$(gettext 'Whatever, boot Puppy from live-CD and then you will be able to use this script.')

$(eval_gettext 'Note, I have not tried it, but if you setup the situation of ${PUPPYSFS} mounted on directory /initrd${PUP_LAYER}, that will be acceptable for this program.')
$(gettext 'You will also need a current live-CD, as the program gets files off it.')
$(gettext 'Anyone want to try it?')

$(gettext "Click 'Ok' button to quit...")" 
 #pupdialog --title "m_01: m_02"  --msgbox "$m_03" 0 0
 Xdialog --wrap --left --title "m_01: m_02"  --msgbox "$m_03" 0 80
 exit
fi

SAVEPART="$PDEV1" #from PUPSTATE.
CDR="/dev/$SAVEPART"

#choose where to create isolinux-builds/ directory...
m_05="$(gettext 'Welcome! This little program takes a snapshot of your current system creates a new initrd boot file.')

$(eval_gettext "Note, you need to have edited the content of /root/INITRD_LOCATION to point to your frugal boot folder")

$(eval_gettext "Note also, if you have an 'underdog Linux' mounted, that too will get combined into the \${PUPPYSFS} file, so beware, it could get big!")

$(gettext 'Click OK button to continue (or close window to quit)...')"
#pupdialog --title "$m_01" --msgbox "$m_05" 0 0
Xdialog --wrap --left --title "$m_01" --msgbox "$m_05" 0 80

[ $? -ne 0 ] && exit

#calc size needed...
m_06="$(gettext 'Calculating needed working space.')
$(gettext 'Please wait, this may take awhile...')"
Xdialog --wrap --left  --title "$m_01" --no-buttons --ignore-eof  --infobox "$m_06" 0 0 0 &
XPID=$!
SIZEOPT=0
SIZEBIN=`du -sk /bin | cut -f 1`
SIZESBIN=`du -sk /sbin | cut -f 1`
SIZELIB=`du -sk /lib | cut -f 1`
SIZEUSR=`du -sk /usr | cut -f 1`
SIZEOPT=0	# 01jul09
[ -d /opt ] && SIZEOPT=`du -sk /opt | cut -f 1`
sync
#kill $XPID
#SIZETOTALK=`expr $SIZEBIN + $SIZESBIN + $SIZELIB + $SIZEUSR + $SIZEOPT`
#SIZETOTALM=`expr $SIZETOTALK \/ 1024`
SIZETOTALK=`LANG=C dc $SIZEBIN $SIZESBIN + $SIZELIB + $SIZEUSR + $SIZEOPT + p`
SIZETOTALM=`LANG=C dc $SIZETOTALK 1024 \/ p| cut -d'.' -f1`	# 01jul09
[ "$SIZETOTALM" ] || SIZETOTALM=1
#echo "SIZETOTALM=$SIZETOTALM"
#estimate a compressed size...
SIZENEEDEDM=`expr $SIZETOTALM \/ 3`
SIZESLACKM=`expr $SIZENEEDEDM \/ 3` #guess
SIZENEEDEDM=`expr $SIZENEEDEDM + $SIZESLACKM`
SIZENEEDEDM=`expr $SIZENEEDEDM + 25` #space for vmlinuz, initrd.gz, zdrv, etc
#echo "SIZENEEDEDM=$SIZENEEDEDM"
#now choose working partition... v431 add ext4...  130216 add f2fs...
PARTSLIST="`probepart -m 2> /dev/null | grep '^/dev/' | grep -E 'f2fs|ext2|ext3|ext4|reiserfs|msdos|vfat|ntfs' | cut -f 1-3 -d '|'`"

 echo -n "" > /tmp/schoices.txt
 echo "$PARTSLIST" |
 while read APART
 do
  [ "$APART" = "" ] && continue #v3.01 preaution
  MNTSTATUS="($m_07)" #"currently mounted"
  ATAG="`echo -n "$APART" | cut -f 1 -d '|' | cut -f 3 -d '/'`"
  ASIZE="`echo -n "$APART" | cut -f 3 -d '|'`"
  AFS="`echo -n "$APART" | cut -f 2 -d '|'`"
  AFPATTERN="^/dev/$ATAG " #v3.01
  AFREE="`df -m | grep "$AFPATTERN" | tr -s " " | cut -f 4 -d " "`"
  FLAG_RO='no' #v431
  if [ ! "$AFREE" ];then
   MNTSTATUS="($m_08)" #"not mounted"
   mkdir -p /mnt/$ATAG
   mount -t $AFS /dev/$ATAG /mnt/$ATAG > /dev/null 2>&1
   if [ $? -eq 0 ];then
    if [ "$ATAG" = "fd0" ];then
     FFREE=`df -k | grep "$AFPATTERN" | tr -s " " | cut -f 4 -d " "`
     AFREE="`LANG=C dc $FFREE 1024 \/ p`"
    else
     AFREE="`df -m | grep "$AFPATTERN" | tr -s " " | cut -f 4 -d " "`"
    fi
    [ "`mount | grep "$AFPATTERN" | grep ' (rw'`" = "" ] && FLAG_RO='yes' #v431 make sure writable.
    umount /dev/$ATAG
   else #v431
    continue
   fi
  else
   [ "`mount | grep "$AFPATTERN" | grep ' (rw'`" = "" ] && FLAG_RO='yes' #v431 make sure writable.
  fi
  [ "$FLAG_RO" = "yes" ] && continue #v431
  #[ "$AFS" ] && echo "${ATAG} \"Filesystem: $AFS  Size: ${ASIZE}M  Free: ${AFREE}M ${MNTSTATUS}\" \\" >> /tmp/schoices.txt #v3.01 added precaution.
  [ "$AFS" ] && echo "${ATAG} \"${m_09}: $AFS  ${m_10}: ${ASIZE}M  ${m_11}: ${AFREE}M ${MNTSTATUS}\" \\" >> /tmp/schoices.txt #v3.01 added precaution. #130302 L18L
 done
 SCHOICES="`cat /tmp/schoices.txt`"

#add tmpfs ramdisk choice...
SIZETMPFSM="`df -m | grep '^tmpfs' | grep '/initrd/pup_rw' | tr -s " " | cut -f 4 -d " "`"
TMPFSMSG=''

if [ "$SIZETMPFSM" != "" ];then
 TOTALTMPFSM="`df -m | grep '^tmpfs' | grep '/initrd/pup_rw' | tr -s " " | cut -f 2 -d " "`"
 if [ "$SCHOICES" = "" ];then #v3.01
  SCHOICES="ramdisk \"$m_09: tmpfs  $m_10: ${TOTALTMPFSM}M  $m_11: ${SIZETMPFSM}M ($m_07)\" \\"
 else
  SCHOICES="$SCHOICES
ramdisk \"$m_09: tmpfs  $m_10: ${TOTALTMPFSM}M  $m_11: ${SIZETMPFSM}M ($m_07)\" \\"
 fi
 m_12="$(gettext 'Note 2: you can use the tmpfs ramdisk, which is in RAM, if it has enough space.')"
 TMPFSMSG="$m_12
 "
fi

[ "$SCHOICES" = "" ] && exit #precaution.
m_13="$(gettext 'A working area is required in which to create the new live-CD iso file.')
$(eval_gettext 'Here are the available partitions. You must choose one that has at least ${SIZENEEDEDM}M free space on it.') 

$(eval_gettext 'If the partition that you would like to use has less than ${SIZENEEDEDM}M free space on it, you will need to quit this script and delete some files.')

$(gettext 'Note 1: you can use a usb drive, but it needs to have been plugged in before running this script, so that it will get detected.')
${TMPFSMSG}
$(gettext 'Highlight desired choice then click OK button...')"
 echo '#!/bin/sh' > /tmp/savedlg
 echo -n "Xdialog --wrap --left --stdout --title \"$m_01\" --menubox \"$m_13\" 0 80 8 " >> /tmp/savedlg
 echo "$SCHOICES"  >> /tmp/savedlg
 echo ' > /tmp/tag.txt' >> /tmp/savedlg
 chmod 755 /tmp/savedlg

kill $XPID
/tmp/savedlg
[ $? -ne 0 ] && exit #130223
WKGPART="`cat /tmp/tag.txt`"
echo "WKGPART=$WKGPART"
[ "$WKGPART" = "" ] && exit
#[ "$WKGPART" = "ramdisk" ] && WKGPART="tmpfs"

#now get the files off it...
#firstly need working place to write to...
[ "$WKGPART" = "ramdisk" ] && WKGMNTPT="/"
WPATTERN="/dev/$WKGPART "
[ "$WKGMNTPT" = "" ] && WKGMNTPT="`mount | grep "$WPATTERN" | tr -s " " | cut -f 3 -d " "`"
#[ "$WKGMNTPT" = "/initrd/pup_rw" ] && WKGMNTPT="/"
if [ "$WKGMNTPT" = "" ];then
 PPATTERN="^$WKGPART "
 WKGFS="`echo "$SCHOICES" | grep "$PPATTERN" | cut -f 2 -d ':' | cut -f 2 -d " "`"
 [ "$WKGFS" = "msdos" ] && WKGFS="vfat"
 mkdir -p /mnt/$WKGPART
 mount -t $WKGFS /dev/$WKGPART /mnt/$WKGPART
 [ $? -ne 0 ] && exit #precaution.
 WKGMNTPT="/mnt/$WKGPART"
fi

echo $WKGMNTPT >/tmp/WKGPART

[ "$WKGMNTPT" = "/" ] && WKGMNTPT=""

# reuse if sfs file already exists
NEW="yes"

SFSPATH=$(ls -1 $WKGMNTPT/puppylivecdbuild/$PUPPYSFS 2>/dev/null)
if [ "$SFSPATH" != "" -a $(echo "$SFSPATH" | wc -l) -eq 1 ]; then
 m_35="$(eval_gettext '${SFSPATH} found.')
$(gettext 'Do you want to reuse it without any change?')
$(gettext "If uncertain, click the 'No' button")"
 Xdialog --wrap --left --title "$m_01" --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$m_35" 0 0 && NEW="no"
fi

SFSPATH=""

if [ "$NEW" = "yes" ]; then  ###### long skip if, cleating new sfs

  #130223 i think should wipe contents of $WKGMNTPT/puppylivecdbuild?
  if [ -d $WKGMNTPT/puppylivecdbuild ];then
    [ -f $WKGMNTPT/puppylivecdbuild/$PUPPYSFS ] && rm -f $WKGMNTPT/puppylivecdbuild/$PUPPYSFS
    [ -f $WKGMNTPT/puppylivecdbuild/$ZDRVSFS ] && rm -f $WKGMNTPT/puppylivecdbuild/$ZDRVSFS
 m_41="$(eval_gettext 'Directory ${WKGMNTPT}/puppylivecdbuild already exists.')

$(gettext "Normally, this would be created fresh, empty. However, it exists from a previous execution of 'remasterpup2' script (this program), with files in it. You may choose to leave these files in-place, for the current remaster. If uncertain, click the 'Erase' button.")

$(gettext 'Note, if you choose to retain the files: The next operation is this script will will read files from a CD, however they will not over-write existing files. Therefore, any customised files will be retained.')

$(gettext "WARNING: If the files in 'puppylivecdbuild' are for a different version of Puppy, click the 'Erase' button.")
$(gettext "Again, warning, if at all uncertain, click the 'Erase' button.")

$(gettext "Click 'Keep' button to retain the files...")
$(gettext "Click 'Erase' button to delete the files...")"
    lbl_41="$(gettext 'Keep')"
    lbl_42="$(gettext 'Erase')"
    Xdialog --wrap --left --title "$m_01" --ok-label "$lbl_41" --cancel-label "$lbl_42" --yesno "$m_41" 0 80
    [ $? -ne 0 ] && rm -rf $WKGMNTPT/puppylivecdbuild
  fi


  #now get the files off it...
  m_17="$(eval_gettext 'Copying CD files to ${WKGMNTPT}/puppylivecdbuild/, please wait...')"
  Xdialog --wrap --left  --title "$m_01" --no-buttons --ignore-eof   --infobox "$m_17" 0 0 0 &
  XPID=$!
  #rm -rf $WKGMNTPT/puppylivecdbuild 2>/dev/null #precaution. 130223 see above.
  mkdir -p $WKGMNTPT/puppylivecdbuild
  #now copy the files... # v431JP HTM, ICO, INF
     sync
#     for F in vmlinuz initrd.gz ${ZDRVSFS} grldr menu.lst '*.xpm' isolinux.bin isolinux.cfg '*.msg' '*.16' '*.HTM*' '*.ICO' '*.INF'
#     do
      #130223 -n means do not override an existing file... 130304 hmmm, -n not supported, use -u ...
#	cp -a -u $CDMNTPT/$F $WKGMNTPT/puppylivecdbuild/ 2> /dev/null
cp -apvr /usr/sbin/REMASTER/ISO-FILES/* $WKGMNTPT/puppylivecdbuild/. 2> /dev/null
	sync
#     done
  #umount /dev/$BURNERDRV 2> /dev/null
  #rox -D $CDMNTPT #130223
  kill $XPID

  #fi #end "BIGIF2"

  # Rufwoof : we always keep modules in with puppy
  #m_16_1="$(eval_gettext 'Do you like to make ${ZDRVSFS}, the separate driver file?')"
  #Xdialog --wrap --left  --title "$m_01" --default-no --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$m_16_1" 0 0
  #[ $? -eq 0 ] && MKZDRV="yes" || MKZDRV=""
  #[ $? -eq 255 ] && exit #130223

  m_18="$(eval_gettext 'Creating the ${PUPPYSFS} file in ${WKGMNTPT}/puppylivecdbuild/.')
$(gettext 'This can take quite a while, so please wait....')"
  Xdialog --wrap --left  --title "$m_01" --no-buttons --ignore-eof   --infobox "$m_18" 0 0 0 &
  XPID=$!

  #create new puppy.sfs file...
  squash() {
	echo $0 $@
	rxvt -bg orange -fg black -title "$m_01" -geometry 80x6 -e mksquashfs $@ 2> /dev/null
  }
  DIRHOME=""
  [ -d /home ] && DIRHOME="/home"
  [ -d /sys ] && DIRSYS="/sys"
  [ -d /lost+found ] && DIRLOST="/lost+found"
  rm -f ${WKGMNTPT}/puppylivecdbuild/$PUPPYSFS 2> /dev/null
  sync
  #note, /puppy.sfs is not normally there, i relocated it to a separate tmpfs,
  #however have not yet done that for multisession-cd/dvd (PUPMODE=77).
  #note, /home could be in underdog linux...

  # modules copied from initrd
  ANOTHER_REMOVE="/lib/modules/$KERNELVER/initrd /lib/modules/*/modules.*"	# 28dec09 modules.*
  if [ "$MKZDRV" = "yes" ]; then
    rm -f $WKGMNTPT/puppylivecdbuild/$ZDRVSFS 2> /dev/null
    mksquashfs /lib $WKGMNTPT/puppylivecdbuild/$ZDRVSFS -keep-as-directory -e /lib/[^m]* $ANOTHER_REMOVE
    ANOTHER_REMOVE="/lib/modules"
  fi
  #120605 Omit certain /dev subdir content and modem components loaded from firmware tarballs...
  [ -d /dev/snd ] && [ "`ls /dev/snd`" != "" ] && DIRDEVSNDFILES="/dev/snd/*" #120721
  [ -d /dev/.udev ] && DIRDEVUDEV="/dev/.udev"
  #121021 modem daemons now left in place.
  [ -f /usr/share/icons/hicolor/icon-theme.cache ] && ICONCACHE=/usr/share/icons/hicolor/icon-theme.cache #120721
  TOPPLCDB=''
  [ -e /puppylivecdbuild ] && TOPPLCDB='/puppylivecdbuild'
  TOPPUPSFS=''
  [ -e /${PUPPYSFS} ] && TOPPUPSFS="/${PUPPYSFS}"
  # display terminal only for the first stage because it takes the most of time. 'squash' is a function, see above. 120512 $COPTIONS added...
  squash / $WKGMNTPT/puppylivecdbuild/$PUPPYSFS ${COPTIONS} -e /etc /proc /initrd /var /tmp /archive /mnt /root $TOPPLCDB $ANOTHER_REMOVE $DIRHOME $DIRSYS $DIRLOST $TOPPUPSFS $DIRDEVSNDFILES $DIRDEVUDEV $ICONCACHE  #120605 end #120721 avoid wildecards option, icon-theme.cache 121021
  sync

  #add pristine folders (out of current puppy.sfs)...
  mksquashfs /initrd${PUP_LAYER}/proc $WKGMNTPT/puppylivecdbuild/$PUPPYSFS -keep-as-directory
  sync
  mksquashfs /initrd${PUP_LAYER}/tmp $WKGMNTPT/puppylivecdbuild/$PUPPYSFS -keep-as-directory
  sync
  mksquashfs /initrd${PUP_LAYER}/mnt $WKGMNTPT/puppylivecdbuild/$PUPPYSFS -keep-as-directory
  sync

  #######START WORKING ON /root#######
  rm -rf /tmp/root 2> /dev/null

  ####################
  # Rufwoof
  #m_19="$(eval_gettext 'This program has created folder /tmp/root, which has everything that is now going to be added as /root in the ${PUPPYSFS} file.')
  #$(gettext "This is mostly 'pristine', as obviously you do not want all your cache files, temp files, email files, and other working/temporary files to be burnt onto the CD. However, if you are familiar with the workings of Puppy, you might like to take a look at /tmp/root right now, and possibly add anything that you want from /root (or remove something!)")
  #$(gettext '(if you think that this program has missed out something important that  should be burnt into /root on the CD, please let me know -- Barry Kauler)')
  #
  #$(eval_gettext "After examining /tmp/root, click 'Ok' to add /root in \${PUPPYSFS} file...")"
  #Xdialog --wrap --left --title "$m_01" --msgbox "$m_19" 0 80
  #
  #####################

  # Rufwoof

  cp -avr /root /tmp
  echo >/tmp/root/.packages/user-installed-packages # All loaded PET's will now be in core

  sync

  [ "`ls /tmp/root/.packages/*.files`" = "" ] && CLEARPKGLOG="yes" || CLEARPKGLOG="no" #120607 in case user copied entire /root to /tmp for boot disk.
  mksquashfs /tmp/root $WKGMNTPT/puppylivecdbuild/$PUPPYSFS -keep-as-directory
  sync
  rm -rf /tmp/root
  #######END WORKING ON /root#######

  #######START WORKING ON /etc#######
#  rm -rf /tmp/etc 2> /dev/null
  #do some work on /etc before add it to the .sfs...
#  cp -a /initrd${PUP_LAYER}/etc /tmp/etc #pristine /etc.
  #maybe this has been modified...
#  cp -af /etc/ld.so.conf /tmp/etc/

  #firmware tarballs may install these scripts... 100913 not good idea...
  #cp -af /etc/init.d/* /tmp/etc/init.d/   #3.99

  #.packages/ .files, copy any files installed to /etc...
  echo -n "" > /tmp/allpkgs.files
  for ONEPKG in `ls -1 /root/.packages/*.files 2>/dev/null | tr "\n" " "`
  do
   for ONEFILE in `cat $ONEPKG | grep '^/etc/' | tr "\n" " "`
   do
    if [ -d $ONEFILE ];then #w018
     mkdir -p /tmp$ONEFILE
    fi
    if [ -f $ONEFILE ];then #w018
     DIRNAME="`dirname $ONEFILE`"
     mkdir -p /tmp$DIRNAME
     cp -a -f $ONEFILE /tmp$DIRNAME/
    fi
   done
  done
  sync

  #100913 fix id-string variable...
  idPATTERN="s%^DISTRO_IDSTRING.*%DISTRO_IDSTRING='${IDSTRING}'%"
  sed -i -e "$idPATTERN" /tmp/etc/DISTRO_SPECS
  cp -f /tmp/etc/DISTRO_SPECS /tmp/DISTRO_SPECSupdated #keep this to put into initrd.gz.


  # Rufwoof - just duplicate /etc
  rm -rf /tmp/etc
  cp -avr /etc /tmp

  #120606 in case user just now replaced the /etc directory...
  sync
  #130527 .XLOADED moved to /root (see /usr/bin/xwin), change test...
  #if [ -f /tmp/etc/.XLOADED ];then #user replaced the /etc directory
  MODIFETC="$(find /tmp/etc/modules -mindepth 1 -maxdepth 1 -name 'firmware.dep.inst.*')"
  if [ "$MODIFETC" != "" ];then
   #rm -f /tmp/etc/.XLOADED
   rm -f /tmp/etc/modules/firmware.dep.inst.*
   touch /tmp/etc/personal_settings_popup_disabled
   touch /tmp/etc/personal_data_save_disabled
  fi
  [ -f /tmp/etc/.XLOADED ] && rm -f /tmp/etc/.XLOADED #130527 just in case old file still there.

  sync


  mksquashfs /tmp/etc $WKGMNTPT/puppylivecdbuild/$PUPPYSFS -keep-as-directory
  sync
  rm -rf /tmp/etc
  #######END WORKING ON /etc#######


  #######START WORKING ON /var#######
  rm -rf /tmp/var 2> /dev/null
  cp -a /initrd${PUP_LAYER}/var /tmp/var #pristine var

  #.packages/ .files, copy any files installed to /var...
  echo -n "" > /tmp/allpkgs.files
  for ONEPKG in `ls -1 /root/.packages/*.files 2>/dev/null | tr "\n" " "`
  do
   for ONEFILE in `cat $ONEPKG | grep '^/var/' | tr "\n" " "`
   do
    if [ -d $ONEFILE ];then #w018
     mkdir -p /tmp$ONEFILE
    fi
    if [ -f $ONEFILE ];then #w018
     DIRNAME="`dirname $ONEFILE`"
     mkdir -p /tmp$DIRNAME
     cp -a -f $ONEFILE /tmp$DIRNAME/
    fi
   done
  done
  sync
  [ "$CLEARPKGLOG" = "yes" ] && rm -f /tmp/var/log/packages/* #120607

  sync
  mksquashfs /tmp/var $WKGMNTPT/puppylivecdbuild/$PUPPYSFS -keep-as-directory
  sync
  rm -rf /tmp/var
  #######END WORKING ON /var#######
  chmod a+r $WKGMNTPT/puppylivecdbuild/* &>/dev/null
  chmod a-x $WKGMNTPT/puppylivecdbuild/*.sfs &>/dev/null
fi ###### end of long skip if, cleating new sfs

kill $XPID

if [ -f $WKGMNTPT/puppylivecdbuild/isolinux.cfg ]; then
 #edit isolinux.cfg...
 ISOLINUXCFG="`cat $WKGMNTPT/puppylivecdbuild/isolinux.cfg`"
 #small tweaks, like acpi=on, ide=nodma...
fi


BOOTPARM=""
[ -f $WKGMNTPT/puppylivecdbuild/grldr ] && BOOTPARM="-b grldr"
[ -f $WKGMNTPT/puppylivecdbuild/isolinux.bin ] && BOOTPARM="-b isolinux.bin -c boot.cat"
if [ "$BOOTPARM" = "" ]; then
 m_25_1="$(gettext 'No boot loaders found. You need isolinux.bin or grldr to make bootable CD.')
$(gettext "Click 'OK' to quit.")
$(eval_gettext '(leaving ${WKGMNTPT}/puppylivecdbuild/ files in existence)')"
 Xdialog --wrap --left  --title "$m_01" --msgbox "$m_25_1" 0 0
 exit
fi

if [ "$NEW" = "yes" ]; then	#120628: no change id-string for reuse
#100913 append id-string. doesn't matter if already have an id-string appended...
echo -n "$IDSTRING" >> $WKGMNTPT/puppylivecdbuild/vmlinuz
[ -f $WKGMNTPT/puppylivecdbuild/$PUPPYSFS ] && echo -n "$IDSTRING" >> $WKGMNTPT/puppylivecdbuild/$PUPPYSFS
[ -f $WKGMNTPT/puppylivecdbuild/$ZDRVSFS ] && echo -n "$IDSTRING" >> $WKGMNTPT/puppylivecdbuild/$ZDRVSFS
#[ -f $WKGMNTPT/puppylivecdbuild/$DEVXSFS ] && echo -n "$IDSTRING" >> $WKGMNTPT/puppylivecdbuild/$DEVXSFS
sync

#100913 need to update file DISTRO_SPECS in initrd.gz, so init script can find puppy files...
mv -f $WKGMNTPT/puppylivecdbuild/initrd.gz /tmp #note $WKGMNTPT may be non-linux fs.
cd /tmp
gunzip initrd.gz
mkdir initrd-tree-tmp1
cd initrd-tree-tmp1
cat ../initrd | cpio -i -d -m
sync
rm -f ../initrd
cp -a -f /tmp/DISTRO_SPECSupdated ./DISTRO_SPECS #see earlier.
find . | cpio -o -H newc | gzip -9 > $WKGMNTPT/puppylivecdbuild/initrd.gz
sync
cd ..
rm -rf initrd-tree-tmp1
cd /root
fi #120628 end

#build new iso file, or direct burn to cd...
#to save space, burn direct from $WKGMNTPT/puppylivecdbuild/ to cd...
m_26="$(eval_gettext 'All the files that will be burnt to CD/DVD are in ${WKGMNTPT}/puppylivecdbuild/.')

$(gettext 'As the working partition may have limited space (for example, you are using a USB pen drive), these files are burnt direct to CD/DVD, rather than create an intermediary iso file. If you do need an iso file, you can copy it from the CD afterward:')
$(eval_gettext '(dd if=/dev/${BURNERDRV} of=puppy.iso seek=0 bs=32k)')

$(gettext "However, if you just want to create an iso file now and not burn to CD/DVD, click the 'No' button.")

$(eval_gettext "Click 'No' button (or close-box on window) to quit program at this point (leaving \${WKGMNTPT}/puppylivecdbuild/ files in existence), and further option to create an iso file...")
$(gettext "Click 'Yes' button to burn to CD/DVD...")"
#Xdialog --wrap --left --title "$m_01" --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$m_26" 0 80

if [ ! $? -eq 0 ];then
 MSG="$(gettext 'ISO file not created.')"
 m_27="$(eval_gettext "Click 'Yes' button to create a 'custom-puppy.iso' in \${WKGMNTPT}/ (assuming that there is 100MB-300MB free space)...")
$(eval_gettext "Click 'No' button (or close-box on window) to quit program at this point (leaving  \${WKGMNTPT}/puppylivecdbuild/ files in existence)...")"
# Xdialog --wrap --left  --title "$m_01" --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$m_27" 0 80
 if [ $? -eq 0 ];then
  #cd $WKGMNTPT
  VOLI=""
  m_27_1="$(gettext 'You can add the CD volume ID, it can be used on Windows and on some Linux system.')"
  VOLI=$(Xdialog --title "$m_01" --stdout --inputbox "$m_27_1" 0 60 "$SFSBASE")
  [ "$VOLI" != "" ] && VOLI="-V $(echo "$VOLI"|tr ' ' '_')"
  [ -f $WKGMNTPT/custom-puppy.iso ] && rm -f $WKGMNTPT/custom-puppy.iso #130223
  # Joliet option
  rxvt -bg orange -fg black -title "$m_01" -e mkisofs -J -D -R $VOLI -o $WKGMNTPT/custom-puppy.iso $BOOTPARM -no-emul-boot -boot-load-size 4 -boot-info-table $WKGMNTPT/puppylivecdbuild/
  MSG="$(eval_gettext '${WKGMNTPT}/custom-puppy.iso created.')"
 fi
 sync
 m_28="$(eval_gettext '${WKGMNTPT}/puppylivecdbuild/ files left in existence.')
$(gettext "Click 'Ok' button to quit...")"
# Xdialog --wrap --left  --title "$m_01" --msgbox "$MSG
 $m_28" 0 0
 exit
fi

VIRTUALCD=""
MSG="$(gettext 'You need to choose a burner drive so that the files created by this program can be burnt to a new CD/DVD.')"
if [ "$BURNERDRV" = "" -o  "$(echo "$BURNERDRV" | grep 'loop')" != "" ]; then
 choice_cdd
fi

if [ "`echo "$BURNERDRV" | grep 'hd'`" != "" ];then
 DEVDEV="ATAPI:/dev/$BURNERDRV"
else
 DEVDEV="/dev/$BURNERDRV"
fi

#now for the actual burn...
m_29="$(gettext 'Please choose the media to burn to.')
$(eval_gettext 'The burner drive is /dev/${BURNERDRV}, and obviously it must be able to burn a DVD if you want to burn a DVD!')

$(gettext "Note, you can later use the 'dd' program to create an iso file:")
 # dd if=/dev/${BURNERDRV} of=puppy.iso seek=0 bs=32k

$(gettext 'PLEASE INSERT THE NEW CD OR DVD RIGHT NOW, THEN CHOOSE FROM MENU...')"
m_30="$(gettext 'New blank recordable CD')"
m_31="$(gettext 'New blank DVD-R (not +R, -RW, +RW)')"
CDCHOICE="`Xdialog --wrap --left --stdout --title \"$m_01\" --menubox \"$m_29\" 0 0 4 CD-R \"$m_30\" DVD-R \"$m_31\"`"

echo '#!/bin/sh' > /tmp/new2cd.sh
if [ "`echo "$CDCHOICE" | grep 'DVD'`" = "" ];then
 #burn to CD...
 echo "mkisofs -D -R -quiet $BOOTPARM  -no-emul-boot -boot-load-size 4 -boot-info-table $WKGMNTPT/puppylivecdbuild/ | cdrecord -multi -tao -pad -data -v speed=4 gracetime=2 dev=$DEVDEV  -" >> /tmp/new2cd.sh
else
 echo "growisofs -speed=4 -Z /dev/$BURNERDRV -R -D -quiet $BOOTPARM -no-emul-boot -boot-load-size 4 -boot-info-table $WKGMNTPT/puppylivecdbuild/" >> /tmp/new2cd.sh
fi

sync
rm -rf /puppylivecdbuild
rm -rf $WKGMNTPT/puppylivecdbuild
sync
umount /dev/$WKGPART

eject /dev/$BURNERDRV

####THE END######
There's this script I created that's called when you click on the remaster menu choice

Code: Select all

#!/bin/sh

# NOTE CURRENTLY NEED TO HARD CODE /root/INITRD_LOCATION where the
# final initrd.lzo file is, so we have a target to replace

TARGETDIR=`cat ~/INITRD_LOCATION | grep '/'`

# Which gtkdialog (for message display)
for P in gtkdialog3 gtkdaialog gtkdialog4; do
  which $P &>/dev/null && GTKDIALOG=$P && break
done

export MSG="$TARGETDIR not accessible - is the drive mounted? Exiting"
if [ ! -d $TARGETDIR ]; then
  SIZE=${#MSG} 
  LEN=` expr $SIZE \* 10`
  if [ $LEN -lt 200 ]; then
    LEN=200
  fi
  if [ $LEN -gt 500 ]; then
    LEN=500
  fi
  export GTKBOX=`echo "<window title=\"Information\"><vbox width-request=\"$LEN\"><text><variable>MSG</variable><input>echo -en \"$MSG\"</input> </text></vbox></window>"`
  $GTKDIALOG -p GTKBOX --center
  exit;
fi


# Run our own remasterpup version
/usr/sbin/REMASTER/remasterpup3

#############################################################################
# Here we go, after a remaster and puppylivecd holds the relevant files
# from within that folder we run the following, which assumes frugal boot
# folder (output for vmlinuz and initrd) is /mnt/sda4
#

export MSG="Building/installing $TARGETDIR/initrd .. please wait"
# Calculate a reasonable choice of size
SIZE=${#MSG} 
LEN=` expr $SIZE \* 10`
if [ $LEN -lt 200 ]; then
  LEN=200
fi
if [ $LEN -gt 500 ]; then
  LEN=500
fi
export GTKBOX=`echo "<window title=\"Information\"><vbox width-request=\"$LEN\"><text><variable>MSG</variable><input>echo -en \"$MSG\"</input> </text></vbox></window>"`
$GTKDIALOG -p GTKBOX --center &
X3PID=$!

# Create work directory
WORKDIR=`cat /tmp/WKGPART` # where puppylivecdbuild (created by remasterpup3
rm -rf $WORKDIR/puppylivecdbuild/newdir  # Shouldn't exist - but just in case
mkdir $WORKDIR/puppylivecdbuild/newdir
cd $WORKDIR/puppylivecdbuild/newdir
rm $TARGETDIR/vmlinuz
cp -avr /usr/sbin/REMASTER/ISO-FILES/vmlinuz $TARGETDIR/vmlinuz &
rm $TARGETDIR/initrd.prev
mv $TARGETDIR/initrd $TARGETDIR/initrd.prev
zcat ../initrd.gz | cpio -id                                    # Extract initrd content
mv ../puppy*.sfs .                                              # Copy in puppy sfs
find | cpio -o -H newc > $TARGETDIR/initrd                      # Reform the initrd
cd ../..
sync
rm -rf $WORKDIR/puppylivecdbuild

# Throw out a message to remove current message and indicate that we're done
kill $X3PID
export MSG="DONE : new initrd and vmlinuz now available in $TARGETDIR"
SIZE=${#MSG} 
LEN=` expr $SIZE \* 10`
if [ $LEN -lt 200 ]; then
  LEN=200
fi
if [ $LEN -gt 500 ]; then
  LEN=500
fi
export GTKBOX=`echo "<window title=\"Information\"><vbox width-request=\"$LEN\"><text><variable>MSG</variable><input>echo -en \"$MSG\"</input> </text></vbox></window>"`
$GTKDIALOG -p GTKBOX --center &
X3PID=$!
# Leave for user to close
#sleep 4
#kill $X3PID
I store both of those in /usr/sbin/REMASTER folder and also within that folder I've a ISO-FILES folder that holds the files on the boot CD (except of course puppy sfs as the remaster script above creates that).

Note that the output is just two files, vmlinuz and initrd.lzo being replaced by the new version. Its also a personal to PC remaster.

This version of remasterpup3 is set to use lzo compression, if you search for COPTIONS there's some code commented out to overide that to no compression (-noX -noI -noF -noX settings)

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#9 Post by rufwoof »

The non-layered pup using cp -rs to load sfs appears to work well, boots to similar to a full install of a lean pup rooted in ram and loading a 500MB squashed office sfs (around 1.2GB when non squashed) took a couple of seconds to load (create all of the sym links) and everything I've briefly tested within that sfs (Libre Office, Audacity, Skype, Qt, full inscape etc.) all seem to be working as intended.

Operational runs times are fine (quick).

That's with the sfs remaining on disk. Next I'm going to try out running the same, but with the sfs copied to ram (so all running in memory). Can't foresee any reason why that might not work OK
Attachments
no-layers.jpg
(74.77 KiB) Downloaded 465 times

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#10 Post by rufwoof »

I can envision a really small non-layered pup that boots more or less to a command prompt, loaded into memory (i.e. perhaps net booted PXE) that then downloads the main pup sfs (desktop gui) loading that using sym links (so stored/runs in compressed format). That might in turn downloads/runs a office sfs.

Conceptually that would boot quickly and the main bottleneck would be download times. My ISP serves at 50Mbit, which is getting up close to the 100Mb local LAN speed, so not a great deal of difference between storing the main pup and office sfs's off-site to that of having it on a local server.

Perhaps a 10MB main boot pup, and all of the rest downloaded into ram (and/or swap file/partition) space.

All just toying/playing around though at present, but looks to have some potential.

User avatar
Ted Dog
Posts: 3965
Joined: Wed 14 Sep 2005, 02:35
Location: Heart of Texas

#11 Post by Ted Dog »

there is also the bind mount method with chroot that existed prior to current layering aufs etc. Seems cleaner than your approach. Also anither tiny distro uses file lists and time date changes to I.D. changed files to save changes they heavly use initrd in a chained fashion. Name is slatix or something like it. Seems solid enough but releases are dated and sparse.

http://distrowatch.com/table.php?distribution=slitaz

poor distro is 99th :shock:

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#12 Post by rufwoof »

Thanks Ted.

Appreciated.

User avatar
Ted Dog
Posts: 3965
Joined: Wed 14 Sep 2005, 02:35
Location: Heart of Texas

#13 Post by Ted Dog »

Your welcome. Your scripts reminded me slitaz. I found it easy to puppify slitaz made a killer hybrid years back in 40M had browser transparent windows and a media player. Posted it on their site and had a bunch of interest but was removed since I did not use slitaz methods to add code, added via pets :roll:

User avatar
Ted Dog
Posts: 3965
Joined: Wed 14 Sep 2005, 02:35
Location: Heart of Texas

#14 Post by Ted Dog »

wow slitaz is releasing monthly with a rolling release have added them to my copy only UEFI method to boot ISO. Current is only a few days old.
Found out same method works to boot an old non GPT disk by making a FAT32 and label it EFI. copied files from UEFI.zip Allows duel boot ( I forced windows8.1 to boot old school and use UEFI to boot linuxes )
If I could just figure out how to change slitaz background image.. hate spiders

User avatar
Ted Dog
Posts: 3965
Joined: Wed 14 Sep 2005, 02:35
Location: Heart of Texas

#15 Post by Ted Dog »

I have similar goals as you for a different idea. Fast boot with USB and or crossover cable. My idea is a disaster recovery and emergency grid wifi system. After the last big one hit OKC and it was impossible to contact family for days to see if they were alright.
Ideally gave out a crossover cable and a boot image to share booting either Macs or Windows machines into linux for common base.
using the grid wifi setup to load whatever else software wise as people walked home.
Needs universal booting and a wifi. PXE boot would be ideal. just pass out cheap crossover cables rather than more expensive cd or usbs. People would then boot other peoples computers and those at home etc. to spread the pxe boot software and load the software apps.

User avatar
ETP
Posts: 1193
Joined: Tue 19 Oct 2010, 19:55
Location: UK

#16 Post by ETP »

Hi Ted,
Nice idea. These adapters work out cheaper than X-over cables.
http://www.amazon.com/Cables-Unlimited- ... B00030BYJI
Regards ETP
[url=http://tinyurl.com/pxzq8o9][img]https://s17.postimg.cc/tl19y14y7/You_Tube_signature80px.png[/img][/url]
[url=http://tinyurl.com/kennels2/]Kennels[/url]

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#17 Post by rufwoof »

Ted Dog wrote:wow slitaz is releasing monthly with a rolling release have added them to my copy only UEFI method to boot ISO. Current is only a few days old.
Found out same method works to boot an old non GPT disk by making a FAT32 and label it EFI. copied files from UEFI.zip Allows duel boot ( I forced windows8.1 to boot old school and use UEFI to boot linuxes )
If I could just figure out how to change slitaz background image.. hate spiders
Its only a small one :)

Applications (menu), Preferences, Desktop Preferences, Appearance tab and select another wallpaper.
Attachments
dt.jpg
(55.82 KiB) Downloaded 149 times

stemsee

#18 Post by stemsee »

i am trying out your method now. But I think it wont work for my distro because what was the previous .sfs file is now a fully decompressed initrd in ram using 4x the memory than a loop mounted sfs. Anyway, i left pup_a, pup_rw and pup_z in existence for mounting stuff on, but of course they are no longer layers, until i put back some of he original init code. Still very interesting though. I envisage using rsync to maintain the savefile file mounted on pup_rw, Failing that your link method is also available. And I have ramdisk which i can dump to device if need be.

Post Reply