amazon web services – How do you add swap to an EC2 instance? – Stack Overflow

amazon web services – How do you add swap to an EC2 instance? – Stack Overflow

amazon web services – How do you add swap to an EC2 instance? – Stack Overflow.

 

Increase virtual memory in EC2.

 

A fix for this problem is to add swap or paging space to the instance.

Paging works by creating an area on your hard drive and using it for extra memory, this memory is much slower than normal memory however this is much more of it available.

To add this extra space to your instance you type:

sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1

If you need more than 1024 then change that to something higher.

To enable it by default after reboot, add this line to /etc/fstab:

/var/swap.1 swap swap defaults 0 0
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s