Click to See Complete Forum and Search --> : swap space/virtual memory on linux?


pickarooney
03-18-2005, 06:42 PM
How or where is this managed on a linux system, if at all? After tripling my RAM recently I've not noticed a great speed improvement when using heavier apps and wondered if I could tweak this somehow.

Hayl
03-18-2005, 06:47 PM
it uses any partitions of type swap that are in your fstab. you can also manually use the swapon and swapoff commands to turn a swap partition on or off. it's not dynamically allocated in most cases although you can make swap files instead of swap partitoins if desired. there is a daemon available to make swap files on the fly when they are needed (basically to protect from runing out of ram).

it (linux) only uses swap if it needs it.

i.e. if you have 2 GB RAM or some other huge amount it's likely that Linux will never use or need swap.

so to answer your question; no - tweaking your swap won't help unless you have a box with a really small amt of ram which I assume you don't because you said you added a lot more ram.

retsaw
03-18-2005, 07:00 PM
You can change the value of /proc/sys/vm/swappiness to set how likely the kernel is to page memory out to swap. The higher the value the more likely it is to use swap, the default value is 60, 20 is probably a good value if you have lots of RAM. If you want more info on this try google, as this is about all I remember.

soulestream
03-18-2005, 07:31 PM
what is considered "alot" of RAM on on my boxes has 768 megs. If im not gaming or video editing could I just swapoff


soule

retsaw
03-18-2005, 08:05 PM
I would consider that a lot, you wouldn't have any problem running without swap. You may also want to consider mounting /tmp as a tmpfs filesystem (which is a RAM based filesystem) to speed things up, this can potentially cause problems (running out of space in /tmp) if you are likely to save large files to /tmp, but otherwise is fine and has the added advantage of automatically cleaning /tmp out on each reboot.

soulestream
03-18-2005, 08:42 PM
how safe is it to delete everything in /tmp regulary

like with a cron job



i delete tmp files in windows al the time,doing that in linux makes my a little nervous


soule

micro
03-18-2005, 09:00 PM
While in the console, I do not hesitate to clear temp as a user, knowing that according to privileges, restricted dir deletes will be denied.

But never clear the temp that way while KDE or another desktop is running, as it could cause too many problems.

If I wanted to clear the temp, I would put this in a script that handles the runlevels 0 and/or 6: rm -rf /tmp/* in this way /tmp itself would not be deleted.

But I wouldn't do this anyway.

For the swap now: Swap partition (1 or many) may exist. If you want to increase the swap size temporarily, there is no need to repartition. Swaps are handled like files and this is what we will create asap and without rebooting

As root:

cd /var
dd bs=1024 count=200 if=/dev/zero of=swap.swp
mkswap swap.swp
swapon swap.swp

This would add 200 mb swap.

retsaw
03-18-2005, 09:24 PM
Originally posted by soulestream
how safe is it to delete everything in /tmp regulary
You have to be careful, programs may be using the files that are in there, but you shouldn't have any files that persist across reboots.

pickarooney
03-19-2005, 05:53 AM
Thanks for the replies :)