Here's a script for flushing RAM to USB on Puppy 3.01

Using applications, configuring, problems
Post Reply
Message
Author
andrei
Posts: 80
Joined: Wed 31 May 2006, 23:56

Here's a script for flushing RAM to USB on Puppy 3.01

#1 Post by andrei »

I have been testing a script in Puppy 2.17, which flushes RAM when running Puppy from the USB flash drive. It seems to work, so I decided to post it.

Actually, the flushing will most likely be implemented automatically, and much more efficiently, on Puppy 2.20. This is because 2.20 will use the updated version of unionfs, with the flushing capability built-in. So, this script which I am posting could only be useful for those people who will stay for some time, for some reason, on 2.17.

I have to explain what I mean by "flushing". Suppose you are running Puppy from the USB flash drive. There is a file on the flash drive, called pup_save.2fs, where all your data is stored. (The file stores an ext2 filesystem, which is mounted when you boot Puppy from the USB flash.) When you write some new file, or make a change to the existing file, all the new data is actually written on RAM, rather than directly on pup_save.2fs. This is done in order to avoid frequent writes on the flash memory. It turns out that USB flash drives can only support a limited number of writes, about 1 million. So, if we wrote everything on pup_save.2fs directly, this would lead to the flash drive "wearing out" in a matter of days. Therefore, all the changes are written on RAM. Periodically the files written on RAM are saved to pup_save.2fs, so they persist after the reboot. This usually happens every 30 minutes, or every time you press the Save button on the desktop.

But due to some technical limitations, when the files are saved from RAM to pup_save, they are not removed from RAM. In other words, files are being COPIED from RAM to pup_save instead of being MOVED. This leads to accumulation of the files in RAM. Accumulation of files in RAM is not good for at least two reasons. First, if you download or create many files, RAM gets full. Especially on older machines with small RAM. But even if you have lots of RAM, there is another problem. Remember that saving files from RAM to pup_save.2fs happens periodically every 30 min. If files get accumulated in RAM, then obviously saving takes longer and longer every time. This is not good.

The flush script solves this problem. If you feel that there are lots of files accumulated in your RAM, just execute the flush script from the terminal window. Go to the folder where the flush script is located, and say:
./flush
The script is very verbose, trying to explain what it is doing. It will free most of the memory, by MOVING all or almost all the files from RAM to the pup_save file on the USB. You should probably exit all the running programs before executing flush, although it is not strictly necessary. The only reason is, if some program is writing on some file at the same time when flush is executed, then this change will likely be lost. So, at least "stop doing everything" when executing flush.

Notice that some preparation is required for this to work. Please read the README file inside the tar.

Once again, this is a temporary solution, Puppy 2.20 will have a much better realization of flushing.
Attachments
flush.tar
scripts to flush RAM to USB on Puppy 2.17
(30 KiB) Downloaded 1619 times
Last edited by andrei on Sat 05 Jan 2008, 03:11, edited 1 time in total.

User avatar
ipw2200user
Posts: 3
Joined: Tue 05 Jun 2007, 08:06
Location: New Zealand

Installed and Testing......

#2 Post by ipw2200user »

I've installed these scripts because I have a problem with puppy 2.17.1 "locking up" when RAM gets too low on a 256MB RAM Laptop. The scripts seem to work OK so far - I make changes to the filesystem and the verbose feedback I get from the prompt indicates it's doing the job. Thanks!

andrei
Posts: 80
Joined: Wed 31 May 2006, 23:56

#3 Post by andrei »

This thread only applies if you are running Puppy from the USB flash drive (aka pendrive).

I could not make myself comfortable with unionfs. I am also not satisfied with how whiteout files are handled in 3.00. On the other hand, I am now very busy at work, and so cannot spend too much time with Puppy. So, I decided to revert to aufs, just for now. The flushing snapmergepuppy which I previously submitted would not work in 3.00, apparently because some changes in the version of bash. So, I had to correct it, and here is the corrected version for use in 3.00 (I have not tested it on 2.17, but I guess it should work on 2.17 too...)

I suspect that this might be more reliable than what we now have in 3.00, although I must say that I had some problems when uninstalling packages. In any case, if somebody wants to try this, then first of all, two things have to be done. First, reverting to aufs. Go to the folder /mnt/home/ (this is where the USB flash drive is mounted) and edit the file syslinux.cfg . In order to switch to aufs, you would have to add layerfs=aufs at the end of the line. For example, my syslinux.cfg consists of one line:
default vmlinuz initrd=initrd.gz pmedia=usbflash layerfs=aufs
This is the standard syslinux.cfg, except for layerfs=aufs at the end.

The second thing, petget should be modified. I just reverted it basically to what it was in 2.17, except for pointing it to the repository for Puppy 3 , rather than Puppy 2. I am attaching the modified petget as a tar file. It should be copied to /usr/sbin/

At this point I would recommend a reboot, just for aufs to take over. Then, install the attached smpflush-3.00.pet. If you want to use flushing, the flush button is now available through Menu->Setup->USB Flash Wizard. But enabling it requires some preparations, just as it was in 2.17. When you first time press the Flush button in the wizard, you should get the instructions on what to do. Alternatively, you can press Help button in the USB Flash Wizard, and read the instructions at the end of the help page. (Flushing could be also invoked from the command line. The command is: snapmergepuppy -f )

I am sorry about this, but this is about the only way I could help now (or rather try to help). Eventually all these things will be sorted out.
Attachments
smpflush-3.00.pet
you should first replace /usr/sbin/petget with the attached new petget, and only then install this smpflush pet
(12.94 KiB) Downloaded 872 times
petget.tar
modified petget; copy it to /usr/sbin/
(80 KiB) Downloaded 859 times

andrei
Posts: 80
Joined: Wed 31 May 2006, 23:56

new version for Puppy 3.01

#4 Post by andrei »

Here is a new version, with two bugs fixed:

1. There was a problem with spaces in filenames. Fixed.
2. The script used to go into an endless loop when flushing a new subfolder in / . Fixed.

I also added a terminal command [b]flush[/b]

The old instructions apply, with one new thing. I now recommend to exit running programs (like Firefox) when executing flush. I had problems installing new Firefox extensions and then flushing while Firefox still running. This new version is tested in Puppy 3.01, and should also work in 3.00.
I am re-attaching the same modified petget for completeness.

Happy flushing in 2008!
Attachments
petget.tar
this is the same, nothing changed
(80 KiB) Downloaded 1263 times
smpflush-3.01.pet
(13.26 KiB) Downloaded 931 times

Post Reply