LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices



Reply
 
Search this Thread
Old 07-10-2005, 11:26 PM   #1
heraklez
LQ Newbie
 
Registered: May 2005
Location: Peru
Distribution: Slackware
Posts: 26

Rep: Reputation: 15
Question 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?
 
Old 07-11-2005, 12:08 AM   #2
Deltabweb
LQ Newbie
 
Registered: Jul 2005
Distribution: Suse 10.0 x86_64
Posts: 21

Rep: Reputation: 15
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.
 
Old 07-11-2005, 01:26 AM   #3
detpenguin
Senior Member
 
Registered: Oct 2003
Location: lost in the midwest...
Distribution: Slackware
Posts: 1,091

Rep: Reputation: 45
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...
 
Old 07-11-2005, 01:43 AM   #4
maginotjr
Member
 
Registered: Aug 2004
Location: BR - Floripa
Distribution: Ubuntu 9.10 - 2.6.x.x
Posts: 661

Rep: Reputation: 34
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.

 
Old 07-11-2005, 07:49 AM   #5
ledow
Member
 
Registered: Apr 2005
Location: UK
Distribution: Slackware 13.0
Posts: 241

Rep: Reputation: 34
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.
 
Old 07-11-2005, 01:29 PM   #6
heraklez
LQ Newbie
 
Registered: May 2005
Location: Peru
Distribution: Slackware
Posts: 26

Original Poster
Rep: Reputation: 15
Smile

thank you very much.
This data is very interesting.
 
Old 07-12-2005, 07:40 AM   #7
Basel
Member
 
Registered: Feb 2004
Location: United States
Distribution: Ubuntu 10.10
Posts: 319

Rep: Reputation: 30
What should be the swap size if you have 1024 RAM?
 
Old 07-12-2005, 09:41 AM   #8
maginotjr
Member
 
Registered: Aug 2004
Location: BR - Floripa
Distribution: Ubuntu 9.10 - 2.6.x.x
Posts: 661

Rep: Reputation: 34
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...
 
Old 07-12-2005, 05:27 PM   #9
Deltabweb
LQ Newbie
 
Registered: Jul 2005
Distribution: Suse 10.0 x86_64
Posts: 21

Rep: Reputation: 15
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.
 
Old 02-14-2006, 06:42 AM   #10
-=Graz=-
Member
 
Registered: Jan 2006
Location: Australia
Distribution: Fedora, Slackware, RHEL, AIX, HP-UX
Posts: 356

Rep: Reputation: 31
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
 
Old 02-14-2006, 07:27 AM   #11
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,504

Rep: Reputation: 1078Reputation: 1078Reputation: 1078Reputation: 1078Reputation: 1078Reputation: 1078Reputation: 1078Reputation: 1078
"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
 
Old 02-14-2006, 08:06 PM   #12
chrisortiz
Member
 
Registered: Nov 2005
Distribution: Slackware, and of course the super delux uber knoppix universal live recovery cd
Posts: 429

Rep: Reputation: 30
as far as seeing if it is in use type "top" use "ctrl c" to quit
 
Old 02-15-2006, 05:46 AM   #13
-=Graz=-
Member
 
Registered: Jan 2006
Location: Australia
Distribution: Fedora, Slackware, RHEL, AIX, HP-UX
Posts: 356

Rep: Reputation: 31
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
 
Old 07-30-2006, 03:50 PM   #14
munichtexan
Member
 
Registered: Oct 2005
Posts: 74

Rep: Reputation: 15
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.

Last edited by munichtexan; 07-30-2006 at 04:30 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question about swap what0101 Linux - Newbie 3 09-19-2005 03:52 PM
Mount question and hot swap question Dr Gutiemouth Linux - Newbie 8 10-20-2004 01:30 PM
Swap Question powerismine Slackware 3 05-09-2003 01:40 AM
Swap question SchoolITguy Linux - General 6 12-04-2002 10:25 AM
Swap Question wonderpun Linux - General 3 09-08-2002 05:58 AM


All times are GMT -5. The time now is 01:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration