0

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

and

[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

and

[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
edelwater
  • 487
  • 1
  • 4
  • 12

1 Answers1

3

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
Matt Houser
  • 9,709
  • 1
  • 26
  • 25