LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-20-2010, 01:27 PM   #1
uncle-c
Member
 
Registered: Oct 2006
Location: The Ether
Distribution: Lubuntu 14.04 LTS, Kali
Posts: 297

Rep: Reputation: 30
Possible "swap " concern ?


G'day.
I wanted to find out how much swap memory I was using, if any. The results of "free" and "top" showed zero swap usage.
Code:
unclec-$ free -m
             total       used       free     shared    buffers     cached
Mem:           493        484          9          0          7        152
-/+ buffers/cache:        323        169
Swap:            0          0          0
Swap usage is ZERO.

Code:
unclec~$ top

top - 17:19:50 up 20 min,  2 users,  load average: 0.03, 0.17, 0.23
Tasks: 108 total,   3 running, 105 sleeping,   0 stopped,   0 zombie
Cpu(s):  6.6%us,  1.3%sy,  0.0%ni, 92.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:    505592k total,   495368k used,    10224k free,     8068k buffers
Swap:        0k total,        0k used,        0k free,   155104k cached
Again swap usage is ZERO. Is this the norm in Linux. i.e. is swap only used when RAM is low and extra memory is required ?

Thanks.
 
Old 03-20-2010, 01:49 PM   #2
troop
Member
 
Registered: Feb 2010
Distribution: gentoo, arch, fedora, freebsd
Posts: 379

Rep: Reputation: 96
Quote:
Swap: 0k total
You have no swap at all...

Last edited by troop; 03-20-2010 at 01:59 PM.
 
Old 03-20-2010, 01:54 PM   #3
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,318

Rep: Reputation: 126Reputation: 126
Quote:
Originally Posted by uncle-c View Post
Again swap usage is ZERO. Is this the norm in Linux. i.e. is swap only used when RAM is low and extra memory is required ?

Thanks.
The use of swap almost always slows a system down, so it should be no surprise that swap is not used unless absolutely necessary.
 
Old 03-20-2010, 02:01 PM   #4
troop
Member
 
Registered: Feb 2010
Distribution: gentoo, arch, fedora, freebsd
Posts: 379

Rep: Reputation: 96
Quote:
The use of swap almost always slows a system down, so it should be no surprise that swap is not used unless absolutely necessary.
It's not quite true.
http://kerneltrap.org/node/3000
Quote:
You really don't want hundreds of megabytes of BloatyApp's untouched memory floating about in the machine. Get it out on the disk, use the memory for something useful.
swappiness is 60 by default.

Last edited by troop; 03-20-2010 at 02:02 PM.
 
Old 03-20-2010, 02:05 PM   #5
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,318

Rep: Reputation: 126Reputation: 126
I'm not gonna bite. The kerneltrap.org link has more than enough discussion.
 
Old 03-20-2010, 02:20 PM   #6
uncle-c
Member
 
Registered: Oct 2006
Location: The Ether
Distribution: Lubuntu 14.04 LTS, Kali
Posts: 297

Original Poster
Rep: Reputation: 30
Thanks for the info gents. There was an incorrect UUID entry in my /etc/fstab file hence the ZERO entries in top and free -m outputs.
 
Old 03-20-2010, 02:51 PM   #7
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,318

Rep: Reputation: 126Reputation: 126
I see that I totally misapprehended your post and am very red-faced. Congrats for fixing it, anyway!
 
Old 03-20-2010, 03:43 PM   #8
uncle-c
Member
 
Registered: Oct 2006
Location: The Ether
Distribution: Lubuntu 14.04 LTS, Kali
Posts: 297

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by Quakeboy02 View Post
I see that I totally misapprehended your post and am very red-faced. Congrats for fixing it, anyway!
No need to apologise. On the contrary, I had been using the system for so long without any swap I am now begining to wonder if it would be any use at all ! Reading your link has made some things clearer so thanks are in order.
 
Old 03-20-2010, 03:54 PM   #9
brucehinrichs
Member
 
Registered: Mar 2008
Location: US
Distribution: Debian Sid; Sabayon, UbuntuStudio, Slackware-multilib 13.1, Peppermint Ice, CentOS
Posts: 575

Rep: Reputation: 67
The amount of swap needed depends (among other things) how much RAM you have. The rule of thumb that I've seen most often is to create a swap partition that is twice your installed RAM. In a machine with 8GB of RAM, creating a swap of 16GB would be ridiculous imho because you most likely won't use up all of your RAM, and therefore won't use any swap. If your machine has 512k of RAM installed, you might mant to consider allocating more than 1GB of swap. How big of a swap partition you need depends mainly on how much RAM is installed, and how you use your machine.
 
Old 03-20-2010, 04:42 PM   #10
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,318

Rep: Reputation: 126Reputation: 126
Quote:
Originally Posted by uncle-c View Post
No need to apologise. On the contrary, I had been using the system for so long without any swap I am now begining to wonder if it would be any use at all ! Reading your link has made some things clearer so thanks are in order.
Yeah, troop's link is quite a good one; written by the guys who actually write the kernel code. As you've kinda figured out, swap serves no real purpose until you need it. I've just settled into recommending 1GB or so of swap for everyone. Those who need more will eventually understand that what they really need is more RAM.
 
Old 03-20-2010, 05:11 PM   #11
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190
Quote:
Originally Posted by uncle-c View Post
I had been using the system for so long without any swap I am now begining to wonder if it would be any use at all
It is very possible for use of swap space to make the system run faster in cases where you don't "need" swap space, meaning the things you are running won't flat out fail for lack of swap space.

The important fact is that most "swapping" is not from the swap space. I expect some argument about the word "swapping" there. But there is no better word for the practical meaning.

Most "swapping" is from read only mappings.

Swapping to/from swap space is inherently twice as expensive because it is to/from, while read only mappings are only from. So the Kernel is biased against the activity described by the narrower meaning of "swapping" (to/from swap space).

But actual access patterns vary by far more than two to one. So many disk accessed might be saved by each pair of disk accesses to swap something stale to/from swap space.

Quote:
Originally Posted by Quakeboy02 View Post
As you've kinda figured out, swap serves no real purpose until you need it.
Based on previous threads, I won't try to convince you otherwise. But I want to make sure the OP and others reading this thread know there is an opposing viewpoint on that.

Quote:
I've just settled into recommending 1GB or so of swap for everyone.
On one hand, that is as invalid as every other rule of thumb for swap size. If you don't know what will be run on the system you have no basis for estimating the appropriate amount of swap space. On the other hand, virtually no one knows enough about what they will run on their Linux system and how memory will be used to make an informed decision about swap space size. Your unsupported guess of 1GB is probably better than most guesses. (Small enough to usually not waste important disk space when it is too large; Big enough to give a decent chance of at least understanding the problem when it is too small and big enough to rarely be too small for ordinary home users of Linux).

Quote:
Those who need more will eventually understand that what they really need is more RAM.
Hopefully those who just need more swap space will figure that out too.

There really are cases where more swap space allows massive problems to be solved and only slightly slower than they could be solved with absurd and expensive amounts of ram. Swap space is a lot less expensive than ram. Most people don't need enough of either for the cost to be significant. But if you do need a lot it's worth figuring out which you need.

Last edited by johnsfine; 03-20-2010 at 05:25 PM.
 
Old 03-20-2010, 05:47 PM   #12
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,318

Rep: Reputation: 126Reputation: 126
Quote:
There really are cases where more swap space allows massive problems to be solved and only slightly slower than they could be solved with absurd and expensive amounts of ram.
I won't argue that, John, because I'm in absolute agreement with you. However, it's the .001% solution, and I just don't spend time on it. By this, I mean that only .001% (random number) of the people who ask about swap will be asking because they have one of these situations. Generally, there is some sort of hint in the question/post about this, and I will either change my response or leave it to you or one of the other, few, people here on LQ that has shown a more than casual understanding of swap in exceptional circumstances. Most people, in my personal observation, just want a checkbox number and a semi-basic understanding of what swap is and how much to use. Giving them a 5000 word dissertation serves no real purpose and probably confuses more than it educates.

But, that's my opinion.

Quote:
But if you do need a lot it's worth figuring out which you need.
Yes it is, but there is no simple metric of "X" amount of memory times some random value "Y" that will give you that. In such a case, you generally need to understand the problem before you can attempt a solution; i.e. deciding on the size of swap.

Cheers, John. I enjoy your posts and your help.

Last edited by Quakeboy02; 03-20-2010 at 05:51 PM.
 
Old 03-22-2010, 07:32 AM   #13
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,411

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
Redhat's take on this: http://kbase.redhat.com/faq/docs/DOC-15252
 
1 members found this post helpful.
Old 03-22-2010, 01:27 PM   #14
uncle-c
Member
 
Registered: Oct 2006
Location: The Ether
Distribution: Lubuntu 14.04 LTS, Kali
Posts: 297

Original Poster
Rep: Reputation: 30
Gents,
The system involved only has 512 MB RAM and uses the lightweight Fluxbox as WM. To be honest since I added the swap I haven't noticed an iota of difference in speed or performance.
 
Old 03-22-2010, 08:29 PM   #15
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,411

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
For a relatively low amt of RAM like that, swap would be handy if you start using the machine relatively heavily; you could run out of RAM. Its not a performance issue (speed/throughput) for you, its a capacity issue.
 
  


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
swap file instead of swap disk "dd" error rezwits Linux - Newbie 5 12-16-2007 01:34 AM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 11:18 PM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 09:31 AM
Update For Post Install Hang On "enabling Swap" Briska_69 Fedora 0 09-06-2004 10:36 AM
Mandrake 10.0 Laptop Won't Boot Past "Activating Swap Partitions"? Aaron Josephson Linux - Software 0 06-26-2004 09:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:45 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration