Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have created 14GB swap file in Amazon EC2 server but the swap file which I created is not being used by the server. The status is showing like this:

$ free -m
             total       used       free     shared    buffers     cached
Mem:          7687       7650         36          0        255       3834
-/+ buffers/cache:       3560       4126
Swap:        14335          0      14335

These are the steps I used to create the swap file on the server:

# dd if=/dev/zero of=/swapfile1 bs=1M count=14336
# mkswap /swapfile1
# swapon /swapfile1

Can someone tell me why the swap file is not being used?

share|improve this question
    
Good Lord, 14G of swap? If you're needing that much swap, you really ought to fix your mis-configured services or alternatively move some load off of that server. –  EEAA Mar 31 '11 at 14:25

3 Answers 3

It's been activated, as you have 14G of swap space available, but it's just not needed as you have 4G of RAM free (*) and Linux wouldn't use the much slower swap space if there is RAM available.

(*) Should you think that your RAM is all used up: It's not, it's just used as cache and can be used instantly if needed. Find more infos about that here.

share|improve this answer

It's not used cause there's no need to. Actually it's quite an unsual question due to normally admins tend to avoid swap usage :) If you want your system to use swap more agressive you can tune up some knobs. One of them is vm.swappiness, try setting it to the maximum: sudo sysctl -w vm.swappiness=100.

share|improve this answer

AFAIK, not all instance types have swap enabled.

Take a look at this link for more info: http://tech.backtype.com/swap-space-on-ec2

share|improve this answer
    
This is not the problem here, as the OP manually created the swap space and activated it. –  Sven Mar 31 '11 at 13:19
    
if you look at the original question, you will notice that that is not exactly clear. ;-) Still, I guess I should've commented on the question before attemting a poor answer –  grojo Apr 1 '11 at 9:20
    
That's a dead link now... –  chrisbunney Nov 18 '12 at 15:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.