Linux-swap Size Change and optimization

Source: Internet
Author: User

Swap size Change

Assuming the current system swap size is 4GB, you want to increase the swap size to 5GB.

The steps are as follows:

View current swap size


Increase the 1GBswap size, assuming the file path and name:/snow/swapfile, execute the following command

DD If=/dev/zero of=/snow/swapfile bs=1m count=1024

Create swap, the file size is 1GB after successful creation


Activate swap


Set the swap security permission to 600

chmod 600/snow/swapfile

Use the free-h command to check that the swap size has been updated successfully


If you want to change back to the original swap size, execute the following command


Use free-h again to see that the value of swap has been changed back to the original 4GB Swap-Optimized file/proc/sys/vm/swappiness, the value inside represents the ratio of physical memory. If 20, indicates that physical memory is used for 80% of the time to temporarily adjust the size of the value of the swap space-assuming that the value of 10 to execute the following command

Sysctl vm.swappiness=10


echo >/proc/sys/vm/swappiness

Permanent adjustment:

vim/etc/sysctl.conf Add a line: vm.swappiness=10

Linux-swap Size Change and optimization

Related Article

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: 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.