Add Swap Space to in your Azure  Linux Machine Instance

By default in Azure if you check the the swap would be 0.
We can set this by using the Azure Linux Agent




Open an SSH session to your Azure Linux instance and run these commands as root or using sudo:

Steps:

1) Test the available disk space for your instance:
df -h

2) Edit the Azure Linux Agent configuration file:
vi /etc/waagent.conf

Update these parameters:
ResourceDisk.Format=y
ResourceDisk.EnableSwap=y
ResourceDisk.SwapSizeMB=16384

Set the “ResourceDisk.SwapSizeMB” value to the number of megabytes to allocate to the swap file. Usually this value can be up to the size of the installed system memory. Make sure you have sufficient available space on the disk to do this.


3) Restart the Azure Linux Agent service:
service waagent restart

4) Verify that your swap file is available:
swapon -s





If you like please follow and comment