Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an Amazon image with 1 root image, 1 image that I uses for websites and is only using 25%, and 1 image "unused"

So I thought... maybe I can use that unused image for a linux swap file.

Since I have 10 Gb (9.2G Avail) would it be wise to create a 8GB swap file on this Volume or would that not be best practice? (I run some WordPress sites only) (memory = 3.75GB)

Can I somehow tell "use the complete disk as swap space" instead of indicating the specific amount?

dd if=/dev/zero of=/mnt/web2/swapfile bs=1024 count=8388608
mkswap /mnt/web2/swapfile
swapon /mnt/web2/swapfile


[root@ip-* web2]# free -m
             total       used       free     shared    buffers     cached
Mem:          3754       3715         38          0         11       3517
-/+ buffers/cache:        186       3567
Swap:         8191          0       8191


[root@ip-* etc]# cat fstab
LABEL=/     /           ext4    defaults,noatime  1   1
tmpfs       /dev/shm    tmpfs   defaults        0   0
devpts      /dev/pts    devpts  gid=5,mode=620  0   0
sysfs       /sys        sysfs   defaults        0   0
proc        /proc       proc    defaults        0   0
web         /dev/xvdf   ext3    defaults        1   1
web2        /dev/xvdg   ext3    defaults        1   1
/mnt/web2/swapfile swap swap    default         0   0
share|improve this question
Why even do this? Are you actually running out of physical memory? – cjc Apr 20 '13 at 17:28
I was - reason not completely clear – edelwater Apr 20 '13 at 19:49
up vote 3 down vote accepted

If you need swap space then use instance storage instead of EBS volumes. There are 3 reasons:

  1. Instance storage will be faster
  2. You'll pay for the EBS I/O
  3. You don't need the swap space to persist beyond restarts
share|improve this answer

Your Answer


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.