LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 02-12-2012, 03:23 PM   #1
michaelmas
LQ Newbie
 
Registered: Jan 2012
Posts: 21

Rep: Reputation: Disabled
Yet another SWAP question: Should I resize?


I know this topic has been disucssed to death and that there is no one truly optimal SWAP size for any case, but hear me out.

I have nearly 3gb RAM and a 250gb hard disk on my Lenovo laptop, running Ubuntu 10.04 LTS. Being a newbie, I chose the default install option, and the installer set up an 8gb SWAP space. That's nearly 3xRAM.

I am asking because I've been reading that in the old days, when RAM was more scarce, the swap should be 2xRAM, but currently I believe I have plenty of RAM and that the SWAP should be 2xRAM at best.

Code:
free -m
             total       used       free     shared    buffers     cached
Mem:          2770       2644        125          0         91       2086
-/+ buffers/cache:        466       2304
Swap:         8112          0       8112
Since I will be switching operating systems in few weeks (Fedora LXDE or Xfce) and possibly pre-partioning for dual boot, should I choose my own SWAP size? Or should I trust the automatic installer?

Is there a likely gain from choosing SWAP of, say, 5gb?
 
Old 02-12-2012, 03:28 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 2xRAM rule of thumb is way outdated. If you would need so much RAM that it would need 6GB (or even the 8GB given to you by the installer) of swap to run your workload the machine would be slow as hell. On a normal desktop machine (which includes laptops) 1-2GB should be more than sufficient, unless you want to use hibernate. In that case the swap partition should be at least the size of your physical RAM.
6 or more GB would simply be a waste of space.
 
Old 02-12-2012, 03:30 PM   #3
ukiuki
Senior Member
 
Registered: May 2010
Location: Planet Earth
Distribution: Debian
Posts: 1,030

Rep: Reputation: 385Reputation: 385Reputation: 385Reputation: 385
Do you use Hibernation? The usual size of swap is the same as RAM so yours could be 3Gb, Even when it shows a lot of RAM in use there is a lot cached too so all good and there is no swap in use at all! How about your partitions space? Are things getting too big and space too small?

Regards
 
Old 02-12-2012, 03:48 PM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by michaelmas View Post
a 250gb hard disk
...
Is there a likely gain from choosing SWAP of, say, 5gb?
The maximum gain is that making SWAP 3GB smaller allows you to make some other partition 3GB larger.

How important is that to you? Do you have a 250GB drive because you need that much? Or do you need much less than that and have it because that is what was convenient to buy? Or do you need more than that and upgrading is inconvenient and you frequently move things to offline storage because you are out of space?

Next question, what is the downside of reducing swap from 8GB to 5GB. That amount of swap is basically insurance. In case of software memory leak, things slow down smoothly and let the problem be more easily diagnosed, rather than failing sooner in a harder to diagnose way. In case you start running certain unlikely large tasks, your system can handle it (maybe slowly) rather than fail. All very unlikely.

I don't know how you use your system. For ordinary use with your system specs the upside of reducing your swap size is small and the downside smaller. Basically, don't care.

Last edited by johnsfine; 02-12-2012 at 03:51 PM.
 
1 members found this post helpful.
Old 02-12-2012, 03:54 PM   #5
michaelmas
LQ Newbie
 
Registered: Jan 2012
Posts: 21

Original Poster
Rep: Reputation: Disabled
@ TobiSGD
I never use hibernation and I'm just a regular desktop user, so clearly I'm wasting space here. Just hoping it's not affecting the performance.

@ ukiuki
Are you saying that my SWAP could be 3gb even though free -m shows 8gb?
I only have the SWAP and the root partition, and I haven't noticed anything unusual, yet.
 
Old 02-12-2012, 04:04 PM   #6
michaelmas
LQ Newbie
 
Registered: Jan 2012
Posts: 21

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by johnsfine View Post
The maximum gain is that making SWAP 3GB smaller allows you to make some other partition 3GB larger.

How important is that to you? Do you have a 250GB drive because you need that much? Or do you need much less than that and have it because that is what was convenient to buy? Or do you need more than that and upgrading is inconvenient and you frequently move things to offline storage because you are out of space?

Next question, what is the downside of reducing swap from 8GB to 5GB. That amount of swap is basically insurance. In case of software memory leak, things slow down smoothly and let the problem be more easily diagnosed, rather than failing sooner in a harder to diagnose way. In case you start running certain unlikely large tasks, your system can handle it (maybe slowly) rather than fail. All very unlikely.

I don't know how you use your system. For ordinary use with your system specs the upside of reducing your swap size is small and the downside smaller. Basically, don't care.
I'm actually only using about 30% of the hard drive, trying rather to keep large stuff on my external device. This is mainly because I just don't like having much stuff on my internal disk, not because of space scarcity.

But it's good to know that excessive SWAP only means less storage and not decreasing performance. Then I won't be losing much sleep because of this.

But I'm still wondering why Ubuntu installer would assign so much SWAP in the first place.
 
Old 02-12-2012, 04:47 PM   #7
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
Quote:
Originally Posted by michaelmas View Post
But I'm still wondering why Ubuntu installer would assign so much SWAP in the first place.
That is a very good question, I never saw such a behavior on systems with "only" 3GB of RAM, may be the Ubuntu developers know something we don't.
 
Old 02-12-2012, 05:51 PM   #8
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by michaelmas View Post
But I'm still wondering why Ubuntu installer would assign so much SWAP in the first place.
My guess is that you have 4GB of physical ram installed and either a BIOS misconfiguration or not using the PAE kernel (or maybe a limitation of the hardware) prevents you from using a significant chunk of ram.

I'm guessing the Ubuntu installer looked at how much ram is physically present, rather than how much ram the about to be installed kernel would be able to use, then it applied the stupid old rule of 2xRAM for swap. Always was a stupid rule, even stupider now, but lacking any non stupid rule, what is a distribution install supposed to default to.

BTW, my guesses tend to be pretty good, but I wouldn't have said "guess" if this post had the level of confidence of my typical answers.

The less generally known fact that went into those guesses is that DMI information about how much ram is physically present is easy to read and totally independent of how much ram the motherboard or BIOS or kernel actually allow you to use.

Last edited by johnsfine; 02-12-2012 at 05:53 PM.
 
  


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
Qtparted -- resize swap? ErrorBound Linux - Software 1 05-11-2006 09:14 PM
Want to resize main and swap partitions Shay SUSE / openSUSE 1 11-19-2004 11:31 AM
resize swap and Reiserfs wutever Slackware 6 10-15-2004 12:08 AM
Should I resize swap partition? snatale1 Linux - Newbie 9 12-27-2003 12:29 PM
resize swap partiton ? qwijibow Linux - Software 3 11-26-2003 12:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:52 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