How can I save to pup001 file on a schedule?
How can I save to pup001 file on a schedule?
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
- BarryK
- Puppy Master
- Posts: 9392
- Joined: Mon 09 May 2005, 09:23
- Location: Perth, Western Australia
- Contact:
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.
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.
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
[cut]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.
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 ?
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.
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
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
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:
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.
Probably a stupid idea but is it not possible to reboot via a cron job so all your stuff gets kicked out to disk?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.
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.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?
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.
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.