Add a SWAP partition after installing the Linux/centos System

Source: Internet
Author: User

Add a SWAP partition after installing the Linux/centos System
Usage of swap partitioning: swap puts data into swap when the physical memory is insufficient. Therefore, swap plays a role in virtual memory, in a sense, memory space is also increased. Generally, the swap partition is set when the system is installed. If you forget to divide the swap partition when installing the system, it will be okay and there is a remedy. The following describes how to add a swap partition after installing the system.

Scenario:
After the system is installed, it is hard to find that SWAP partitions are not divided. For production servers, this obviously does not work. Therefore, you need to add SWAP partitions.


1. First check the swap size
# Free
Total used free shared buffers cached
Mem: 3922944 158168 3764776 0 6948 37384
-/+ Buffers/cache: 113836 3809108
Swap: 0 0 0

Obviously, it is displayed as zero.


2. Run the dd command to create a swap partition.
# Dd if =/dev/zero of =/doiido/swap bs = 1024 count = 8388608

Calculation Formula of count: count = SIZE * 1024 (size in MB)
In this way, create a/doiido/swap partition file with a size of 8 GB.


3. format the new partition.
# Mkswap/main/swap


4. Change the new partition to a swap partition.
# Swapon/main/swap

Note: The command to disable SWAP partitioning is: # swapoff/main/swap


5. view the swap size again
# Free
Total used free shared buffers cached
Mem: 3922944 158168 3764776 0 6948 37384
-/+ Buffers/cache: 113836 3809108
Swap: 8388608 0 8388608


6. automatically mount swap upon startup
# Echo "/main/swap defaults 0 0">/etc/fstab
The SWAP partition is created.

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.