LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-17-2012, 11:18 PM   #1
cheesewizz
Member
 
Registered: Aug 2004
Location: Philippines
Distribution: Centos
Posts: 221

Rep: Reputation: 15
How to check swap available and how to increase it


Hi


Awhile ago my centos server cannot access by other users
since this is running as terminal mode not gui when I opened it
lots of message appeared on my LCD something swap is 0%


i used this command df -ha to check swap

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
130G 63G 61G 51% /
proc 0 0 0 - /proc
sysfs 0 0 0 - /sys
devpts 0 0 0 - /dev/pts
/dev/cciss/c0d0p1 99M 20M 75M 21% /boot
tmpfs 501M 0 501M 0% /dev/shm
none 0 0 0 - /proc/sys/fs/binfmt_misc
sunrpc 0 0 0 - /var/lib/nfs/rpc_pipefs



but i dont know which swap is there?
and how to increase swap without reinstalling of Distro.
and is it possible to check and review error message the time i restarted the server which log is that?



Thanks
 
Old 02-18-2012, 12:24 AM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
Look at your memory usage with the "free" command -- it will tell you available and used swap space. I believe in principal you can use a file on a normal partition as swap, but it will be less efficient than having a swap parttion on your disk.
 
Old 02-18-2012, 01:12 AM   #3
cheesewizz
Member
 
Registered: Aug 2004
Location: Philippines
Distribution: Centos
Posts: 221

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by btmiller View Post
Look at your memory usage with the "free" command -- it will tell you available and used swap space. I believe in principal you can use a file on a normal partition as swap, but it will be less efficient than having a swap parttion on your disk.
Thanks for your reply

I execute free command and here is the result

total used free shared buffers cached
Mem: 1025884 1012324 13560 0 3584 103532
-/+ buffers/cache: 905208 120676
Swap: 2064376 424904 1639472


Thanks
 
Old 02-18-2012, 03:52 AM   #4
devilboy09
Member
 
Registered: Nov 2011
Location: Iran
Distribution: Debian, CentOS, LFS, CloudLinux
Posts: 377

Rep: Reputation: 10
you can use free -h for enabling human readable option.also if you want to increase the swap space i suggest you to create a swp file, like this:
Code:
dd if=/dev/zero of/swapfile bs=1024 count=1024
mkswap /swapfile
these command will create a 1 MB swap file that can be mounter automatically on boot time with fstab file.like this:
Code:
/swapfile none swap sw 0 0
 
Old 02-18-2012, 09:00 AM   #5
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 devilboy09 View Post
these command will create a 1 MB swap file
Are you assuming the OP will understand how to scale up from the 1MB swap file you described to the desired size, and that the OP can estimate a good size?

The bs=1024 in your example tells dd to work 1KB at a time, which is small and possible slow for creating a big file. The count=1024 tells how big in units of bs= to make the file.

The output from free that was posted shows the 2GB swap space less than one quarter used, which would be OK. But I think we are inferring from the vague info in the first post that at some other time the swap space was entirely used.

If 2GB of swap was used then adding 2GB more would not be generous. Having swap 2GB bigger than the most you've seen used is a reasonable safety margin. If the main disk were larger, I would suggest adding more than 2GB swap space now. But with only 61GB free disk space, I wouldn't want to be too generous with the safety margin on swap space.

If I understand dd syntax properly, then using bs=1M count=2048 would give a 2GB swap file instead of your 1MB example.

Since the system has only 1GB ram, the fact that it needs more than the 2GB swap it already has, may mean it is seriously underconfigured for the work it is doing, so adding swap will allow things to work that would have otherwise failed but they will only work slowly because 1GB is not enough ram.
Alternately, needing more than 2GB swap might indicate a memory leak in some program. Adding more swap space would reduce and delay the consequences of the memory leak and make the memory leak easier to diagnose. But it still doesn't diagnose itself. If you don't diagnose and correct it, even with added swap space, a memory leak will probably grow until it causes a serious failure.

Last edited by johnsfine; 02-18-2012 at 09:19 AM.
 
Old 02-19-2012, 08:11 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
As implied above, you really want to diagnose the underlying problem, if any.
Try 'top' in batch mode -b http://linux.die.net/man/1/top & accumulate results in a file, then examine the file to try and pinpoint the culprit(s)
 
Old 02-20-2012, 03:03 PM   #7
satyadev75
LQ Newbie
 
Registered: Nov 2010
Location: Chennai
Posts: 21

Rep: Reputation: 0
the above posts are really good solution . and you can create the swap from partitions also


"#fdisk /dev/sda (hda/sda/vda are types of disks)
command:n
2
.
.
:wq
#partprobe
#mkswap /dev/sda2
#vi /etc/fstab
/dev/sda2 swap swap defaults 0 0
:wq
#swapon /dev/sda2
#free "


and if your doubt is clear plese post it as solved question
 
  


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
How to Increase swap size ramesh14 Linux - Software 10 03-29-2010 12:01 AM
Increase SWAP Space? your_shadow03 Linux - Newbie 2 01-30-2009 04:52 AM
increase swap size ssilayaraja Linux - Newbie 5 08-18-2008 09:23 PM
How can I increase swap space? abefroman Linux - Server 12 12-27-2007 11:23 AM
Increase Swap Space? star geezer Linux - Software 9 03-10-2003 12:04 PM

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

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