LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-12-2013, 01:30 PM   #1
NeXuS_2006
Member
 
Registered: Dec 2003
Distribution: Fedora
Posts: 64

Rep: Reputation: 18
Get by without swap space?


Hey all. I've been tweaking my Mint install lately, and am wondering if it is possible or advisable to get by without any swap for the kernel, no file, no partition, nothing. The swap doesn't seem very useful, right now I have 6GB ram, with 283MB free, but if you consider the 3180MB used by disk caching as "free" also, I have a lot of extra ram. The swap partition is only 1GB, and only has 131MB used, this is with a week of uptime and use of a lot of apps (I have about a dozen open ATM, including a virtualMachine with 1GB reserved for the VM). All the tutorials I have read seem to be old. I found one that said you should make a swap space at least double your ram, or even as large as 1GB (lol).

So, what is the worst case scenario?

Last edited by NeXuS_2006; 09-12-2013 at 01:32 PM.
 
Old 09-12-2013, 01:36 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
The worst case scenario is that you run out of RAM and the oom_killer starts to kill your processes.
The worst case scenario when using a 1GB swap-space is that you have lost 1GB of space on your disk, something I would consider negligible in times with TB disks.
 
Old 09-12-2013, 01:37 PM   #3
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
One use of swap on a system like yours is as a minor performance enhancement. A little stale anonymous data has been swapped out (as you reported) allowing slightly more ram to be used for cache, probably avoiding a few disk I/Os and making your system a trivial amount faster.

A second use of swap is as insurance against unexpected activity. If you use far more ram than expected, you would like that to merely slow down your system, rather than make the OOM killer destroy one or more processes.

The first effect is likely too small to measure and the second may be very unlikely (in your case). So the benefit of swap is likely small. But the cost is probably also small. How big is your hard drive and how full? If it is near full, you ought to get another or bigger hard drive and the proportional cost of a few GB of swap within that hard drive is trivial. If your hard drive is not near full then the space saved by not having swap has no value.

The old idea of "double ram" never made any sense back when it was commonly accepted. It makes less sense now. I think 2GB is a good size for swap on an ordinary home system. 2GB is a good swap size if you have 0.5GB of ram and 2GB is a good swap size if you have 32GB of ram. Your current 1GB of swap isn't bad either. 2GB is just my personal guess.

It is possible for you to get by with zero swap. Most likely, that would never cause a serious problem. Most likely the slow down from less caching would not be noticeable. But I still don't advise it, mainly because disk space is very inexpensive.

If you happened to have an old hard drive under 200GB and it is 80% to 90% full, you might factor in the inconvenience of installing a new hard drive with the performance problems of running too near a full filesystem, and decide to rationally overvalue a GB or two of space that might otherwise be swap. But if your drive is over 90% full, just get a real hard drive. If it is under 80% full, don't worry about a couple GB of swap space.

Last edited by johnsfine; 09-12-2013 at 01:50 PM.
 
Old 09-12-2013, 01:42 PM   #4
snowday
Senior Member
 
Registered: Feb 2009
Posts: 4,667

Rep: Reputation: 1411Reputation: 1411Reputation: 1411Reputation: 1411Reputation: 1411Reputation: 1411Reputation: 1411Reputation: 1411Reputation: 1411Reputation: 1411
Swap is strictly optional.

It is only required if either a) you wish to hibernate-to-disk, or b) you don't have enough RAM to perform the required tasks.
 
Old 09-12-2013, 07:41 PM   #5
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,978

Rep: Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624
Maybe a modified version, "Swap is strictly optional." if you have enough ram. (actually snowpine said that)

Some apps stubbornly use swap still even if not needed. Even hard to flush it sometimes.

Knowing your needs is the only choice you have to decide if you need swap. A common desktop user may never need swap with 6 or more G ram. It would be easy for a power user or server to crash on that.

Last edited by jefro; 09-15-2013 at 08:14 PM.
 
Old 09-12-2013, 09:14 PM   #6
NeXuS_2006
Member
 
Registered: Dec 2003
Distribution: Fedora
Posts: 64

Original Poster
Rep: Reputation: 18
Quote:
Originally Posted by jefro View Post
Maybe a modified version, "Swap is strictly optional." if you have enough ram.

Some apps stubbornly use swap still even if not needed. Even hard to flush it sometimes.

Knowing your needs is the only choice you have to decide if you need swap. A common desktop user may never need swap with 6 or more G ram. It would be easy for a power user or server to crash on that.
Thanks for the clarification. I understood that if you ran out of physical memory and have no swap, it is the same result as running out of physical memory and swap, which at 6Gb v 7Gb, is a 17% difference, not a whole lot.

I suppose I'll leave it as is, as pointed out swap space takes so few resources for the potential, albeit rare, headache. Thanks for the great discussion.
 
Old 09-13-2013, 03:58 AM   #7
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Quote:
Originally Posted by TobiSGD View Post
The worst case scenario is that you run out of RAM and the oom_killer starts to kill your processes.
The worst case scenario when using a 1GB swap-space is that you have lost 1GB of space on your disk, something I would consider negligible in times with TB disks.
If you run out of RAM without swap, indeed the OOM killer starts killing processes hogging the RAM. It may also kill more innocent processes.

If you run out of RAM with swap, your computer will slow to a crawl and it will take you 10 - 20 min to kill the offending app.

I prefer the former, and I only have 2GB of RAM and I have only run out two or three times due to a leaky program.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What if tmpfs space is full? Written to swap space? pstein Linux - Newbie 8 11-18-2012 06:51 AM
how to reduce swap space and reclaim the space grantm Linux - Newbie 7 08-16-2012 07:05 AM
[SOLVED] what the difference swap space and swap file dundu Linux - Newbie 4 07-29-2012 12:03 PM
how much swap space is needed; how to increase swap space? johnpaulodonnell Linux - Newbie 5 03-23-2007 03:20 AM
How to unmount actual swap and mount a new(bigger) swap space? isaac Linux - Newbie 1 06-06-2004 01:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:16 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
Open Source Consulting | Domain Registration