SWAP partitions in Azure are quite interesting thing – SWAP space can be created on the local resource disk with the Linux Agent by enable swap in /etc/waagent.conf. It will automatically use the resource disk (which comes with every VM) to create the swap ( i.e. there’s no need to create a disk for it and also it means that please do not use swap on OS or data disk ). Good links which surely may help here – it’s not a rocket science, just changing Azure Linux Agent configuration file.
There’s a recommendation regarding where should be SWAP placed – we highly recommend to use resource disk for that ( i.e. /mnt/resources ) and not using system drive for that purpose. There’s several reason why it should be like that and all of them are about performance ( so yes, technically you can do it, but consequences of that configuration will be bad and non-so-predictable performance ):
- OS drive is a storage account backed entity and it saved during restarting/moving VMs. So it’s not good idea to slow down that account by additional workloads.
- OS drive is optimized almost for fast boot and other additional workloads will make performance of that resource not so good ( or very bad even ).
- OS drive is from technical side is a remote storage, so latency might be higher compared to local resources.
- Resource disk is located locally and not survived during host changed, but it’s much faster and this is a place designed especially for swap-like workloads.
Also we support a way inject a script or other metadata into a Microsoft Azure virtual machine at provision time – it’s custom data and cloud-init :
Examples of configuration :
Leave a Reply