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 10-30-2008, 07:27 AM   #1
umwai
Member
 
Registered: May 2008
Location: Sri Lanka
Distribution: Ubuntu
Posts: 57
Blog Entries: 1

Rep: Reputation: 16
Question How much swap


If I have 3GB RAM do I need to have 6GB Swap. Is it really necessary.what is the purpose of having swap.
 
Old 10-30-2008, 08:02 AM   #2
womd
Member
 
Registered: Sep 2005
Location: Austria
Posts: 35

Rep: Reputation: 15
google is your friend

Quote:
Originally Posted by umwai View Post
If I have 3GB RAM do I need to have 6GB Swap. Is it really necessary.what is the purpose of having swap.
.. with this amout of ram you could have no swap at all ... but i think you could afford to give it about 2GB ...

depends on how / what you do with your system ...

swap info:

http://lissot.net/partition/partition-04.html
 
Old 10-30-2008, 08:25 AM   #3
jlarson
LQ Newbie
 
Registered: Oct 2008
Posts: 6

Rep: Reputation: 0
Swap

Swap is virtual RAM. If you are running a program and your RAM is full, then the data the program would normally store in RAM will be written to the swap partition.

3GB is a pretty large amount of RAM. Depending on your usage of the system, you may not need swap. I would recommend doing at least 1 to 2GB unless you really need to save that space on your hard disk.

The general guideline of 2x the size of your RAM can make sense when you have a smaller amount of RAM, but when you get over 1GB RAM there isn't much point in doing 2x.

I have 2GB of RAM on my laptop, and I rarely, if ever, hit swap.
 
Old 10-30-2008, 08:29 AM   #4
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,117
Blog Entries: 2

Rep: Reputation: 113Reputation: 113
If you are doing suspends or hibernates (never can recall which) then you need to have more swap then you do memory because it'll suspend/hibernate to the swap area. Otherwise it really depends on how you are using the system.
 
Old 10-30-2008, 08:36 AM   #5
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 61
These days, with plenty of RAM available, the amount of SWAP you need is just the amount needed for getting Suspend-to-disk (usually = to-swap) working, if you intend to use this feature. For security in case of exceptionnal workload, I wouldn't go under 512MB.

Yves.
 
Old 10-30-2008, 09:17 AM   #6
anupamsr
Member
 
Registered: Sep 2004
Location: India
Distribution: Kubuntu, Archlinux, Suse, Gentoo, Mandrake
Posts: 370

Rep: Reputation: 30
I have 1 GB ram and 1 GB swap space. I always hibernate to swap, and I have yet to reach swap limit otherwise, after around 4 months of use.
 
Old 10-30-2008, 09:22 AM   #7
bitpicker
Member
 
Registered: Jul 2003
Location: Germany
Distribution: Xubuntu, Ubuntu
Posts: 416
Blog Entries: 14

Rep: Reputation: 35
The rule 'Swap = RAM x 2' which underlies the original question is a stupid myth from the dark ages of computers with 8 MB RAM for text processing and 16 MB (yay!) for what passed as multimedia back then.

I have a system with only 768 MB of RAM which rarely ever uses even one MB of the 996 MB of swap I have set up. With 3 GB I'd not bother with swap at all. Depends on what the system is supposed to do of course.

Robin
 
Old 10-30-2008, 09:53 AM   #8
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287
The maximum amount of swap would be 2xRAM, but normally 1xRAM is enough. For me I have 2 GB RAM, 2 GB swap, but just a few days ago opening some large image files used up almost all the RAM and swap, so it really depends on what you do with your system.
 
Old 10-30-2008, 11:55 AM   #9
Cichlid
Member
 
Registered: Jan 2002
Location: Montreal
Distribution: Ubuntu 8.10
Posts: 178

Rep: Reputation: 30
How can you measure how much of your swap you are using at any given time?
 
Old 10-30-2008, 12:12 PM   #10
bitpicker
Member
 
Registered: Jul 2003
Location: Germany
Distribution: Xubuntu, Ubuntu
Posts: 416
Blog Entries: 14

Rep: Reputation: 35
I'm running gkrellm and it shows me that I'm not using any swap.

In a terminal you can use the command top.

This is part of its output:

Code:
Mem:    775852k total,   481000k used,   294852k free,    24684k buffers
Swap:  1020116k total,        0k used,  1020116k free,   196848k cached
 
Old 10-30-2008, 01:36 PM   #11
lazlow
Senior Member
 
Registered: Jan 2006
Posts: 4,362

Rep: Reputation: 172Reputation: 172
The amount of swap needed is determined by what you are doing on the machine. I have a mcahine with 2 gigs of ram and four of swap, in some situations I have used 2/3 of that swap. However I would not consider my use of that particular system as "typical". When you consider that a 320gig drive is well under $70 now is it really costing you that much to follow the worst case rule of 2X ram?
 
Old 10-30-2008, 01:42 PM   #12
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,072

Rep: Reputation: 384Reputation: 384Reputation: 384Reputation: 384
The thing is that if you run out of physical ram and you have no swap, then the system will start closing programs without previous notice, and you can lose data.

So, it's always (and affordable nowadays) to have some swap just in case. At least, that way, you can notice the huge performance penalty when your ram is filled, and you have some extra time to save your work and close apps normally.

For the rest, there's little point in using more than 512 mb of swap, unless you need it for hibernation or whatever. If you hit more than half a GB of ram your system is going to be ususable anyway and you simply need more ram, or you need to use lighter stuff.
 
Old 10-30-2008, 01:58 PM   #13
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,289

Rep: Reputation: 126Reputation: 126
Quote:
Originally Posted by umwai View Post
If I have 3GB RAM do I need to have 6GB Swap. Is it really necessary.what is the purpose of having swap.
As others have stated, in general, no, not with 3GB of ram, unless you get into some video editing situation where you are editing gigabytes of video in ram. I generally view the swap question as one of those "if you have to ask, then you don't need it" types of questions.
 
Old 10-30-2008, 10:55 PM   #14
bcwagne
Member
 
Registered: Feb 2008
Distribution: Debian Testing, OSX
Posts: 164

Rep: Reputation: 32
I usually stick by the old rule of thumb and have twice as much swap as ram. You may scoff if you like, but I have no reason not to...I can't even fill 50 GB of my 250 GB hard drive.
 
Old 10-30-2008, 11:28 PM   #15
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,072

Rep: Reputation: 384Reputation: 384Reputation: 384Reputation: 384
Quote:
Originally Posted by bcwagne View Post
I usually stick by the old rule of thumb and have twice as much swap as ram. You may scoff if you like, but I have no reason not to...I can't even fill 50 GB of my 250 GB hard drive.
If there's no reason to do so, then there's no reason to do so. We might as well say that there's no reason to have 6gb of swap space. So, that argument is invalid by itself Believe me, I have a total of 1.2 TBs, and I am going to buy a new disk soon because I have only ~100GB left.

If the swap starts filling up due to a memory lack in firefox (just an example ) and the computer hangs without you being able even to move the mouse pointer, you are going to wish that your swap space was smaller, so the program crashes and is closed soon. Otherwise, you might have to wait for a long time until you can do anything with your box. That can be minutes to hours, depending on the hardware.

There's really no point in having such a huge swap space, unless it's for very concrete tasks. And even then, if you really fill 6gb of swap and you only have 3gb of ram, you definitely are running software that your box is simply not capable of running, and you need an upgrade.
 
  


Reply

Tags
installation


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 - having trouble with swap auto mounting at boot lostdj Linux - General 2 08-05-2008 12:47 PM
Need Help Increasing Swap by creating a swap file froggo Red Hat 3 06-13-2006 08:04 AM
Linux swap / solaris not appearing as swap in Ubuntu? Erik_the_Red Linux - Newbie 1 07-30-2005 12:57 PM
How to unmount actual swap and mount a new(bigger) swap space? isaac Linux - Newbie 1 06-06-2004 01:23 AM
Difference between Swap Virtrual memory and Swap Parition Nappa Slackware 4 11-27-2003 07:58 PM


All times are GMT -5. The time now is 02:58 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration