Command for adding Swap space through the Swap file

Source: Internet
Author: User

If SWaP space is used up, an error occurs. Therefore, we need to make a correct partition of the SWaP space when installing the system, and know how to increase the SWaP space when the Swap space is reduced. Here, we will briefly introduce how to increase the Swap space through the SWaP file to save your effort.

1) become a Super User
$ Su-root

2) create a Swap file
# Dd if =/dev/zero of = swapfile bs = 1024 count = 65536

Create a swap file with continuous space.

3) activate the Swap file
#/Usr/sbin/swapon swapfile

Swapfile refers to the swap file created in the previous step.

4) now the newly added Swap file has taken effect, but after the system restarts, it does not remember the previous steps. Therefore, you must record the file name and Swap type in the/etc/fstab file, for example,/path/swapfile none Swap sw, pri = 3 0 0

5) check whether the Swap file is added
/Usr/sbin/swapon-s

Delete excess Swap space

1) become a Super User

2) use the Swapoff command to reclaim Swap space.
#/Usr/sbin/swapoff swapfile

3) edit the/etc/fstab file and remove the entity of the Swap file.

4) reclaim the file from the file system.
# Rm swapfile

5) Of course, if the Swap space is not a Swap file but a partition, you need to create a new file system and then mount it to the original file system.

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.