Page 1 of 1

How can I save to pup001 file on a schedule?

Posted: Sat 13 Aug 2005, 19:56
by dvw86
I have Puppy running in RAM and often do not reboot for days, so a sudden power outage (like my kids pushing the reset button) could cause me to loose a lot of work. I would like a little script that would save everything back to the pup001 file like the rc.reboot script does, but without rebooting. I looked at stripping that script down but I'm not quite sure what all of it does. Does anybody have any advise to get me started? Thanks

Posted: Sat 13 Aug 2005, 23:56
by BarryK
I presume you're booting off usb, so all of pupxxx got copied onto ramdisk?

If so, yeah, a big button on the desktop to do that, or even an automatic thing that does it every say 5 minutes ...Puppy does have a background daemon script called "check_space" that could be extended to do this.

This is on my to-do list, maybe it will interest somebody.
/tmp/rc.reboot has the shutdown script, need the code out of there to see how writing back to pupxxx file is done.

Posted: Sun 14 Aug 2005, 00:42
by dvw86
Actually I have it installed onto the hard drive but have it loading into RAM as discussed here. It's the same basic set up as booting from a USB drive. I wouldn't mind writing or modifying the script, but I'm not sure what all the script is doing. I'm guessing that this is the place to start.

Code: Select all

#v0.9.8 (see /sbin/init and /etc/rc.d/rc.sysinit)
if [ -f /tmp/pupxxxshutdown.txt ];then
. /tmp/pupxxxshutdown.txt
 #echo
 echo "Please wait, copying /root to $PUPMNTPOINT..."
 echo "(writing back to the pupxxx file on the USB drive from ramdisk)"
 rm -fr $PUPMNTPOINT/*
 #...heh, heh, this leaves behind hidden files/dirs, so do this...
 rm -fr $PUPMNTPOINT/.[a-zA-Z0-9]*
 sync
 cp -af /root/. $PUPMNTPOINT
 sync
 echo "...done"
  echo "Zeroising unused portion of pupxxx partition..."
  PARTFREE=`df | grep "$PUPMNTPOINT" | tr -s " " | head -n 1 | cut -f 4 -d " "`
  dd if=/dev/zero of=$PUPMNTPOINT/empty.tmp bs=1024 count=$PARTFREE > /dev/null 2>&1
  sync
  rm -f $PUPMNTPOINT/empty.tmp
  sync
  echo "...done"
 #rm -f /tmp/pupxxxshutdown.txt #shouldn't be necessary as /tmp pristine at bootup.
Fi

Posted: Sun 14 Aug 2005, 02:48
by Bruce B
dvw86 wrote:Actually I have it installed onto the hard drive but have it loading into RAM as discussed here. It's the same basic set up as booting from a USB drive. I wouldn't mind writing or modifying the script, but I'm not sure what all the script is doing. I'm guessing that this is the place to start.
[cut]

I don't interpret anything written in the posts at the link you referenced as loading pupxxx file to RAM. As near as I can read it, pupxxx is sitting on the hard disk and being written to each time you save your work. I could be wrong, that's why I have a ?

Posted: Sun 14 Aug 2005, 03:03
by dvw86
I could be wrong, but I believe that the line root=/dev/ram0 ramdisk_size=16384 loads Puppy into RAM. I know that if I create a file and save it, the file is gone if I suddenly loose power to the computer or if I press the reset button. If I do a proper shut down the file is still there when it boots back up.

Posted: Sun 14 Aug 2005, 03:15
by Bruce B
I could be wrong but I think your pupxxx file is being used from the hard disk.

How about making a quick calculation by booting the computer and running the free command. I think you will be able to roughly calculate if there is a 256 MB* pupxxx file sitting in RAM along with the other files from image.gz, usr_cram.fs and normal system usage.

* or whatever size it is on your 'puter

Posted: Sun 14 Aug 2005, 03:29
by dvw86
total 482992
used 451100
free 31892

Posted: Sun 14 Aug 2005, 03:31
by Bruce B
It appears like your pupxxx is in RAM huh? It is in RAM you better come up with a way of periodically saving files :)

I think an option 1 typically fits together simplistically something like this:
  • /bin/ files are in RAM - generated each boot by image.gz
    /dev/ files are in RAM - generated each boot by image.gz
    /etc@ files are on hard disk inside pupxxx
    /lib/ files are in RAM - generated each boot by image.gz
    /mnt/ the mount points are generated each boot by image.gz
    /proc/ files in RAM generated by the system
    /root/ the mounted pupxxx
    /sbin/ files are in RAM - generated each boot by image.gz
    /tmp/ created by image.gz and used by various process throughout the session
    /var/ is generated by image.gz and possibly added to during the session - all is lost on reboot
    /usr/ files are in RAM - generated each boot by usr_cram.fs
    AND
    /usr/ is also from the pupxxx file at /root/.usr and as far as precedence and priority it
    rates high, meaning whatever is in /root/.usr has presedence to what was in usr_cram.fs when
    it was loaded.
Edit note: the only significant difference between the GRUB instructions I've been using and the ones in the thread is the ramdisksize. I figured that was more for making sure there was adequate space to expand image.gz

Posted: Tue 16 Aug 2005, 21:13
by PaulR
dvw86 wrote:I know that if I create a file and save it, the file is gone if I suddenly loose power to the computer or if I press the reset button. If I do a proper shut down the file is still there when it boots back up.
Probably a stupid idea but is it not possible to reboot via a cron job so all your stuff gets kicked out to disk?

Posted: Wed 17 Aug 2005, 00:56
by dvw86
PaulR wrote:Probably a stupid idea but is it not possible to reboot via a cron job so all your stuff gets kicked out to disk?
I think that cron is a great idea. It has been on my to-do list. I would just have it run a "save-to-disk" script rather than the reboot script though. My problem is getting the right save-to-disk script.

Posted: Wed 17 Aug 2005, 02:00
by doopdoop
The problem could be time in this. If you have a larger pupXXX it needs some time to copy the whole thing to an USB stick.

Idea:
Let not really copy the thing, just check for differences.

1. Poorman's way: do a cp with the -u (update, just copies newer files)
2. Geek's way: Install fam (file alternation monitor), which checks for any change in a specified directory (here /root) and let a script react on this. Advantage: a little bit safer (does not depend on correct timestamp ) and less overhead, if there are a lot of files.