LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions
User Name
Password
Linux - Distributions This forum is for Distribution specific questions.
Red Hat, Slackware, Debian, Novell, LFS, Mandriva, Ubuntu, Fedora - the list goes on and on... Note: An (*) indicates there is no official participation from that distribution here at LQ.

Notices


Reply
  Search this Thread
Old 01-03-2005, 12:21 AM   #1
dna9
Member
 
Registered: Nov 2004
Location: Colorado
Distribution: Ubuntu mostly...
Posts: 100

Rep: Reputation: 28
Question ubuntu - increase swap size


i installed ubuntu. when i go to "system monitor" it says this when
i click the tab for "resource monitor" at the bottom:


==================================================

used memory: 91.0 mb of 504 mb
used swap: 0 bytes of 486 mb

name: directory: type: total: used:
/dev/hda1 / ext3 72.9 gb 1.6 gb
tmpfs /dev/shm tmpfs 252mb 0 bytes

==================================================


my question is this, shouldn't my swap be 2x ram? other distro's i
have installed made a 1004 mb space for swap. i have 512 mb ram.
i let the ubuntu installer do the partitioning. should i not worry about it?
if it is not right, can i change it once the OS is installed? is there a
command for it?

thx...
 
Old 01-03-2005, 12:23 AM   #2
dna9
Member
 
Registered: Nov 2004
Location: Colorado
Distribution: Ubuntu mostly...
Posts: 100

Original Poster
Rep: Reputation: 28
my post

my post didn't format the way i wanted it to. try and read it anyway.
 
Old 01-03-2005, 05:06 AM   #3
kostian
Member
 
Registered: Jul 2004
Location: LT
Posts: 150

Rep: Reputation: 15
I think you dont need a gig of swap with 512mb ram(ofcourse it depends on what your doing with your box). i have 256megs of ram and swap usage is max ~400mb and opera browser uses most part of it.
AFAIK the 2xRAM formula is from the old days when computers had little ram.
you shouldnt worry unless you are running out of swap. you either can resize your current swap partition, create another one or create a swap-file.
 
Old 01-04-2005, 05:31 AM   #4
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
A recent suggestion was:
If you have 512MB or more RAM, SWAP should be 1/2 size of RAM
Less than 512, should be 2x size of RAM.

An example:
You have 512MB RAM, your swap should be somewhere around 256MB.

If you had 256MB RAM, then your SWAP should be somewhere around 512MB.

Cool
 
Old 01-04-2005, 02:09 PM   #5
qwijibow
LQ Guru
 
Registered: Apr 2003
Location: nottingham england
Distribution: Gentoo
Posts: 2,672

Rep: Reputation: 47
as the other post said, you probably dont need all that memory.

however to answer the question, here is a good way to add swap without having to resize your partitons.

Code:
# edit count= to be the amount of extra swap you want
dd if=/dev/zero of=/SWAP.img bs=1M count=128
losetup /dev/loop7 /SWAP.img
mkswap /dev/loop7
swapon /dev/loop7
then add the losetup and swapon lines to your rc.local boot scripts.

the proper way to increace your swap size however, would be to use qtparted on a live-cd like Knoppix to reduce your root partiton, and increace your swap partiton.
[/code]

Last edited by qwijibow; 01-04-2005 at 02:10 PM.
 
Old 01-23-2005, 07:53 AM   #6
mglukhovsky
LQ Newbie
 
Registered: Jan 2005
Distribution: Ubuntu and Yoper
Posts: 6

Rep: Reputation: 0
If you've got the hard drive space to spare, then actually what several Linux experts have told me (this is assuming you're a power user, graphic designer, developer, or just heavy user) that the best formua is 3x your computer's RAM, up to 1 GB. If you've got >1GB of RAM, then it's just 1x. Seems a bit outrageous, but it's worked quite well, and yes I have gotten periods where I've used that much swap.
 
Old 01-23-2005, 09:09 AM   #7
qwijibow
LQ Guru
 
Registered: Apr 2003
Location: nottingham england
Distribution: Gentoo
Posts: 2,672

Rep: Reputation: 47
[/quote]formua is 3x your computer's RAM, up to 1 GB. If you've got >1GB of RAM, then it's just 1x.[/quote]

seems a bit of a crap formula.. no insult intended, but hat would mean a user with just under a gigabyte of ram would end up with 4Gig total memory, and a user with just over a gig ram would end up with 2gigs ram.

double the amount of total memory for the sake of 5 megs ram !

im no expert, but here is would i would recomend...
take the maximum amount of ram you will ever need... (for many of you, this might be the recomended about of ram on the unreal tournament / doom CD)
Multiply by 2 (to be on the safe side.) then subtract the amount of ram physical ram you have... and their you have your Swap...

to be more accutate, you might want to factor in how "swappy" your kernel is.
set swappyness with
echo "number_between_0_and_100" > /proc/sys/vm/swappiness

make you machine more swappy for machines with little ram, less swappy for machines with large amounts of ram.

Last edited by qwijibow; 01-23-2005 at 09:12 AM.
 
Old 01-23-2005, 10:58 AM   #8
mglukhovsky
LQ Newbie
 
Registered: Jan 2005
Distribution: Ubuntu and Yoper
Posts: 6

Rep: Reputation: 0
Quote:
no insult intended, but hat would mean a user with just under a gigabyte of ram would end up with 4Gig total memory, and a user with just over a gig ram would end up with 3gigs ram.
Try re-reading the guideline I gave. For under a gig (obviously with some discretion) the rule is to multiply by three. For over a gig, make your swap EQUAL to the size of your RAM.

Obviously, these are only guidelines, not a strict mathematical formula. If someone has 256 MB of ram, having a swap of 768 MB wil help considrably. If you have 512 MB of ram, maybe you ought to only go with a 1 GB swap instead. Howver, I still don't see where you're getting figures of 4gb and 3 gb from.

The old "twice the amount of ram minus the amount of physical memory" rule is from the earlier days of linux, when machines weren't coming with 1 GB of memory or very ram-intenstive applications, particularly given the influx of eye candy in the Linux Desktop, as part of the path to bringing the average home user away from Windows.

Really, it all comes down to personal choice. I use a gig of swap, and have occasionally come close to using all of it. Howver, I frequentlu do hit half the swap size, so I like to have the room to spare. Storage is cheap, I can afford sparing a gig for stabiliy and speed. What another user's situations is will affect the size of their swap.
 
Old 01-23-2005, 11:04 AM   #9
qwijibow
LQ Guru
 
Registered: Apr 2003
Location: nottingham england
Distribution: Gentoo
Posts: 2,672

Rep: Reputation: 47
Quote:
Try re-reading the guideline I gave. For under a gig (obviously with some discretion) the rule is to multiply by three. For over a gig, make your swap EQUAL to the size of your RAM.
so for systems with 0.95 Gig of ram, you would add almost 3 gigs of swap.
total almost 4 gigs of memory.

for systems with 1.05Gugs of ram, you would add just ofver a gig swap...
total 2 gigs of memory.

like i say, for the state of an insignificant amount of ram, you are doubleing the total memory, trippleing the swap.

maybe you should re-read my post before telling me to re read yours.

anyways, im just saying genral rules just down work,
i have 512 megs of ram, with swappyness set to 60, and my swap is never touched, even when compiling multiple large programs (like KDE) and authoring a DVD. to playing Ut2004 / Doom.
 
Old 01-23-2005, 11:11 AM   #10
mglukhovsky
LQ Newbie
 
Registered: Jan 2005
Distribution: Ubuntu and Yoper
Posts: 6

Rep: Reputation: 0
I meant no offense, but as I said, it's all personal preference. But let's be realistic here. What normal user would have 0.95 GB of ram, or 1.05 gb of ram? The average user would have 128, 512, 768, or 1024. That's what I was aiming at.

Clearly we use Linux differently, which leads to our different swap usage. What works for me maynot work for others. But that's Linux and FOSS in general is about, isn't it? The choice to use what works best for you!
 
Old 01-23-2005, 02:27 PM   #11
qwijibow
LQ Guru
 
Registered: Apr 2003
Location: nottingham england
Distribution: Gentoo
Posts: 2,672

Rep: Reputation: 47
Quote:
I meant no offense
i know, neither did i. im just arguing that i dont believe swap should simply be a multiple of your physical ram.
 
Old 01-24-2005, 11:45 AM   #12
winsnomore
Member
 
Registered: May 2004
Location: USA
Distribution: #1 PCLinuxOS -- for laughs -> Ubuntu, Suse, Mepis
Posts: 315

Rep: Reputation: 31
Here is a formula ..

1. carefully count the numbers of angles dancing on the head a pin. (use a CAT scanner if you can)
2. multiply that by your birthdate (not the year .. actual days from the year BC 2355 + add the lost days of the julian calendar)
3 Take a factorial of it
4 divide it by 42
5 and use it as a seed of random number generator to give you an idea what the swap space should be ..

This 5 step formula is what the gurus uses .. cuz it always give the right answer for "each" individual.

All these formulas are BOGUS .. 2x/3x/4x .. < x, > y ..

Simple formula is WHAT are you doing with your computer ..
If you are doing:
lot of audio/video compression .. A LOT OF SWAP "may help" ..
A lot of programming .. may be ..(i guess in this case you won't be asking such questions on a forum)
Only websurfing .. almost none
a bit this a bit that ... a little bit would do ..
typically servers use good deal of swap.
You can always mount additional fs for swap .. .. so start with any amount you can .. 200-300 meg .. and if you see things
failing, memory meter pegging .. create another swap partition and add that in fstab and you will be happy forever.
 
  


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
Linux swap / solaris not appearing as swap in Ubuntu? Erik_the_Red Linux - Newbie 1 07-30-2005 12:57 PM
Looking to increase swap partition Patgod Linux - Newbie 8 03-29-2004 05:46 PM
How to increase SWAP partition space ? sureshsaragadam Linux - Newbie 23 10-01-2003 09:24 AM
increase point size size when printing PDF files newlin Red Hat 0 09-27-2003 07:13 AM
Increase Swap Space? star geezer Linux - Software 9 03-10-2003 12:04 PM

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

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