Linux Manually create swap

Source: Internet
Author: User

Swap is the swap partition under Linux, similar to the virtual memory of windows, when the physical memory is low, the system can put some memory of infrequently used programs into swap, to solve the situation of physical memory shortage.

If the swap space created by the system installation is too small, you can create swap files manually.


First, create a file


DD If=/dev/zero of=/root/swapfile bs=1024 count=1024000


SSH executes the above command to create a 1G empty file named Kwxgd (write 0 to occupy the disk).


Second, make the swap file


Mkswap KWXGD


SSH executes the above command, the generated KWXGD is made into swap files, if you do not make swap files, the next step may appear: "Swapon:kwxgd:read swap header failed:invalid argument" error.


Third, the swap file to enter into force


Swapon KWXGD


SSH executes the above command so that the "KWXGD" swap file takes effect and is superimposed into the current SAWP space.


Iv. View Current Swap


Swapon-s


SSH executes the above command to see the current swap situation.


Five, automatic mount


1) Edit/etc/fstab


Vi/etc/fstab


2) fill in by format

/root/swapfile Swap swap Defaults 0 1

This article from "the more efforts, the more fortunate!" "Blog, be sure to keep this provenance http://7250365.blog.51cto.com/7240365/1690729

Linux Manually create 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.