Amazon EC2 add swap

If you want to add some swap to your Amazon EC2 instance, here’s the quick’n dirty:

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

To have the swap mounted on boot, modify /etc/fstab and add the line below:

/var/swap.1 swap swap defaults 0 0


Leave a Reply