Understanding swap partitions - SOLVED!

Booting, installing, newbie
Message
Author
VictorVictor5
Posts: 131
Joined: Thu 24 May 2012, 02:52

Understanding swap partitions - SOLVED!

#1 Post by VictorVictor5 »

Greetings everyone,

Ok, after going back and reading the help notes, I want to see if I'm on the right track with swap partitions. Please correct me if I'm wrong.

A swap partition is basically "emergency RAM" that can help out out systems when running programs. A general rule of thumb is 2 x RAM, so in my case 384 MB x 2 = 768 MB partition for swap partition (so in essence it will give me 1 GB memory - 768 MB swap + 384 onboard RAM).

The swap partition should be formatted ext2.

Am I way off here?

Thanks!
VV5
Last edited by VictorVictor5 on Thu 17 Jan 2013, 02:58, edited 1 time in total.

bark_bark_bark
Posts: 1885
Joined: Tue 05 Jun 2012, 12:17
Location: Wisconsin USA

#2 Post by bark_bark_bark »

there is a special type of format for swaps partitions. But don't use a swap on:

-a Flash Memory Card (SD, MicroSD, CompactFlash, etc.)
-USB thumb drive
-Solid State Drives
....

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

#3 Post by Flash »

As I understand a swap partition, it has no specified or defined filesystem, so it is not formatted in the usual sense of the word. It is just.....swap. Virtual memory. Puppy uses it if it runs out of RAM, which is unlikely with 384 MB of RAM unless you watch video or do things with very large files such as image files. In any case, if you can add more RAM to the computer, I highly recommend that you do it.

User avatar
James C
Posts: 6618
Joined: Thu 26 Mar 2009, 05:12
Location: Kentucky

#4 Post by James C »

Might help...
http://ubuntuforums.org/showthread.php?t=1369433

A hint...... one of the options in GParted is "linux-swap".

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#5 Post by amigo »

The partition type should be '82'. Linux partitions meant for filesystems are type '83'. As Flash sort of points out, they need not be formatted with any filesystem at all. Instead of being formatted as a filesystem, they are formatted as swap space using the 'mkswap' command -which basically just divides the partition into 4K 'pages'.

VictorVictor5
Posts: 131
Joined: Thu 24 May 2012, 02:52

#6 Post by VictorVictor5 »

Cool - thanks everyone for their feedback.

James C - saw what you were talking about in GParted. Just went that way.

Thanks!
VV5

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#7 Post by jpeps »

Flash wrote: Puppy uses it if it runs out of RAM, which is unlikely with 384 MB of RAM unless you watch video or do things with very large files such as image files.
wrong....maybe 2gigs and over, but you'll be using it all the time to initialize programs, etc, with 384 MB.

capicoso
Posts: 172
Joined: Fri 13 Jan 2012, 23:38
Location: Argentina

#8 Post by capicoso »

jpeps wrote:
Flash wrote: Puppy uses it if it runs out of RAM, which is unlikely with 384 MB of RAM unless you watch video or do things with very large files such as image files.
wrong....maybe 2gigs and over, but you'll be using it all the time to initialize programs, etc, with 384 MB.
In a 32bit puppy i could never break 1gb ram. I do lot of audio work, lots of programs running at the same time with jack, also some video.
On a 64bit yes, i'm at >1gb easily

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

#9 Post by Flash »

For over 5 years I've run various Puppys exclusively from multisession DVDs. Currently my computer has 4 GB of RAM, but for the first few years after I started using Puppy my computer had first 256 MB then 512 MB of RAM, and no hard disk drive, thus no swap memory. Puppy never ran out of RAM in that computer except once, when I tried to install OpenOffice. That's what I based my statement on.
bark_bark_bark wrote:there is a special type of format for swaps partitions. But don't use a swap on:

-a Flash Memory Card (SD, MicroSD, CompactFlash, etc.)
-USB thumb drive
-Solid State Drives
Actually using flash memory for swap is reported to work well. Even Windows uses it. :lol:
Flash drive controllers spread the writes around so that the "wear" is not concentrated in one area. Writing to a flash memory is what "wears" it out, but it takes 100,000 to 1,000,000 writes before errors begin to creep in. That would be many years for most applications. Even then, error correction codes are used so that no data is lost as long as only a few errors occur.

Dewbie

#10 Post by Dewbie »

Flash wrote:
Puppy never ran out of RAM in that computer except once
I run a range of Puppies, from 4.1.2 to Wary 5.2.2.
Max RAM usage with this setup is about 317MB, regardless of version.
(Specs: PII / 350MHz / 320MB RAM / 267MB swap)

User avatar
RetroTechGuy
Posts: 2947
Joined: Tue 15 Dec 2009, 17:20
Location: USA

#11 Post by RetroTechGuy »

jpeps wrote:
Flash wrote: Puppy uses it if it runs out of RAM, which is unlikely with 384 MB of RAM unless you watch video or do things with very large files such as image files.
wrong....maybe 2gigs and over, but you'll be using it all the time to initialize programs, etc, with 384 MB.
I find that Firefox regularly leaks all over my RAM, eating all of my 1GB RAM (I should note that my machine with 2GB doesn't seem to do that).
[url=http://murga-linux.com/puppy/viewtopic.php?t=58615]Add swapfile[/url]
[url=http://wellminded.net63.net/]WellMinded Search[/url]
[url=http://puppylinux.us/psearch.html]PuppyLinux.US Search[/url]

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#12 Post by jpeps »

RetroTechGuy wrote:
I find that Firefox regularly leaks all over my RAM, eating all of my 1GB RAM (I should note that my machine with 2GB doesn't seem to do that).
Noticed this link; might be worth a try

http://support.mozilla.org/en-US/questions/939920

User avatar
RetroTechGuy
Posts: 2947
Joined: Tue 15 Dec 2009, 17:20
Location: USA

#13 Post by RetroTechGuy »

jpeps wrote:
RetroTechGuy wrote:
I find that Firefox regularly leaks all over my RAM, eating all of my 1GB RAM (I should note that my machine with 2GB doesn't seem to do that).
Noticed this link; might be worth a try

http://support.mozilla.org/en-US/questions/939920
Thanks, I look into that.

I've been using a script to clean the RAM cache (I think that Bruce wrote the functional piece -- I like to monitor it's action). Whenever FF starts acting goofy, I run it a couple times...

Code: Select all

clear
echo " Initial free space"
free
echo ""
echo " clearing cache"
sync && echo 3 > /proc/sys/vm/drop_caches
echo ""
echo " Final free space"
free
[url=http://murga-linux.com/puppy/viewtopic.php?t=58615]Add swapfile[/url]
[url=http://wellminded.net63.net/]WellMinded Search[/url]
[url=http://puppylinux.us/psearch.html]PuppyLinux.US Search[/url]

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#14 Post by jpeps »

RetroTechGuy wrote:
I've been using a script to clean the RAM cache (I think that Bruce wrote the functional piece -- I like to monitor it's action). Whenever FF starts acting goofy, I run it a couple times...

Code: Select all

clear
echo " Initial free space"
free
echo ""
echo " clearing cache"
sync && echo 3 > /proc/sys/vm/drop_caches
echo ""
echo " Final free space"
free
That probably won't do it. Run a search on caches in /root and everything is still there. Try RamBack and Memory Restart...you can monitor and clear it easily.

User avatar
RetroTechGuy
Posts: 2947
Joined: Tue 15 Dec 2009, 17:20
Location: USA

#15 Post by RetroTechGuy »

jpeps wrote:
RetroTechGuy wrote:
I've been using a script to clean the RAM cache (I think that Bruce wrote the functional piece -- I like to monitor it's action). Whenever FF starts acting goofy, I run it a couple times...

Code: Select all

clear
echo " Initial free space"
free
echo ""
echo " clearing cache"
sync && echo 3 > /proc/sys/vm/drop_caches
echo ""
echo " Final free space"
free
That probably won't do it. Run a search on caches in /root and everything is still there. Try RamBack and Memory Restart...you can monitor and clear it easily.
Actually, that does drive the crud out of the RAM (which is the problem). FF (or something related to FF) loads up the RAM to just under 1GB, that operation will usually push the used RAM down to 3-400 MB.

I added in some of the tools you recommended, and it seems to behave a little better. Still effectively overflowed once (the one widget shows RAM usage -- and that time it was at 600MB), but I was pushing it pretty hard (lots of open tabs).

Once place where it regularly clogs up is Facebook (and it will generally load up there, with only 1 or 2 tabs open -- I'll see how the add-ons help).

For reference, I just opened FF, and went straight into Murga. I have 2 tabs open, and the FF monitoring plug-in is showing between 140 and 150 MB used for FF.

That behavior really cramps a low RAM machine.

Edit: Now that's interesting. The FF monitoring too is showing 140MB, but top shows VSZ as 448M (47% of RAM).

I'll have to do some reading to see what the monitoring tool is tracking...
[url=http://murga-linux.com/puppy/viewtopic.php?t=58615]Add swapfile[/url]
[url=http://wellminded.net63.net/]WellMinded Search[/url]
[url=http://puppylinux.us/psearch.html]PuppyLinux.US Search[/url]

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#16 Post by jpeps »

After testing it to the max...the memory restart restored the CPU functioning. Not having to reboot the OS is all I care about. To get a freeze wasn't easy...25 tabs, several videos..over an hour of u tubes. That's about all I can ask for on an old dell with 1gig RAM. (the main issue has always been CPU...and is more related to flash than FF).

edit: right now I'm running 70 java jars and FF with 10 tabs, and had no problem running a utube video despite a long load time. Another tab opened right up for writing this response....nothing bogging down. All because of swap..176M being used. Remember the myth about java using too much ram?

Next, I turned off my swap file, ran about 20 jars and tried to load FF. FF wouldn't load, and the computer froze, requiring a reboot. That should quell the swap dispute. It's all about ram management, which the kernel handles very well if you give it the right tools.

User avatar
RetroTechGuy
Posts: 2947
Joined: Tue 15 Dec 2009, 17:20
Location: USA

#17 Post by RetroTechGuy »

jpeps wrote:After testing it to the max...the memory restart restored the CPU functioning. Not having to reboot the OS is all I care about. To get a freeze wasn't easy...25 tabs, several videos..over an hour of u tubes. That's about all I can ask for on an old dell with 1gig RAM. (the main issue has always been CPU...and is more related to flash than FF).

edit: right now I'm running 70 java jars and FF with 10 tabs, and had no problem running a utube video despite a long load time. Another tab opened right up for writing this response....nothing bogging down. All because of swap..176M being used. Remember the myth about java using too much ram?

Next, I turned off my swap file, ran about 20 jars and tried to load FF. FF wouldn't load, and the computer froze, requiring a reboot. That should quell the swap dispute. It's all about ram management, which the kernel handles very well if you give it the right tools.
I've noticed that when FF (or some accessory for FF) eats the majority of the RAM, that Youtube videos will no longer play. It will display the Youtube page, but just a black box where the video goes.

A RAM purge (using the script references earlier), a refresh of the screen will restore playing.

No, I haven't had FF crash the OS yet. I have had it bog things down to the point where I thought I might have to crash it to get out... Once in a great while, I've had trouble opening a terminal in order to run my script.

Typically I can get just purge the RAM, and close FF gracefully.

Oh, regarding swap... I have a 1.2 GB swap on this machine. It doesn't very often dig into the swap -- it seems that FF only likes RAM...I don't see it overflowing into the swap partition.
[url=http://murga-linux.com/puppy/viewtopic.php?t=58615]Add swapfile[/url]
[url=http://wellminded.net63.net/]WellMinded Search[/url]
[url=http://puppylinux.us/psearch.html]PuppyLinux.US Search[/url]

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#18 Post by jpeps »

RetroTechGuy wrote:
A RAM purge (using the script references earlier), a refresh of the screen will restore playing.

No, I haven't had FF crash the OS yet. I have had it bog things down to the point where I thought I might have to crash it to get out... Once in a great while, I've had trouble opening a terminal in order to run my script.

Typically I can get just purge the RAM, and close FF gracefully.

The script purges the cache

Code: Select all

Mem: 676196K used, 358316K free, 0K shrd, 74116K buff, 288476K cached
Mem: 341576K used, 692936K free, 0K shrd, 3800K buff, 65044K cached
However, the computer remains just as bogged down, given the CPU usage is still too high (100%). In fact it's 10% higher than before I cleared the cache:

Code: Select all


18833  6729 root     R     619m  61%   0 100% /mnt/sda2/firefox/firefox

Now, if I hit the memory restart button, watch what happens :

Code: Select all


18833  6729 root     S     444m  44%   0   5% /mnt/sda2/firefox/firefox
Now, everything is running smoothly again.
Oh, regarding swap... I have a 1.2 GB swap on this machine. It doesn't very often dig into the swap -- it seems that FF only likes RAM...I don't see it overflowing into the swap partition.

I've notice that also. FF does it's own thing (i.e, wants all your active RAM). As noted above, however, swap will provide the RAM you need by getting it somewhere else.

I suspect there could also be some downsides to clearing the general cache vs just handling FF.

User avatar
RetroTechGuy
Posts: 2947
Joined: Tue 15 Dec 2009, 17:20
Location: USA

#19 Post by RetroTechGuy »

Weird, jpeps...

On my system, I just ran it:

Code: Select all

Initial free space
              total         used         free       shared      buffers
  Mem:       969868       821240       148628            0        30472
 Swap:      1228964         2388      1226576
Total:      2198832       823628      1375204

clearing cache

Final free space
              total         used         free       shared      buffers
  Mem:       969868       461860       508008            0         1080
 Swap:      1228964         2388      1226576
Total:      2198832       464248      1734584
At the moment, I do have FF and Thunderbird open. But it does a similar response with just FF running.
[url=http://murga-linux.com/puppy/viewtopic.php?t=58615]Add swapfile[/url]
[url=http://wellminded.net63.net/]WellMinded Search[/url]
[url=http://puppylinux.us/psearch.html]PuppyLinux.US Search[/url]

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#20 Post by jpeps »

Yes, similar to what I posted. Looks like you're using some swap as well. Check out info for the browser though, which includes CPU usage. I think the kernel will take what it needs from the cache anyway, so probably it's unnecessary to clean it ? It certainly doesn't restore resources the way restarting the browser does.

Post Reply