Azure Linux Support Team

Support for Linux on Azure

How to: Add SWAP to Linux VM’s on Azure

Every virtual machine (VM) on Azure has what we call a temporary (ephemeral) disk which is recommended to be used ONLY as temporary storage and that includes SWAP files or data that does not need to be available upon a reboot or saved , the data stored in this drive will be lost.

To create a swap file in the directory that’s defined by the ResourceDisk.MountPoint parameter, you can update the /etc/waagent.conf file by setting the following three parameters:


Where the size is in MB, so for instance, to create a SWAP file of 4GB you could use these lines:


Before creating a SWAP file using the WAAgent, we also recommend looking at how much space you have available for the temporary disk by checking this link where on each category of VM we display the local SSD or local HDD storage available.


How to add a swap file in Linux Azure virtual machines

Optimizing your Linux VM on Azure