Puppy Swap File Questions

Using applications, configuring, problems
Message
Author
peb
Posts: 18
Joined: Mon 24 Oct 2005, 20:28

Puppy Swap File Questions

#1 Post by peb »

I've browsed a bit trying to figure out Puppy swap files. I have some basic questions.

I'm running Puppy 4.1 from a CD-ROM with a pupsave file on a Windows vfat volume. The pupsave file, about 512 mb, is encrypted supposedly.

I assume that part of that pupsave file is being used as a swap file when I'm working in Puppy, and that it's encrypted when I'm not. Right?

Can Puppy mess at all with pagefile.sys on the vfat volume?

Does it write any other transient files, even temporarily on the vfat volume outside the pupsave file?

Thanks.

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#2 Post by Flash »

By default Puppy looks for a swap partition (not a swap file) when it boots, and uses it if it finds it. I think Puppy can be configured to use a swap file, even use the Windows page file. There was a discussion in the forum a year or two ago about doing just that. Try entering "page file AND swap" in the forum search engine.

Puppy doesn't encrypt what it puts in swap memory. I seem to remember a thread somewhere in this forum discussing that (I think it was started by forum member Aitch.) I can't remember if a way was suggested to encrypt what is in swap memory.

Bruce B

#3 Post by Bruce B »

By default most Puppys will look for a swap file by the name of pupswap.swp in the root directory. In frugal install this is AKA /mnt/home, AKA /initrd/mnt/dev_save/. (maybe in other locations also, but I've not checked every possibility)

On boot up I perform a variety of tasks.

On shutdown I perform different tasks with a script I call po, which is short for PowerOff.

On shutdown, a person could, with ease write a script to:

1) turn off the swapfile
2) mount the swapfile
3) write zeros or random data to the swapfile
4) unmount the swap file
5) Then continue with the shut down process.

PaulBx1
Posts: 2312
Joined: Sat 17 Jun 2006, 03:11
Location: Wyoming, USA

#4 Post by PaulBx1 »

The other thing is to not use swap at all. Many machines will run fine without it.

Unfortunately Puppy requires a swap file or volume while booting; if a linux swap partition is not available it will CREATE a swap file WITHOUT ASKING. :shock: And then use it. There is no "pfix=noswap" parameter although I've been lobbying for one. This means at the end of the boot you must kill swap with the swapoff command; I do it in /etc/rc.d/rc.local. And hope nothing got stuck in it even by that point.

If you use swap, cleartext passwords and so forth will be in it, and you MUST clean it as Bruce suggests to ensure security. No, swap is not in the pupsave.

Pupsave encryption is pretty rudimentary at this point.

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#5 Post by Flash »

Thanks Bruce. Once again I stand corrected. :lol:

PaulBx1, I don't have a hard disk drive at all, only RAM. What does Puppy do if it can't find a place to put a swap file?
[url=http://www.murga-linux.com/puppy/viewtopic.php?t=69321][color=blue]Puppy Help 101 - an interactive tutorial for Lupu 5.25[/color][/url]

Bligh
Posts: 480
Joined: Sun 08 Jan 2006, 11:05
Location: California

#6 Post by Bligh »

TazOC found this in response to my query.

"Puppy Linux will automatically use a Linux swap partition. With Puppy 2.x and later when using a pup_save file, Puppy will use these files for swap on boot if in same directory as the pup_save file : WIN386.SWP, PAGEFILE.SYS, pup.swp and, with Puppy 2.01, pupswap.swp. Puppy 2.01 and later will create a swap file if needed in same dir as pup_save if needed, unless using 2.02 or later which won't create one if not one of the following file systems: msdos (FAT12/16), vfat (FAT32), ext2, ext3, reiserfs, minix"

Cheers

peb
Posts: 18
Joined: Mon 24 Oct 2005, 20:28

#7 Post by peb »

[quote="PaulBx1"]The other thing is to not use swap at all. Many machines will run fine without it.

Unfortunately Puppy requires a swap file or volume while booting; if a linux swap partition is not available it will CREATE a swap file WITHOUT ASKING. :shock: And then use it. There is no "pfix=noswap" parameter although I've been lobbying for one. This means at the end of the boot you must kill swap with the swapoff command; I do it in /etc/rc.d/rc.local. And hope nothing got stuck in it even by that point.
/quote]

Good information. Thank you. And I wholeheartedly support your lobbying. One thing I strongly dislike about Windows is that it runs services, creates all sorts of files that are difficult to track down, etc. when it does anything of substance. But I've found many versions of Linux aren't much better. What I want is something like Portable Apps that leave no footprints (except, I'm sure for the swap files) on the host computer when they exit.

I don't mind using a pupsave file for the convenience, but I don't want Puppy prints elsewhere, even in swap files, and particularly without my assent.

Bruce B

#8 Post by Bruce B »

1) I still have an accuracy concern. Under some circumstances Puppy will make a pupswap.swp file, this is agreed. My accuracy concern is on all recent and current versions? Also on all hdd file systems.

2) Tend to think it is a given that Puppy will look for it and activate it, if found as a pretty standard rule.

3) The other thing is, I didn't offer to show how to clean it on reboot. If someone doesn't know, but wants an example, just ask.

User avatar
Aitch
Posts: 6518
Joined: Wed 04 Apr 2007, 15:57
Location: Chatham, Kent, UK

#9 Post by Aitch »

3) The other thing is, I didn't offer to show how to clean it on reboot. If someone doesn't know, but wants an example, just ask.
OK, Bruce,

I'll volunteer for that, as I know you're dying to tell us :wink:

Gets my curiosity juices flowing, for sure

Aitch :)

peb
Posts: 18
Joined: Mon 24 Oct 2005, 20:28

#10 Post by peb »

Bruce B wrote: 3) The other thing is, I didn't offer to show how to clean it on reboot. If someone doesn't know, but wants an example, just ask.
An example would be very helpful

User avatar
puppyluvr
Posts: 3470
Joined: Sun 06 Jan 2008, 23:14
Location: Chickasha Oklahoma
Contact:

#11 Post by puppyluvr »

:D Hello,
I have understood that when booted pfix=ram Puppy didnt touch the hard drive....
Is this mistaken..
.Did I misunderstand, or are you saying Puppy will mount a drive and use a Windows Pagefile on it for swap?? Unknown to the user???
Or create a pupswap.swp file on it???

As for System Ram, doesnt the bios flush it on boot??

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#12 Post by Flash »

puppyluvr wrote:... As for System Ram, doesn't the bios flush it on boot?
When the system boots, the BIOS assumes there is nothing stored in RAM because shutting the computer off turns off the power to RAM which allows the data stored in RAM to "evaporate." It takes a few seconds, or possibly even a minute or two, for the data in RAM to completely dissipate, during which time it has been demonstrated that the RAM can be powered back up and its data recovered, if done right. Not with any BIOS I've heard of, however. All BIOSes are designed to simply ignore and overwrite anything that might be in RAM when the computer boots.

User avatar
puppyluvr
Posts: 3470
Joined: Sun 06 Jan 2008, 23:14
Location: Chickasha Oklahoma
Contact:

#13 Post by puppyluvr »

:D Hello,
@Flash,
Thanks for the clarification, so its more an ignore than flush...Equally effective...
As to my other query, any advice. Not accessing the HD is a critical point for some of my users, and I would like to be clear on this...

@ Under any circumstances, will Puppy make use of an existing drive without user direction????? When booted pfix=ram????? And is there a pfix=noswap for Puppy???

Bruce B

#14 Post by Bruce B »

Sorry guys, I got side tracked and forgot to reply fast.

Basically what we want to do is mount it, write zeros to it then unmount it.

The standard name for the Puppy swapfile is: pupswap.swp, I'll use this for illustration. For purpose of illustration I'll make up a mount point at /mnt/swapf

Normally, on an hdd install, your swap file would be at the highest level of the filesystem where puppy is mounted. This is usually accessible at the symlink /mnt/home.

Considering all this as true on your computer, we would run these commands:

swapoff /mnt/home/pupswap.swp

(we deactivated it, but if we didn't we could do the rest, the problem is with an activated swapfile any data it is holding will not get zeroed, just the free area gets wiped)

mount -t tmpfs -o loop /mnt/home/pupswap.swp /mnt/swapf

dd if=/dev/zero of=/mnt/swapf/tmpfile.tmp

(note: we are not zeroing pupswap.swp, not at all, if we did that we'd lose the formatting)

(if you read carefully, you see we are writing of (output file) called tmpfile.tmp inside pupswap.swp)

(this file will have contents of zeros and it will fill the swap file) (alternately we could use the if=/dev/random in place of if=/dev/zero)

rm /mnt/swapf/tmpfile.tmp


(we remove the file, now pupswap.swp is all zeros)

umount /mnt/swapf

Notes

dd is not told when to stop, it will stop when the pupswap.sfs if full. It will usually be short on get compared to the puts. But it will be fast.

one could tell it to write in small chunks like 512 bytes at a time. this would assure the last part gets put, but it takes longer.

dd if=/dev/zero of=/mnt/swapf/tmpfile.tmp bs=512

You can also do similar inside your pup_save file and on partitions.

dd if=/dev/zero of=tmpfile.tmp bs=512

then

rm tmpfile.tmp

Personally, I'm a bit paranoid writing anything of any kind to NTFS. Paranoia is a fear lacking in foundation and I'm not sure of my foundation.

The foundation I have is (1) there was a time we couldn't with Linux, (2) then FOSS development achieved a level where we could, (3) I don't think MS ever released the NTFS specs, did they? (4) lastly it is Microsoft partition and not much trust there on my part.

I'm not saying this to discourage anyone from wiping an NTFS partition. I don't have one either, but if I did, I'd probably wipe it while running XP.

I found a nice set of Unix utility ports for Windows here:

http://unxutils.sourceforge.net/

Lastly, run the commands manually for testing, then when you are satisfied with all your file locations, mount points and whatever else, put the commands in a script, then just call the script.

I would also suppose the best place to deactivate the swapfile is after leaving X and booting to the Command Line.

Then I'll be ready for Q&A if anyone has some.

PaulBx1
Posts: 2312
Joined: Sat 17 Jun 2006, 03:11
Location: Wyoming, USA

#15 Post by PaulBx1 »

Paranoia? Seems justified, given that gparted used to be able to downsize an NTFS partition, but if that partition is a Vista installation, it borks Vista. Since gparted is presumably capable of moving files around, the only conclusion I can think of is that Vista stores data on the partition but outside any file, or that there is a new file type that no one outside Microsoft knows about. Either one is at least disturbing.

I have my own paranoia about scrubbing a swap file or partition. If important cleartext is put on a drive, there is always a chance it will remain there; for example, an incorrect shutdown, or incorrect code that doesn't quite do what one imagines it is doing.

I just noticed Puppy no longer forces you to have a pupswap.swp file, as none exists on my /mnt/home (which is FAT32) with my Puppy 4.1.2. So I wonder what happens if I just boot without shutting off swap in my rc.local? I have no swap partition. I will try it and see if Puppy concocts a swap from somewhere.

Puppyluvr, there is no pfix=noswap. That was only a desire of mine.

<later>
Woops, I just realized my rc.local for this version does not have a swapoff. Yet "free" shows no swap, and as I said before, pupswap.swp is not created. So it looks like Barry responded to the complaints, or at least when he reworked his init script he did not bother to put in the "you'll get swap whether you want it or not" code. :)

peb
Posts: 18
Joined: Mon 24 Oct 2005, 20:28

#16 Post by peb »

I'm running Puppy 4.x. I tried to look for swp and sys using pfind to serach files and file content.Searches for file content seemed to run, but eventually hung (0% activity and blanked dialogs) without returning anything. I don't have any confidence in the lack of results. Pfind didn't find any files with the .swp extension

When I looked at running processes, it showed the process

grep -i -l pagefile.sys /proc/acpi/event

I ran md5 hashes on pagefile.sys at random intervals, and after shutting down and rebooting the computer. No change in hash file results whatsoever. So, it doesn't look like the pagefile.sys is being used.

The info provides some comfort that the pagefile.sys is not being tampered with, but without searching all the scripts for both .swp and .sys, I wouldn't call the evidence conclusive.

Bruce B

#17 Post by Bruce B »

peb wrote:I'm running Puppy 4.x. I tried to look for swp and sys using pfind to serach files and file content.Searches for file content seemed to run, but eventually hung (0% activity and blanked dialogs) without returning anything. I don't have any confidence in the lack of results. Pfind didn't find any files with the .swp extension
1) my experience is, it is more the exception than the rule that Puppy makes a pupswap.swp file. So much more the exception than the rule, I don't expect it to do it, as a rule.

Moreover, it may have been some versions that made this file and other versions not. Even at that, only in some circumstances. Example: maybe not on an NTFS, but yes on other file systems. On the other hand;

2) it is my experience that in an hdd install, Puppy will look for the file at the highest level and activate it if found. This is a fair behavior rule without many exceptions, I'm aware of. Although likely there are exceptions, considering the vast array of install types and Puppy versions.

The name it looks for is pupswap.swp, so if you make one with that name in the right location, I expect Puppy to activate it on its own.

3) if you make a file by another name or location, you will need to activate it, this is usually done by users in the file /etc/rc.d/rc.local with a command line this:

swapon /filelocation/file_name

peb
Posts: 18
Joined: Mon 24 Oct 2005, 20:28

#18 Post by peb »

I searched /etc/* and found these references to a swap file. Only one file /etc/rc.d/rc.sysint seemed to make any references to a swap file. Puppy 4.1.2 is the version I'm using. I'm running from a CDROM with a pupsave file on the harddisk.

FOUND
/etc/rc.d/rc.sysinit:155: swapon $ONESWAP
/etc/rc.d/rc.sysinit:157: [ $? -eq 0 ] && SWAPON="yes"

155-158 tries to find a linux swap partition and turn it on


================================================================
FOUND
/etc/rc.d/rc.sysinit:161:if [ "$SWAPON" != "yes" ];then
/etc/rc.d/rc.sysinit:166: swapon /initrd${PUP_HOME}${SWAPFILE}
/etc/rc.d/rc.sysinit:168: [ $? -eq 0 ] && SWAPON="yes"
/etc/rc.d/rc.sysinit:172: swapon $SWAPFILE
/etc/rc.d/rc.sysinit:174: [ $? -eq 0 ] && SWAPON="yes"

160-176 in rc.sysint:
#if no go, try for a swap file...
if [ "$SWAPON" != "yes" ];then
SWAPFILE="/pupswap.swp"
[ "$PSWAPFILE" ] && SWAPFILE="`echo -n "$PSWAPFILE" | cut -f 3 -d ','`" #/etc/rc.d/PUPSTATE
if [ -f /initrd${PUP_HOME}${SWAPFILE} ];then
echo -n "Loading swap file ${SWAPFILE}..." >/dev/console
swapon /initrd${PUP_HOME}${SWAPFILE}
status_func $?
[ $? -eq 0 ] && SWAPON="yes"
fi
if [ -f $SWAPFILE ];then
echo -n "Loading swap file ${SWAPFILE}..." >/dev/console
swapon $SWAPFILE
status_func $?
[ $? -eq 0 ] && SWAPON="yes"
fi
fi

From this it seems the only file it looks for is called pupsave.swp and the only place it looks is PUPHOME; and a swapfile is turned on if found, but not created.

On the other hand, there's this statement that is included in the above that I can't figure out. Why is it there or needed? Maybe someone can elaborate.

[ "$PSWAPFILE" ] && SWAPFILE="`echo -n "$PSWAPFILE" | cut -f 3 -d ','`"

So, my conclusion is that for 4.1.2 running from a CDROM or USB, Puppy does NOT create a swapfile automatically and does not look for use pagefile.sys or other Windows swapfile. (From my search, no files made reference to Windows swap files such as pagefile.sys.)

Correct conclusion?

User avatar
rjbrewer
Posts: 4405
Joined: Tue 22 Jan 2008, 21:41
Location: merriam, kansas

#19 Post by rjbrewer »

Puppy looks for the swap files or swap partition you may have
created.

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#20 Post by rcrsn51 »

This is interesting. I know that in previous versions (2.xx?) Puppy would automatically make a swap file. But I just checked in 4.00 and this feature is gone, as PaulBx1 stated above. Does anyone know when it first disappeared?

I suspect that BarryK's rationale for removing it goes like this:

Back when most users doing a coexist install were working with Win98 and FAT32, it was considered safe to make a swap file in the Windows partition. But as NTFS became the standard, there was concern about potential corruption when the swap file was created.

However, anyone installing Puppy into a separate partition must have already reworked their hard drive. So it would not be a problem for them to split off another partition for swap.

Was this another of those unilateral decisions made by the benevolent dictator? Still, swap files are handy and it might be nice to have an option in the Setup menu to create one.
Last edited by rcrsn51 on Fri 26 Dec 2008, 18:03, edited 1 time in total.

Post Reply