nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Why Swap=2 x RAM

This is a discussion on Why Swap=2 x RAM within the Getting started tutorials forums, part of the Linux Getting Started category; Hi Friends, Why do we use Swap space double the RAM. i.e SWAP = 2 x RAM. Is this a ...


Go Back   nixCraft Linux Forum > Linux Getting Started > Getting started tutorials

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 06-19-2007, 10:43 AM
diptanjan's Avatar
Junior Member
User
 
Join Date: May 2007
Location: Hyderabad
My distro: Redhat, Suse
Posts: 12
Rep Power: 0
diptanjan is on a distinguished road
Send a message via MSN to diptanjan Send a message via Yahoo to diptanjan Send a message via Skype™ to diptanjan
Post Why Swap=2 x RAM

Hi Friends,

Why do we use Swap space double the RAM. i.e SWAP = 2 x RAM.

Is this a universal rule for any size of RAM...?

If I install LINUX with 1GB of RAM and then after somedays I want to upgrate my RAM to 2GB. Can I do that without hampering the installation, as in that case I have to provide the SWAP space as 4GB.

I think yes.. now tell me How?

TIA

Diptanjan
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-19-2007, 05:54 PM
rockdalinux's Avatar
Contributors
User
 
Join Date: May 2005
Location: Bangalore
My distro: RHEL, HP-UX, Solaris, FreeBSD, Ubuntu
Posts: 571
Rep Power: 7
rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough
Default

That is the general rule of thumb so that you get exactly twice as much memory for loaded programs as there is physical RAM. For example if RAM is 512 you will get total 1 Gig. Swap is only used when you have maximum load.
__________________
Rocky Jr.
You may have my body & soul, but you will never touch my pride!

If you have knowledge, let others light their candles at it.

Certified to work on HP-UX / Sun Solaris / RedHat
Reply With Quote
  #3 (permalink)  
Old 06-19-2007, 06:02 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Any distro with shell
Posts: 958
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Quote:
Originally Posted by rockdalinux View Post
That is the general rule of thumb.
Noop.. that doesn't work with everyone.

To OP,

First find out how much RAM is sufficient or max to your needs. Generally you are limited by pricing factor (affordability aka price of RAM)

Second find out the min virtual memory requirements that will avoid server crash. So it is like:
SWAP Space = Min crash space

Let us say you have 2 GB ram and your server can take load upto 3GB and after that it will crash. So my swap space is set to 1GB.

Swap space defines the minimum virtual memory that system can operate with and the total amount of RAM.

So If you have 16GB RAM you are not going to create 32GB swap space. It is all about your and your application requirements. Find out that and create space as per requirements don't follow blindly
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #4 (permalink)  
Old 06-19-2007, 06:08 PM
rockdalinux's Avatar
Contributors
User
 
Join Date: May 2005
Location: Bangalore
My distro: RHEL, HP-UX, Solaris, FreeBSD, Ubuntu
Posts: 571
Rep Power: 7
rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough
Default

Quote:
Noop.. that doesn't work with everyone.
Nice but I never said – twice the ram is numero uno rule.

All I wanted to highlight is - OP is new to linux and should stick to general rule. Let him/her play with Linux and understand Linux and computer. So once you know your server you should able to make an estimate based upon your needs (I guess this what you are talking about).
__________________
Rocky Jr.
You may have my body & soul, but you will never touch my pride!

If you have knowledge, let others light their candles at it.

Certified to work on HP-UX / Sun Solaris / RedHat

Last edited by rockdalinux; 06-19-2007 at 06:13 PM.
Reply With Quote
  #5 (permalink)  
Old 06-19-2007, 06:42 PM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
My distro: Debian GNU/Linux
Posts: 482
Rep Power: 5
monk will become famous soon enough monk will become famous soon enough
Default

Quote:
Originally Posted by diptanjan View Post
do we use Swap space double the RAM. i.e SWAP = 2 x RAM.
Read : Linux.com - Allocating swap space
__________________
May the force with you!
Reply With Quote
  #6 (permalink)  
Old 03-25-2008, 01:14 AM
Member
User
 
Join Date: Mar 2008
My distro: Debian, Slackware, LFS
Posts: 83
Rep Power: 1
Tux-Idiot is on a distinguished road
Default

first off there is no thumb rule as swap = 2x RAM.
these days hdd space is more, back in those days 650 megs of hdd = heaven or dream come true, they were all BNC net or floppy net or net image or some mode or other which resulted in dumb terminals, they had the booting off via NFS root. those days RAM was expensive.
ram's clock cycle is in gigs and before in megs. but hdd's clock cycle is in 3600 then, now 7200 and newest 10000 rpm. so those days also they had to run dbms, and dbms like bdb berkeley db which normally uses a lot of processing and indexing which reqires a lot of ram. so, the rule is valid still today. if you want a database server like mysql or pgsql or oracle or db4.3 or unixodbc? you need an insane amount of RAM. which is why? if you are planning to run dbms? then to be on safe side? 4x RAM is safe and secure from hdd potential crash.
coming to point 2: if you upgrade RAM what do you? STOP being a PANICKY CHICKEN CHICK with skirt. swapoff the swap drive, remove it from fstab, resize some partition where you got loads of space for party, create a new partition for swap and format it as a swap and swapon. rh 7.x got a nice howto on system customisation.
/dev/mem and /dev/kmem = RAM memory and /dev/hdNX = hdd, RAM = high speed hdd. in short and they ease the process of io which is why we have seek time.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Swap piggy Getting started tutorials 3 07-17-2007 09:44 AM
Difference between Linux Swap partition & Swap file hrishikesh Linux software 9 03-16-2007 02:08 AM
difference between Swap and Virtual memory ricc Linux software 3 03-16-2007 01:35 AM
how to find swap in solaris raj Solaris/OpenSolaris 1 02-05-2007 06:48 PM
Deleted SWAP partition sonaikar Linux software 1 02-05-2005 06:20 PM


All times are GMT +5.5. The time now is 07:18 AM.


Powered by vBulletin® Version 3.7.3 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36