Skip to content

Commit 8410470

Browse files
committed
Getting rid of extra swap-space instructions
1 parent f89b528 commit 8410470

File tree

1 file changed

+17
-56
lines changed

1 file changed

+17
-56
lines changed

articles/virtual-machines/linux/create-upload-generic.md

Lines changed: 17 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -228,37 +228,37 @@ The [Azure Linux Agent](../extensions/agent-linux.md) `waagent` provisions a Lin
228228
sudo systemctl enable cloud-init.service
229229
```
230230

231+
1. Swap: Do not create swap space on the OS disk.
231232

232-
1. 7. Swap: Do not create swap space on the OS disk.
233+
The Azure Linux Agent or Cloud-init can be used to configure swap space using the local resource disk. This resource disk is attached to the VM after provisioning on Azure. The local resource disk is a temporary disk, and might be emptied when the VM is deprovisioned. The following blocks show how to configure this swap.
233234

234-
The Azure Linux Agent or Cloud-init can be used to configure swap space using the local resource disk. This resource disk is attached to the VM after provisioning on Azure. The local resource disk is a temporary disk, and might be emptied when the VM is deprovisioned. The following blocks show how to configure this swap.
235+
Azure Linux Agent
236+
Modify the following parameters in /etc/waagent.conf
235237

236-
Azure Linux Agent
237-
Modify the following parameters in /etc/waagent.conf
238-
```
239-
ResourceDisk.Format=y
240-
ResourceDisk.Filesystem=ext4
241-
ResourceDisk.MountPoint=/mnt/resource
242-
ResourceDisk.EnableSwap=y
243-
ResourceDisk.SwapSizeMB=2048 ## NOTE: Set this to your desired size.
244-
```
238+
```
239+
ResourceDisk.Format=y
240+
ResourceDisk.Filesystem=ext4
241+
ResourceDisk.MountPoint=/mnt/resource
242+
ResourceDisk.EnableSwap=y
243+
ResourceDisk.SwapSizeMB=2048 ## NOTE: Set this to your desired size.
244+
```
245245

246-
Cloud-init
247-
Configure cloud-init to handle the provisioning:
246+
Cloud-init
247+
Configure cloud-init to handle the provisioning:
248248

249249
```bash
250250
sed -i 's/Provisioning.Agent=auto/Provisioning.Agent=cloud-auto/g' /etc/waagent.conf
251251
sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
252252
sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
253253
```
254254

255-
Configure Cloud-init to create swap.
255+
Configure Cloud-init to create swap.
256256

257-
To format and create swap you have 2 options either:
257+
To format and create swap you have 2 options either:
258258

259-
1. Pass this in as a cloud-init config every time you create a VM through `customdata`. This is the recommended method.
259+
1. Pass this in as a cloud-init config every time you create a VM through `customdata`. This is the recommended method.
260260

261-
2. Use a cloud-init directive baked into the image that will do this every time the VM is created.
261+
2. Use a cloud-init directive baked into the image that will do this every time the VM is created.
262262

263263
Create cfg file to configure swap using Cloud-init:
264264

@@ -283,14 +283,6 @@ To format and create swap you have 2 options either:
283283
EOF
284284
```
285285
286-
2. Don't create swap space on the OS disk. The Azure Linux Agent can automatically configure swap space using the local resource disk that is attached to the VM after provisioning on Azure. The local resource disk is a temporary disk, and might be emptied when the VM is deprovisioned. After installing the Azure Linux Agent, modify the following parameters in /etc/waagent.conf as needed.
287-
```
288-
ResourceDisk.Format=y
289-
ResourceDisk.Filesystem=ext4
290-
ResourceDisk.MountPoint=/mnt/resource
291-
ResourceDisk.EnableSwap=y
292-
ResourceDisk.SwapSizeMB=2048 ## NOTE: Set this to your desired size.
293-
```
294286
295287
9. Configure cloud-init to handle the provisioning:
296288
1. Configure waagent for cloud-init:
@@ -337,37 +329,6 @@ To format and create swap you have 2 options either:
337329
EOF
338330
```
339331
340-
10. Swap configuration. Do not create swap space on the operating system disk.
341-
Previously, the Azure Linux Agent automatically configured swap space by using the local resource disk that is attached to the virtual machine after the virtual machine is provisioned on Azure. However, this is now handled by cloud-init, you must not use the Linux Agent to format the resource disk create the swap file, modify the following parameters in /etc/waagent.conf appropriately:
342-
```
343-
ResourceDisk.Format=n
344-
ResourceDisk.EnableSwap=n
345-
```
346-
If you want to mount, format and create swap you can either:
347-
1. Pass this in as a cloud-init config every time you create a VM through `customdata`. This is the recommended method.
348-
2. Use a cloud-init directive baked into the image that will do this every time the VM is created.
349-
350-
```
351-
echo 'DefaultEnvironment="CLOUD_CFG=/etc/cloud/cloud.cfg.d/00-azure-swap.cfg"' >> /etc/systemd/system.conf
352-
cat > /etc/cloud/cloud.cfg.d/00-azure-swap.cfg << EOF
353-
#cloud-config
354-
# Generated by Azure cloud image build
355-
disk_setup:
356-
ephemeral0:
357-
table_type: mbr
358-
layout: [66, [33, 82]]
359-
overwrite: True
360-
fs_setup:
361-
- device: ephemeral0.1
362-
filesystem: ext4
363-
- device: ephemeral0.2
364-
filesystem: swap
365-
mounts:
366-
- ["ephemeral0.1", "/mnt"]
367-
- ["ephemeral0.2", "none", "swap", "sw,nofail,x-systemd.requires=cloud-init.service,x-systemd.device-timeout=2", "0", "0"]
368-
EOF
369-
370-
```
371332
372333
1. Deprovision.
373334
> [!CAUTION]

0 commit comments

Comments
 (0)