问题原文
原帖链接 · bitinn · CC BY-SA 3.0
I have read quite a few posts on this, but I am still unsure about the correct approach, assuming:
I have a default Ubuntu 14.04 LTS VM created by and running on Azure, which doesn't come with a swap
I would like to create a swap using existing VM storage, instead of create a new disk using additional storage
Posts I have read:
- https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-how-to-inject-custom-data/
- https://wiki.ubuntu.com/AzureSwapPartitions
- https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/1374166
Many solutions were discussed but I can't seem to find one that will persists across server reboots (probably due to cloud-init has it's own idea about image partitioning), can someone advise me on the best practice?
社区高分解答
原帖链接 · Bruno Faria · CC BY-SA 3.0
Assuming that you have Linux Agent installed. All you have to do is to enable swap under /etc/waagent.conf. These are the relevant lines:
ResourceDisk.Format=y # Format if unformatted. If 'n', resour$
ResourceDisk.Filesystem=ext4 # Typically ext3 or ext4. FreeBSD image$
ResourceDisk.MountPoint=/mnt/resource #
ResourceDisk.EnableSwap=y # Create and use swapfile on resource d$
ResourceDisk.SwapSizeMB=2048 # Size of the swapfile.
It will automatically use the resource disk (which comes with every VM) to create the swap. There's no need to create a disk for it.
Update: You also need to execute the steps below in order to create the swapfile:
umount /mnt
service walinuxagent restart
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
