Aliyun ECS Linux Add or remove virtual memory swap

Source: Internet
Author: User
Tags aliyun

One, add swap

1. Use the following command to create a 1G swap space.

DD If=/dev/zero Of=/tmp/swap BS=1MB count=1024

2. Make a swap file

Mkswap/tmp/swap

3, start the swap partition.

Swapon/tmp/swap

4, this operation is only valid for the current, restart the server after the expiration. If you want to keep it going. You can edit the/etc/fstab file:

Vim/etc/fstab

and add the following, save to ensure that the added virtual memory swap is permanently in effect.

/tmp/swap Swap Defaults 0 0

Second, delete swap

If you no longer need virtual memory swap, delete the/tmp/swap swap defaults 0 0 content in the/etc/fstab file. and recycle the swap space.

Swapoff/tmp/swap
Rm/tmp/swap

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.