How can I create a swap partition in EC2?
- Attach a new Amazon EBS volume to your EC2 instance.
- Initialize it as swap directly:
sudo mkswap /dev/xvdf(replace with your volume's identifier). - Enable it:
sudo swapon /dev/xvdf. - Add it to
/etc/fstabusing its UUID to prevent reboot mounting errors