Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

The default Ubuntu AMI does not have swap enabled, but it is not suitable for production use as the machine just crash when it is Out Of Memory.

Are there existing images with swap enabled so I can use without create a custom image?

Thanks.

share|improve this question

1 Answer 1

You do not need to create a custom AMI in order to gain swap storage on an Amazon EC2 instance. Rather you can simply add a swap file as outlined in How do I add more swap?:

Swap is generally associated with a swap partition, perhaps because the user is prompted to create a swap partition at the time of installation. In fact, any file can be used as a swapping device, be it a partition or a conventional file. Swap can be added by increasing the size of the swap partition or by adding a swap file. [...] [emphasis mine]

Section Four-step Process to Add Swap File outlines the required steps, which boils down to e.g. (replace /mnt with an appropriate directory of your choice):

sudo fallocate -l 512m /mnt/512MiB.swap
sudo chmod 600 /mnt/512MiB.swap
sudo mkswap /mnt/512MiB.swap
sudo swapon /mnt/512MiB.swap

This won't survive a reboot yet, thus requires you to edit /etc/fstab, e.g.:

sudo nano /etc/fstab

Then add this line at the end of the file:

/mnt/512MiB.swap  none  swap  sw  0 0

Please refer to the linked page for more details and an example session, if need be.

share|improve this answer

Your Answer

 
discard

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.