1

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?

1
  • 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, 2011 at 14:25

3 Answers 3

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.

0

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.

-1

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

3
  • This is not the problem here, as the OP manually created the swap space and activated it.
    – Sven
    Mar 31, 2011 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, 2011 at 9:20
  • That's a dead link now... Nov 18, 2012 at 15:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .