Aliyun CentOS server Add swap space

Source: Internet
Author: User
Tags centos server aliyun


I am now using the Aliyun minimum configured server, 1 cores, 512MB memory, viewing memory information swap space is 0MB, as follows:
[root@www ~]# free-m
              total       used        free     shared    buffers     Cached
mem:           494         124        370           0          7        
-/+ buffers/cache:         74         419
swap:            0           0          0

After searching for information, the following solutions are available in the Aliyun forum:

Source Address: http://bbs.aliyun.com/read/139905.html?spm=5176.7189909.0.0.bE6Z3x

1. Access to catalogue

cd/var/

2. Get the block of swap files to add (here in 1GB for example, Count = 1024 x 1024)

DD If=/dev/zero of=swapfile bs=1024 count=1048576


3. Create a swap file

/sbin/mkswap Swapfile

4. Activate swap file

/sbin/swapon Swapfile (now you can see the swap space with the free command)

5. See if swap information is correct

/sbin/swapon–s

6. Add to Fstab file to allow system to boot automatically when booting

echo "/var/swapfile swap defaults 0 0" >>/etc/fstab

7. Modify/etc/rc.local

Cat/etc/rc.local
Touch/var/lock/subsys/local
#swapoff-A

8. Reboot the server

Reboot

The results are as follows:

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.