LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-20-2010, 06:20 AM   #1
ramesh14
Member
 
Registered: Apr 2008
Location: Hyderabad
Distribution: RHEL5,Fedora 8/9
Posts: 119
Blog Entries: 1

Rep: Reputation: 15
Question How to Increase swap size


Hi all,

I'm using fc8 in postfix server. My harddisk capacity 80GB.

when i run the command
#df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/hda3 ext3 73G 19G 51G 27% /
/dev/hda1 ext3 244M 8.3M 223M 4% /boot
none tmpfs 744M 0 744M 0% /dev/shm


sudo /sbin/fdisk /dev/hda

The number of cylinders for this disk is set to 9729.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Selected partition 4
No free sectors available

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Selected partition 4
No free sectors available

Command (m for help):


Now i've increased ram size from 512mb to 2GB. How to increase swap size.Even i was unable to create new partition. Please guide me how to increase the swap size.

Thanks in advance...
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 03-20-2010, 07:05 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
why do you want to increase the swap size? You've just bought more RAM so you've even less need for swap, not more. If you're going by an archaic rule of thumb of needing twice as much swap as ram then that's nonsense these days.

If for some reason you honestly do think you need it (in which case you have bigger problems and probably need to totally rearchitect the whole solution) then you can use mkswap to make a swap file within any given partition, first create a file of your desired size - dd if=/dev/null of=/var/swapfile bs=1024 count=102400 for a 100mb file then mkswap /var/swapfile and then swapon /var/swapfile to activate it.

you don't need to do this at all though.
 
1 members found this post helpful.
Old 03-20-2010, 08:34 AM   #3
thorkelljarl
Senior Member
 
Registered: Jun 2008
Posts: 1,807

Rep: Reputation: 215Reputation: 215Reputation: 215
Take a look...

Try running the command "top" from a terminal while your system is running at level of activity that you would consider to be normal/high.

http://linux.die.net/man/1/top

You will see the amount of memory being used and whether swap is active or not. An alternative to "top" is the command "free"; Google will help you to interpret the results of either.

http://linux.die.net/man/1/free
 
1 members found this post helpful.
Old 03-20-2010, 09:27 AM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194
The key question is whether you will be running bigger tasks and/or a larger number of simultaneous tasks now that you have more ram.

If you will be using the computer for the same activities as before, then (as acid_kewpie explained) you now need less swap space than before. The various formulas suggesting increased swap space for increased ram size were generally nonsense.

So if you bought more ram just because it was inexpensive and/or you bought more ram just to speed up tasks you could already run, leave your old swap space unchanged.

But if you plan to run bigger or more tasks than you were able to run before, the amount of additional swap space you need is still not determined by any rule of thumb from the amount of ram. It is determined by the sizes of the tasks you want to run.

If you figure out what swap space you need, it is easier to add it as a swap file (as acid_kewpie explained) than as a partition.

If you prefer a swap partition, you would need to boot on a liveCD and run a partition editor to shrink/move existing partitions to make more swap space. That isn't hard either, but it can't be done while the partition(s) you are modifying are booted or mounted.

Last edited by johnsfine; 03-20-2010 at 09:28 AM.
 
2 members found this post helpful.
Old 03-25-2010, 02:02 AM   #5
ramesh14
Member
 
Registered: Apr 2008
Location: Hyderabad
Distribution: RHEL5,Fedora 8/9
Posts: 119

Original Poster
Blog Entries: 1

Rep: Reputation: 15
Hi,

In my organization i'm using mail server, weekly we are sending 80,000's of mails. In these some of the mails are getting bounced & in queue. I'm getting the error message swap size is full. I increased ram from 512MB to 2 GB. Now is there any necessity to increase the swap size. Please suggest me.

Thanks in advance...
 
Old 03-25-2010, 06:06 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
you're just asking the same question again, and we've already answered you.
 
1 members found this post helpful.
Old 03-25-2010, 12:17 PM   #7
brucehinrichs
Member
 
Registered: Mar 2008
Location: US
Distribution: Debian Sid; Sabayon, UbuntuStudio, Slackware-multilib 13.1, Peppermint Ice, CentOS
Posts: 575

Rep: Reputation: 69
You can answer your own question (Now is there any necessity to increase the swap size. Please suggest me.):
1. Install the new RAM
2. See if you still get the error message that swap is full

At the risk of sounding obvious, if after installing the RAM the error message goes away, you don't need more swap

Last edited by brucehinrichs; 03-25-2010 at 12:22 PM.
 
1 members found this post helpful.
Old 03-25-2010, 05:27 PM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
if you need more swap, you don't need more swap, you need even more ram. Or more servers.
 
1 members found this post helpful.
Old 03-25-2010, 06:29 PM   #9
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194
Quote:
Originally Posted by brucehinrichs View Post
2. See if you still get the error message that swap is full
That is hardly a safe answer. You want to increase swap if you are even close to getting an error like that, not wait till you actually get it.

Quote:
Originally Posted by acid_kewpie View Post
if you need more swap, you don't need more swap, you need even more ram. Or more servers.
As always, I disagree with that. Swap space very often works quite well for its intended purpose. You don't need to have all your anonymous memory in ram.

Quote:
Originally Posted by ramesh14 View Post
I increased ram from 512MB to 2 GB. Now is there any necessity to increase the swap size.
You still haven't provided enough info for a useful answer to your question.

1) How much swap space did you have before?
(for all we know) maybe you had zero swap space before and that configuration was massively inadequate for the task. Then even if 2GB of ram is adequate for the task, having a little swap space would probably provide some safety and even some performance improvement.
Maybe you had 4GB of swap space before (though I really doubt it) and that was still too little. Then the increase from 512MB ram to 2GB of ram might be enough to fix the immediate error message, but I wouldn't expect it to be safe. You would need more.
Probably you had 512MB or 1GB of swap space before so probably the change from 512MB to 2GB of ram is relatively big enough to be confident it is enough with no change in swap size. But even in that case, I think it is worth checking to be more sure ...

2) Look at your memory use. While the big thing you want to run is actually running, use the free command to see what memory and swap space look like
Code:
 free
             total       used       free     shared    buffers     cached
Mem:       #######    #######     ######     ######     ######    #######
-/+ buffers/cache:    #######    #######
Swap:      #######      #####    #######
Check out that orange number. Make sure it is nearly the full 2GB of the ram you think you have.

Look at the red number, which is buffers plus cache plus free. That should probably be pretty big: 200MB or more. If it isn't, then the memory use may be too dominated by anonymous memory (either ram or swap is rather small for what you're trying to accomplish).

Look at the green number. That is the size of your swap space. It should be much larger than the Cyan number, which is the used part of your swap space.

With your big task running, probably Red is 500MB or more and Green is 500MB or more and Cyan is 100MB or less (probably zero). In that case the ram upgrade totally solved the problem, stop worrying.

If not, you need to give some more thought to your swap file size. Post the whole output of free (done while the big job was running).
 
1 members found this post helpful.
Old 03-26-2010, 03:01 AM   #10
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
If someone has a machine and they QUADRUPLE the amount of RAM and they still run out of swap, something is seriosuly wrong. and just throwing extra resources at it is not going to be the answer
 
1 members found this post helpful.
Old 03-29-2010, 12:01 AM   #11
ramesh14
Member
 
Registered: Apr 2008
Location: Hyderabad
Distribution: RHEL5,Fedora 8/9
Posts: 119

Original Poster
Blog Entries: 1

Rep: Reputation: 15
Ok Thanks to all. My doubt is clarified.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to increase size of swap space? anyzoo Linux - Newbie 11 06-18-2009 07:11 PM
increase swap size ssilayaraja Linux - Newbie 5 08-18-2008 09:23 PM
HOw increase the swap disk size? hinetvenkat Linux - Server 1 07-25-2007 08:55 PM
How to increase swap size in LVM? Akhran Debian 1 04-04-2006 09:47 AM
ubuntu - increase swap size dna9 Linux - Distributions 11 01-24-2005 11:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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