LinuxQuestions.org
Review your favorite Linux distribution.
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 01-13-2006, 05:00 AM   #1
Garp
Member
 
Registered: Jul 2003
Location: Oahu, Hawaii, USA
Distribution: Ubuntu, Debian, RHES
Posts: 57

Rep: Reputation: 15
Best practice size for Swap partition


I'm writing up some documentation for work explaining the steps for rebuilding a linux box, and on a proof read I spotted I'd written that the good practice is for swap to be the same size as system memory, something I remember reading somewhere. What I don't remember is why? I can think of various locations talking about the reccomended size of a swap file for Windows and getting everything from "half the system memory + 64mb" through to obscure ones like "total system memory + 2* your Aunt Mary's Age, divided by the number of prunes she had for dinner"; there seemed to be no concensus nor any real explanation as to where these hard and fast rules had developed from.

Is there such an explanation out there for Linux and its swap drive size? Is "same size as system memory" really good practice?
 
Old 01-13-2006, 05:05 AM   #2
Ahmed
Member
 
Registered: May 2005
Location: München, Germany
Distribution: Slackware
Posts: 386

Rep: Reputation: 41
Don't know.. I heard that it's double the system memory though

-A
 
Old 01-13-2006, 05:25 AM   #3
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 197Reputation: 197
Quote:
Originally Posted by Ahmed
Don't know.. I heard that it's double the system memory though

-A
Old rule of thumb that is..

Nowadays when desktop systems have 1GB of memory almost standard, it just all depends on how much swap you should use. It all depends on what the system is going to be used for, how much memory total it has, etc.

Heavily used server with 2GB of RAM, it probably wouldn't hurt to have a 2GB swap space. Same server lightly used and not expecting high loads, 512MB might do the job and might never get used, even the 2GB swap on high traffic server might never get used.
 
Old 01-13-2006, 03:00 PM   #4
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,178

Rep: Reputation: 49
I've generally run with 2x system memory for <1gB, 1x for >1gB
 
Old 01-13-2006, 08:25 PM   #5
bandersnatchy
Member
 
Registered: May 2004
Location: USA-Calif
Distribution: KANOTIX!
Posts: 48

Rep: Reputation: 15
Quote:
Originally Posted by Garp
Is "same size as system memory" really good practice?
"Good practice" is what works for you. Long threads of logical arguments about how swap is good or not so good are interesting, but don't point to a single simple formula.

If you are "rebuilding" an existing server, there should be some idea about what works in your particular network.

If there is no idea about what is most efficient in a network, and I felt obliged to put a formula in the documentation, I wouldn't hesitate to put something about starting with 2x RAM, monitoring, and adjusting if needed.

For a desktop, Poetics' formula looks good to me, generally. More swap may be advised for putting together custom live CDs or DVDs. I've read that lots of swap is good for working with video.

A work manual? Remember KISS. Keep it as simple as possible. Don't try to explain all the issues of the Linux universe.

Good Luck!
 
Old 01-14-2006, 05:15 PM   #6
Garp
Member
 
Registered: Jul 2003
Location: Oahu, Hawaii, USA
Distribution: Ubuntu, Debian, RHES
Posts: 57

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by bandersnatchy
"Good practice" is what works for you. Long threads of logical arguments about how swap is good or not so good are interesting, but don't point to a single simple formula.

If you are "rebuilding" an existing server, there should be some idea about what works in your particular network.

If there is no idea about what is most efficient in a network, and I felt obliged to put a formula in the documentation, I wouldn't hesitate to put something about starting with 2x RAM, monitoring, and adjusting if needed.
How does one go about monitoring the swap usage? I don't think I've ever read it anywhere.

Quote:
A work manual? Remember KISS. Keep it as simple as possible. Don't try to explain all the issues of the Linux universe.

Good Luck!
I've done my absolute hardest to keep the manual simple, but its literally a step-by-step process talking the end user exactly through installing Gentoo and then on to a fully working DVB PVR box. I can't have done too badly with it as a totally non-linux geek has just managed to do it on a test box in the office
 
Old 01-14-2006, 07:41 PM   #7
bandersnatchy
Member
 
Registered: May 2004
Location: USA-Calif
Distribution: KANOTIX!
Posts: 48

Rep: Reputation: 15
Quote:
Originally Posted by Garp
How does one go about monitoring the swap usage? I don't think I've ever read it anywhere.
I'm really out of my league here, with servers. Maybe someone else will jump in.

Here is something less serious folk like me might do on a desktop machine... Configure a KSysGuard chart to show swap use for a half hour. Take a snapshot of this screen after a period when memory use is high. But a server administrator may not want KSysGuard anywhere near his server.

A resourceful expert could probably use "free" in a script, collecting memory use data info every few seconds, but that appears to be reinventing what surely has to already be out there.

A little googling located this James Day post in mysql forum:
"In a linux environment you should use top and vmstat to monitor swap use. For top, turn on the optional column for displaying the number of hard page faults (called nFLT in some versions). If it's a dedicated server I aim for close to zero si and so in vmstat monitoring, based on experience showing that any significant amount hurts. "
http://forums.mysql.com/read.php?24,8218,8266

But sorry, I really don't know if Mr. Day has the best answer either.

I keep finding stuff about "meminfo", but reading it is giving me an awful headache. Maybe you can do better!

Quote:
Originally Posted by Garp
I've done my absolute hardest to keep the manual simple, but its literally a step-by-step process talking the end user exactly through installing Gentoo and then on to a fully working DVB PVR box. I can't have done too badly with it as a totally non-linux geek has just managed to do it on a test box in the office
Whoa! You bit off a big chunk for starters. Take some time to enjoy your accomplishments. Congrats.
 
Old 01-18-2006, 05:32 AM   #8
Garp
Member
 
Registered: Jul 2003
Location: Oahu, Hawaii, USA
Distribution: Ubuntu, Debian, RHES
Posts: 57

Original Poster
Rep: Reputation: 15
Quote:
Whoa! You bit off a big chunk for starters. Take some time to enjoy your accomplishments. Congrats.
It was and wasn't my choice
We really needed to be able to record off freeview (digital terrestrial in the UK), and be able to burn the recordings onto DVD for use in classrooms. After spending ages digging around I couldn't find a commercial solution that fulfilled all the requirements, dual tuners etc. etc. Decision was made amongst the team that as I had a mythtv box running at home (more or less.. was still working on it at the time), if we bought a couple of digital tv cards we could produce an in house solution. After bashing my head against brickwalls in RHES (running on other servers in-house), Fedora Core, and Slackware, I finally switched over to Gentoo like I was using at home. No hassles there Install took longer, sure, but it works with no hassles on the scale I was getting with the other distros.

Problem is I'm the only person on site that has ever installed Gentoo before, so documentation of install was necessary in case I get run over by a number 9 bus or something

Eventually, when I get time, I'll be knocking up the instructions into more of a HOWTO format than they are currently for others to use. A few of the colleges in the area have heard about our PVR and were asking how to make ones of their own...
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Swap Partition Size Murdock1979 Slackware 11 07-27-2005 01:09 AM
What size should I make my swap partition? bobotoes Linux - Newbie 7 09-30-2004 10:36 PM
swap partition size alaios Linux - General 4 09-27-2004 01:21 PM
swap partition size? Toker Linux - Newbie 16 10-12-2003 11:19 AM
change swap partition size? jamaso Linux - General 4 07-03-2002 09:46 AM


All times are GMT -5. The time now is 05:50 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration