Manual Swap creation in Linux

Source: Internet
Author: User
Swap is a Swap partition in Linux, similar to Windows virtual memory. when the physical memory is insufficient, the system can put some programs that are not frequently used in the memory into Swap to solve the problem of insufficient physical memory. If the Swap space opened during system installation is too small, you can manually create a Swap file. 1. create the file ddif =/dev/zeroof = kwxgdbs = 1024 count = 1024000SSH and execute the preceding commands,

Swap is a Swap partition in Linux, similar to Windows virtual memory. when the physical memory is insufficient, the system can put some programs that are not frequently used in the memory into Swap to solve the problem of insufficient physical memory.

If the Swap space opened during system installation is too small, you can manually create a Swap file.


1. create a file
dd if=/dev/zero of=kwxgd bs=1024 count=1024000

Run the preceding command in SSH to create a 1G empty file named kwxgd (write 0 occupies disk ).


II. create a Swap file
mkswap kwxgd

Run the preceding command in SSH to generate the generated kwxgd as a SWAP file. if the SWAP file is not created, the following error may occur during the next step: "swapon: kwxgd: read swap header failed: invalid argument "error.


3. make the Swap file take effect
swapon kwxgd

Run the preceding command in SSH to make the "kwxgd" Swap file take effect and overwrite it into the current sawp space.


4. view the current SWAP
swapon -s

Run the preceding command in SSH to view the current situation of swap.


5. Automatic mounting
1) edit/etc/fstab
vi /etc/fstab

2) Fill in according to the format
/root/kwxgd   swap    swap    defaults      0    1

Enter the preceding information in the format and save it, as shown in.

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