LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 12-22-2009, 12:15 PM   #1
Alexvader
Member
 
Registered: Oct 2009
Location: Japan
Distribution: Arch, Debian, Slackware
Posts: 994

Rep: Reputation: 94
Optimum size for /swap


Hi Forum

I Have searched and googled for this... but so far I have not found a conclusive answer...

Some say it should be twice of Physical ram, some say it should be the same, some a bit less...

Assuming I do not want to suspend to RAM, I always shutdown with poweroff, what should be the size of my swap...?

BRGDS

Alex
 
Old 12-22-2009, 12:17 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
If you have plenty of RAM you shoudl never need to swap anything out to disk, so you shouldn't need any. At the same time if you have a huge disk a few gig wouldn't be missed. Essentially there is no real rule any more and you are unlikely to suffer whatever you pick. As you covered off already, the only real issue would be suspending to disk which you don't want to do.
 
1 members found this post helpful.
Old 12-22-2009, 12:28 PM   #3
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
What acid_kewpie said, plus a few considerations. Firstly, the twice RAM rule of thumb is a leftover from the days when a typical server had 16MB (that's megabytes) of RAM, so SWAP was heavily used. So, a corollary would be that even today, if you're running a server with a lot of users you either need lots of RAM or maybe just a largish SWAP space. However, if you were in that position you would probably already know what to do.

As you already know, suspend is an issue to consider, as well.

But, the worst thing about SWAP is that it's bog slow; even if there's only one user - you. Memory is just too cheap these days to be trapped using a hard disk for pseudo-RAM. And, imagine the situation where you have several GB of SWAP and you have to actually use it for something besides suspend because you just don't have enough RAM. That would probably be miserably slow. My suggestion is to use about 1GB of SWAP space, and if you ever notice your machine actually swapping do the obvious: add more RAM.
 
1 members found this post helpful.
Old 12-22-2009, 12:29 PM   #4
Alexvader
Member
 
Registered: Oct 2009
Location: Japan
Distribution: Arch, Debian, Slackware
Posts: 994

Original Poster
Rep: Reputation: 94
Hi Acid_Kewpie

I have 4Gigs installed, I am planning to install 4Gigs more... that's right... : 8Gigs physical RAM...

But, I do run some heavy stuff... Computational Fluid Dynamics, Finite Elements Analysis... and I mean HEAVY...

When the volume of data outbounds the physical RAM limitations, having some spare Gigs to "spill the rest" of the data structures of the running analysis wouldn't seem such a bad Idea...

Think I'll stick w/ 4Gigs RAM...

BRGDS

Alex

EDIT

In a "defaults" Debian Lenny Install on this Box, the installer allocated 12, ( yeah, you read well.. 12 ...) Gigs of swap for 4 Gigs of Ram in an LVM setup...

Do these guys sell HDDs or what...!!??

Last edited by Alexvader; 12-22-2009 at 12:37 PM.
 
Old 12-22-2009, 12:31 PM   #5
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
Quote:
Originally Posted by Alexvader View Post
But, I do run some heavy stuff... Computational Fluid Dynamics, Finite Elements Analysis... and I mean HEAVY...
Can we assume you're already running a 64-bit kernel? If not, you should consider it; and I don't recommend that very often.
 
1 members found this post helpful.
Old 12-22-2009, 12:35 PM   #6
Alexvader
Member
 
Registered: Oct 2009
Location: Japan
Distribution: Arch, Debian, Slackware
Posts: 994

Original Poster
Rep: Reputation: 94
Yes QuakeBoy02,

I am running 64bit smp kernel...

All my stuff was compiled w/ Intel Compilers Icc and Ifort for 64 bit...

BRGDS

Alex
 
Old 12-22-2009, 01:29 PM   #7
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
The previous responses have touched upon the history of swap. I can offer my own observations with respect to my systems.

My primary office system is a dual core running Slackware 12.2 and KDE 3.5.10. I have 4 GB of RAM and the kernel compiled for that. On this system I run virtual machines, Firefox, KMail, Akgregator, Amarok, Kate, KMix, KAlarm, etc. Once in a while swap gets used. Not often but I have seen that happen.

My HTPC is a dual core running Slackware 12.2 and KDE 3.5.10. I have 2 GB of RAM. I only run the system as a home theater PC and web browser. Once again, once in a while swap gets used. Again, not often but I have seen that happen.

I have two clunker machines that I tinker with occasionally. One is a 400 MHz K6-III+ CPU with 256 MB RAM and the other is a 350 MHz PII CPU with 448 MB RAM. On both hard drives I have 1 GB swap partitions.

I have the drive space and with my dual core systems I configured my swap partitions to be larger than the amount of installed RAM in each box (4.4 GB and 3.3 GB respectively). I did this with the idea that perhaps someday I might use suspend-to-disk. I don't use that shutdown option because I have found that boot times from suspend-to-disk are about the same as from a cold start.

You mentioned you might not be interested in any suspend options. Therefore you would not need to create a swap partition large enough to support suspend-to-disk. The only question then for yourself to answer is how much RAM does your daily usage consume? If you have the drive space, creating a 1 GB swap partition seems silly nowadays with 2 to 4 GB of RAM now common, but that partition size won't hurt you in any way. On the other hand, going the other extreme and creating a tiny swap partition could bottleneck your system someday if you start using a lot of RAM.

As mentioned, with the price of RAM relatively inexpensive these days, an extra stick or two basically avoids any concerns with swap.

I never have tried to run any system with swap off. I don't know whether no swap at all has any serious effects on a Linux-based system.
 
1 members found this post helpful.
Old 12-22-2009, 01:46 PM   #8
AlvaroG
Member
 
Registered: Jul 2009
Location: Canelones, Uruguay
Distribution: Slackware
Posts: 147

Rep: Reputation: 43
Quote:
Originally Posted by Woodsman View Post
I never have tried to run any system with swap off. I don't know whether no swap at all has any serious effects on a Linux-based system.
Well, I ran my sistem without swap for long time, without knowing (one day I ran the 'free' command and noticed it was showing 0 MB of swap, the partition somehow was not set up on the fstab :-D
I have a laptop with 2GB of RAM and the swap gets touched sometimes (a lot more now that I'm with KDE4 on Slack13, I have to say), but never noticed anything strange when it was disabled.

Running VMs with a lot of memory (on my laptop, a WinXP VM with 700MB out of 2GB allocated) or suspend to disk are good reasons to have a swap partition (in the case of the VM, as a "just in case"). But I believe that unless you are doing something that requires as much memory as you may get (large image processing, audio/video edition), there should be no need for swap on a system that has 4GB of memory.

Don't really know how much swap the suspend-to-disk feature may need. It always loads around 500MB from disk when it wakes up, what seems strange considering my memory usage varies a lot. But to be safe I made my swap partition the same size of my physical RAM (2GB), which is less than 2.5% of the hard disk size (and my hd is small for today's standards, only 120GB)


My 2 cents :-)
 
1 members found this post helpful.
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Optimum PC size deaddog Linux - Newbie 2 12-17-2007 10:11 AM
Swap size... simonj82 Slackware 11 06-09-2006 09:44 AM
Why should you give the size of the swap disk as twice the size of RAM vmniza Linux - Newbie 3 09-17-2004 02:13 AM
Is there an optimum block size for the dd command? tgardner Linux - Newbie 1 08-25-2003 08:43 PM
swap size kodiakmook Linux - Software 6 01-05-2002 12:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

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