Swapfile for low-RAM PCs

Continuing my testing of Puppy on low-RAM machines, I have now modified /etc/rc.d/rc.shutdown to automatically create a swapfile.

This only happens under certain stringent conditions. The PC must have less than or equal to 128MB RAM and no existing swapfile or swap partition.

On the first shutdown, if a pup-save file is created on a hard drive partition, or session saved to the entire partition, and if the partition is a "fast" media (not USB), then a swapfile is created. The shutdown script does not ask, after all this is no more invasive than the operation of creating a save-file. Furthermore, a swapfile is really essential for reasonable performance. Note, it also depends on sufficient free space in the hard drive partition.

Note also, this automatic creation of a swapfile, named 'pupswap.swp', existed in the 'rc.sysinit' script in the Puppy 3.x series (I don't recall about the 2.x series), and I removed it for the 4.x series. Now I have brought it back, but now creating it at the first shutdown.

Posted on 5 Jul 2009, 10:55


Posted on 5 Jul 2009, 14:12 by dogone
Swap file creation
So be it. I do suggest that Puppy inform the user that both a swap file and save file are being created. It's the Linux way.

Posted on 5 Jul 2009, 20:00 by dogle
Thanks ...
...for continuing to look after low-RAM machines. I beg to second dogone's comment.

Posted on 6 Jul 2009, 8:02 by BarryK
Okay, there is now an information message at shutdown about creation of the swapfile.

Posted on 6 Jul 2009, 10:02 by technosaurus
Why not at startup
Sound good but was there a particular reason that you decided not to do it during startup when the RAM size and swap are being detected and turned on? Seems like it would be well worth the delay to users with low RAM and not really affect the others...

Posted on 6 Jul 2009, 10:35 by BarryK
I weighed everything up, decided it is better to do it at first shutdown. The 'init' scripts detects its existence and makes some space allocations accordingly, which is convenient.

Posted on 6 Jul 2009, 14:25 by drongo
Might be an idea to warn users to defrag NTFS partitions before proceeding. We occasionally get people complaining about Puppy causing problems on their Windows partition after creating pupsave files. Something like closedown without saving/reboot into Windows/defrag/reboot into Puppy.

Not sure if you'd need this for FAT?

Posted on 6 Jul 2009, 19:33 by ICPUG
Swapfile created on the 3 series?
Barry says the swapfile was created on the Puppy 3 series and was removed from Puppy 4 series.

I have a 128MB machine and it never had the swap file from the Puppy 3 series - so the limit must have been set lower.

Also, justification for this swap file creation is that it is no more invasive than the pupsave creation. However, the user has a choice with the pupsave. They are not just informed - they can refuse to create it.

Automatic creation of files should be used sparingly. Look what happened when the pup_xxx.sfs was automatically copied to the hard drive without the user having a say.

We know best, doing things automatically, is the Microsoft way, not the Puppy way.

Posted on 6 Jul 2009, 20:16 by BarryK
swapfile in 3.x -- and 2.x
I just checked, the automatic creation of 'pupswap.swp' is also in the 2.x series.

The code that creates 'pupswap.swp' is in rc.sysinit. In both 2.x and 3.x pups there is no check for the amount of ram. The only check is if running in PUPMODE=12.
... so it was a bit more restricted than my current implementation in terms of the PUPMODE, but unrestricted in terms of amount of RAM.

Posted on 6 Jul 2009, 20:20 by BarryK
Puppy already has a warning at shutdown, if partition is NTFS then please defragment it first before creating a save-file.

Posted on 7 Jul 2009, 18:53 by ICPUG
Yes the warning is fine with the pupsave - because one can choose not to create the pupsave - defrag - then create pupsave next time.

However, if you create the swap file automatically then you cannot defrag before it is created.

Posted on 9 Jul 2009, 7:53 by Pizzasgood
The swap file is only automatically created if the user has told it to create a pupsave.

Posted on 9 Jul 2009, 8:29 by BarryK
Re: low-RAM and swapfile
I bumped it up a bit, now the swapfile gets created if RAM is 256MB or less.

Probably there is a good argument to not have any test for the amount of RAM, always create the swapfile if save-file is on a fast hard drive and there is no other swap file/partition.