LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Swap question (https://www.linuxquestions.org/questions/slackware-14/swap-question-342022/)

heraklez 07-10-2005 10:26 PM

Swap question
 
Hello, I have a question, when I installed Slackware on my machine, the installer requested me to make a swap partition and I have assigned 512 MB for swap partition. I have 256 MB of RAM.
I know that swap areas are used to temporarily hold data when RAM is currently used up. Could anybody explain me that better?
Now, how can I now that my system is using that area?
Is that area a special file system? If is so, can I mount it maybe on /mnt/swap_part?
Can I swap off? How? What would happen if I swap off? Will decrease the system perfomance?

Deltabweb 07-10-2005 11:08 PM

Re: Swap question
 
Quote:

Originally posted by heraklez
I know that swap areas are used to temporarily hold data when RAM is currently used up. Could anybody explain me that better?
Now, how can I now that my system is using that area?
Is that area a special file system? If is so, can I mount it maybe on /mnt/swap_part?
Can I swap off? How? What would happen if I swap off? Will decrease the system perfomance?

Often Swap is used when you don't have anymore free space in your ram
To know if it's using it just make ctrl+echap, in the status bar of the window that popups, there's the usage and free space of the swap, if it says 0KB free, your swap isnt setup correctly. And you can also see if its used.
Yep the filesystem is called linux swap you need to make a new partition for it. You don't mount it in a folder it's mounted as swap. To mount it use :
Code:

mount -t swap /dev/xxx swap
As you see with this command filesystem is swap and where you mount it isnt something like /mnt/swap but swap
Yep you can swap off by deleting the line concerning your swap partition in /etc/fstab
If you have a performance hit depends on your system and what you do with it. If you have 512 MB of memory, it should be ok to swap off if you don't play games nor use applications that uses lot of memory. Though you shouldn't turn it off cos you will perhaps have a performance drop anyway. I dunno for linux but I know that on windoze, experts doesn't agree about the swap size, but they all agree that you need one.
I have 1024 MB of DDR and I can run my computer without swap on linux. The swap file is used only when I play UT2004 though there's still like 200 MB of free DDR.

detpenguin 07-11-2005 12:26 AM

i have 512mb of ram, and i've yet to touch my swap partition...unless you're doing something graphically intense, such as deltabweb pointed out, gaming and such, you probably won't ever use your swap...and on newer pc's with larger harddrives (40gigs and up) you won't really miss the 512mb's you have dedicated to swap, and it won't affect performance...

maginotjr 07-11-2005 12:43 AM

just keep it there. 256mb of ram its better do not swap off.

And you probably will not need to mount it, if you check the fstab file you may see that the swap partition is already right seted by the system.

:D

ledow 07-11-2005 06:49 AM

For a better explanation:

I believe that swap is not just used like it was in early windows versions - as extra very-slow RAM. In Linux, swap is used as extra RAM in an emergency and also as a back-burner for areas of RAM that are not used very often.

Say you have apache (a large, memory-hungry program) loaded on your system serving webpages, but only for your own internal use. Say it has to actually answer a request once a week. The rest of the time it is sitting in your really-fast RAM chip doing nothing.

Linux detects situations like this and uses it's brain - why not put apache into slow swap so that we don't have it sitting around taking up a much more precious resource when it is hardly making any use of it. Much better to put apache into your swap area and use the really fast RAM that this frees up for applications that are actually going to make use of it, even if it's only to cache/buffer that to-do list that you have on the computer that you open every two seconds.

It's much more sensible to have the quick availability of a common-used program/file than it is to use all your fast RAM to speed up a never-used program and then have to run that commonly-used program from swap.

Of course, when you DO request that page from apache, it is moved from swap into whatever available RAM you have, to speed up it's execution. To do this, Linux might well move another program from RAM into swap to free up some space to allow it to work.

This is how Linux and modern Windows versions work, I believe. As a fallback, though, you don't want a program crashing and burning just because it allocated 513Mb when you only have 512Mb. In those cases, swap is used as just extra RAM but Linux still does it's best to find the least-accessed megabyte of that 513 and put that into swap, to keep the computer running as fast as possible.

As an aside, I have 512Mb RAM but I only use a 100Mb swapfile. I never have problems but having the swap around can actually speed up the computer when I load large programs as the rarely-used services are swapped out of main RAM leaving the power-hungry applications the full use of my PC3200-DDR.

heraklez 07-11-2005 12:29 PM

thank you very much.
This data is very interesting.

Basel 07-12-2005 06:40 AM

What should be the swap size if you have 1024 RAM?

maginotjr 07-12-2005 08:41 AM

if I remember right, they said that if you have more them 512mb of ram you dont need a swap space .... and if Im well remembered it cant (not recommened) be over 512mb ( or 1024) something like that...

Deltabweb 07-12-2005 04:27 PM

I have 1024 and I have a swap partition of 2048 but it's too much (too lazy to resize it)
With 1024 you don't need a swap partition if you don't use memory hungry programs (3D games, The GIMP with huge images, ...)
If you want to have one (which is recommended in windows though i dunno in linux) 512 or 256 MB should be good.

-=Graz=- 02-14-2006 05:42 AM

for some reason my swap space has dissappeared , im unsure why...

i checked FSTAB and it lists:
/dev/hda7 swap swap defaults 0 0

If i re-run the slack 10.1 install and select the 'setup swap' section ... it also picks hda7 as suitabl for swap space... i have tried formatting it (with the setup program) an then running through the installer (only installing the 'games') and then
Picking to Update FSTAB
No format of /dev/hda6 (primary linux part)
etc etc... says setup complete and upon reboot i still got no swap

I type:
mount -t swap /dev/hda7 swap
and i get:
mount: mount point swap does not exist

what am i doing wrong here?? ;)
I also have a mount for /SYS (which i dont remmeber being there before)

Running Slack 10.1 - w.kernel 2.6.15
on dell700m laptop /PentiumM.1.8 / 1024MB DDR and 80GB hdd

Thanx
Graz

syg00 02-14-2006 06:27 AM

"swapon -s" will tell you if swap is being used. dmesg should have some relevant messages as well.

You don't mount swap as per a normal partition.
"mkswap /dev/hda7" will format it.
"swapon /dev/hda7" will activate it.

If you aren't getting it activated at system start, try changing the fstab entry to;
/dev/hda7 none swap sw 0 0

chrisortiz 02-14-2006 07:06 PM

as far as seeing if it is in use type "top" use "ctrl c" to quit

-=Graz=- 02-15-2006 04:46 AM

HI Guys,
Thanks for the responses... this is now resolved.
I used:
swapon /dev/hda7" will activate it.
which has done the trick.

Also, that TOP command is great... seems my swap space does not ever get used anyway. i guess the 1GB of ram crunches
2 x 512MB as well

Thanks again

munichtexan 07-30-2006 02:50 PM

Ok, I have done a very stupid thing and now I can not boot on my linux partition. I had set up a 8 GB swapfile for numerically intensive software with the following commands:

dd if=/dev/zero of=swapfile bs=1024 count=1000000000
/sbin/mkswap swapfile

This worked fine, but in the process of doing some work I ran into a situation where the 1 GB plus 8 GB swap file was not sufficient. (In reality, I am not sure I was using the full 8 GB swapfile to begin with) So I thought an easy fix was the following:

dd if=/dev/zero of=swapfile bs=1024 count=2000000000
/sbin/mkswap swapfile

which gave me a 48 GB swapfile. Not thinking I went to my Windows partition to use my Skype internet phone and in trying to reboot onto Linux I am not able to access. Using my OpenSuse 10.0 install disk I attempted to "update" my Linux and it tells me that in the /etc/fstab setup the device hda3 is not properly setup. It appears that I do not have enough disk space or memory left.

I have some files and data that I would like to save on the Linux partition that had not been backed up. I have enough knowledge to be dangerous and this is an at home setup. Any help would be appreciated.

update: Moved into the text only mode of the linux boot and removed the swapfile because my error was associated with not enough hard drive space for the KDE. Interesting, did not realize KDE needed access to the hard drive, thought it was entirely enclosed in internal ram.


All times are GMT -5. The time now is 10:48 PM.