You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/virtual-machines/linux/optimization.md
+32-1Lines changed: 32 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,38 @@ By default when you create a VM, Azure provides you with an OS disk (**/dev/sda*
42
42
## Linux Swap Partition
43
43
If your Azure VM is from an Ubuntu or CoreOS image, then you can use CustomData to send a cloud-config to cloud-init. If you [uploaded a custom Linux image](upload-vhd.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json) that uses cloud-init, you also configure swap partitions using cloud-init.
44
44
45
-
On Ubuntu Cloud Images, you must use cloud-init to configure the swap partition. For more information, see [AzureSwapPartitions](https://wiki.ubuntu.com/AzureSwapPartitions).
45
+
You can't use the **/etc/waagent.conf** file to manage swap for all images that are provisioned and supported by cloud-init. For the full list of images, see [Using cloud-init](using-cloud-init.md).
46
+
47
+
The easiest way to manage swap for these images is to complete these steps:
48
+
49
+
1. In the **/var/lib/cloud/scripts/per-boot** folder, create a file called **create_swapfile.sh**:
**$ sudo vi /var/lib/cloud/scripts/per-boot/create_swapfile.sh**
56
+
57
+
```
58
+
#!/bin/sh
59
+
if [ ! -f '/mnt/swapfile' ]; then
60
+
fallocate --length 2GiB /mnt/swapfile
61
+
chmod 600 /mnt/swapfile
62
+
mkswap /mnt/swapfile
63
+
swapon /mnt/swapfile
64
+
swapon -a ; fi
65
+
```
66
+
67
+
> [!NOTE]
68
+
> You can change the value according to your need and based on the available space in your resource disk, which varies based on the VM size being used.
For images without cloud-init support, VM images deployed from the Azure Marketplace have a VM Linux Agent integrated with the OS. This agent allows the VM to interact with various Azure services. Assuming you have deployed a standard image from the Azure Marketplace, you would need to do the following to correctly configure your Linux swap file settings:
0 commit comments