I have read quite a few posts on this, but I am still unsure about the correct approach, assuming:
-
I have a default Ubuntu 14.04 LTS VM created by and running on Azure, which doesn't come with a swap
-
I would like to create a swap using existing VM storage, instead of create a new disk using additional storage
Posts I have read:
- https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-how-to-inject-custom-data/
- https://wiki.ubuntu.com/AzureSwapPartitions
- https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/1374166
Many solutions were discussed but I can't seem to find one that will persists across server reboots (probably due to cloud-init has it's own idea about image partitioning), can someone advise me on the best practice?
Best Answer
Assuming that you have Linux Agent installed. All you have to do is to enable swap under /etc/waagent.conf. These are the relevant lines:
It will automatically use the resource disk (which comes with every VM) to create the swap. There's no need to create a disk for it.
Update: You also need to execute the steps below in order to create the swapfile: