Is it safe to store a swap-file on the Temporary Disk on Azure?
Solution 1:
No problem to have swap file on this disk but make sure to use the Linux agent to create it. It will automatically create and manage it in the resource disk.
Here's how to enable:
- Edit the "/etc/waagent.conf"
Add or uncomment these lines:
ResourceDisk.Format=y
ResourceDisk.Filesystem=ext4
ResourceDisk.MountPoint=/mnt/resource
ResourceDisk.EnableSwap=y
ResourceDisk.SwapSizeMB=2048
Usually only EnableSwap and SwapSizeMB will not come configured by default. Save and restart the agent to apply.
Solution 2:
On Windows virtual machines, this is done by default.
On Linux VMs this should be safe too, unless the system expects the swap file to already exist at boot time: then it could complain about not finding it and thus being unable to mount it.
In this case, some scripting would be needed to check at boot time if the swap file is actually there and create it if it isn't; all of this of course before mounting it.
Azure probably provides some means to automatically manage this.